Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

features: Support mountExtensions #1279

Merged
merged 1 commit into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/libcrun/container.c
Original file line number Diff line number Diff line change
Expand Up @@ -3886,7 +3886,7 @@ libcrun_container_get_features (libcrun_context_t *context, struct features_info

// Hardcoded feature information
(*info)->oci_version_min = xstrdup ("1.0.0");
(*info)->oci_version_max = xstrdup ("1.1.0");
(*info)->oci_version_max = xstrdup ("1.1.0+dev");

// Populate hooks
populate_array_field (&((*info)->hooks), hooks, num_hooks);
Expand Down Expand Up @@ -3925,6 +3925,9 @@ libcrun_container_get_features (libcrun_context_t *context, struct features_info
(*info)->linux.apparmor.enabled = true;
(*info)->linux.selinux.enabled = true;

// Put the values for mount extensions
(*info)->linux.mount_ext.idmap.enabled = true;

// Populate the values for annotations
#ifdef HAVE_SECCOMP
{
Expand Down
11 changes: 11 additions & 0 deletions src/libcrun/container.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,16 @@ struct selinux_info_s
bool enabled;
};

struct idmap_info_s
{
bool enabled;
};

struct mount_ext_info_s
{
struct idmap_info_s idmap;
};

struct linux_info_s
{
char **namespaces;
Expand All @@ -129,6 +139,7 @@ struct linux_info_s
struct seccomp_info_s seccomp;
struct apparmor_info_s apparmor;
struct selinux_info_s selinux;
struct mount_ext_info_s mount_ext;
};

struct annotations_info_s
Expand Down
15 changes: 15 additions & 0 deletions src/oci_features.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,20 @@ crun_features_add_selinux_info (yajl_gen json_gen, const struct linux_info_s *li
yajl_gen_map_close (json_gen);
}

void
crun_features_add_mount_ext_info (yajl_gen json_gen, const struct linux_info_s *linux)
{
yajl_gen_string (json_gen, (const unsigned char *) "mountExtensions", strlen ("mountExtensions"));
yajl_gen_map_open (json_gen);

yajl_gen_string (json_gen, (const unsigned char *) "idmap", strlen ("idmap"));
yajl_gen_map_open (json_gen);
add_bool_to_json (json_gen, "enabled", linux->mount_ext.idmap.enabled);
yajl_gen_map_close (json_gen);

yajl_gen_map_close (json_gen);
}

void
crun_features_add_linux_info (yajl_gen json_gen, const struct linux_info_s *linux)
{
Expand All @@ -182,6 +196,7 @@ crun_features_add_linux_info (yajl_gen json_gen, const struct linux_info_s *linu
crun_features_add_seccomp_info (json_gen, linux);
crun_features_add_apparmor_info (json_gen, linux);
crun_features_add_selinux_info (json_gen, linux);
crun_features_add_mount_ext_info (json_gen, linux);

yajl_gen_map_close (json_gen);
}
Expand Down
7 changes: 6 additions & 1 deletion tests/test_oci_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def test_crun_features():
features = json.loads(output)
expected_features = {
"ociVersionMin": "1.0.0",
"ociVersionMax": "1.1.0",
"ociVersionMax": "1.1.0+dev",
"hooks": [
"prestart",
"createRuntime",
Expand Down Expand Up @@ -155,6 +155,11 @@ def test_crun_features():
},
"selinux": {
"enabled": True
},
"mountExtensions": {
"idmap": {
"enabled": True,
},
}
},
"annotations": {
Expand Down