conf: add first, trivial support for idmapped mounts

parent 0b932f9d
......@@ -98,6 +98,10 @@
#include <../include/prlimit.h>
#endif
#ifndef HAVE_STRLCPY
#include "include/strlcpy.h"
#endif
lxc_log_define(conf, lxc);
/*
......@@ -2095,6 +2099,7 @@ const char *lxc_mount_options_info[LXC_MOUNT_MAX] = {
"create=file",
"optional",
"relative",
"idmap=",
};
/* Remove "optional", "create=dir", and "create=file" from mntopt */
......@@ -2103,7 +2108,8 @@ void parse_lxc_mntopts(struct lxc_mount_options *opts, char *mnt_opts)
for (size_t i = LXC_MOUNT_CREATE_DIR; i < LXC_MOUNT_MAX; i++) {
const char *opt_name = lxc_mount_options_info[i];
char *p, *p2;
size_t len;
char *idmap_path, *p, *p2;
p = strstr(mnt_opts, opt_name);
if (!p)
......@@ -2122,9 +2128,20 @@ void parse_lxc_mntopts(struct lxc_mount_options *opts, char *mnt_opts)
case LXC_MOUNT_RELATIVE:
opts->relative = 1;
break;
case LXC_MOUNT_IDMAP:
p2 = p;
p2 += STRLITERALLEN("idmap=");
idmap_path = strchrnul(p2, ',');
len = strlcpy(opts->userns_path, p2, idmap_path - p2 + 1);
if (len >= sizeof(opts->userns_path))
WARN("Excessive idmap path length for \"idmap=<path>\" LXC specific mount option");
else
TRACE("Parse LXC specific mount option \"idmap=%s\"", opts->userns_path);
break;
default:
WARN("Unknown LXC specific mount option");
continue;
break;
}
p2 = strchr(p, ',');
......
......@@ -186,7 +186,8 @@ typedef enum lxc_mount_options_t {
LXC_MOUNT_CREATE_FILE = 1,
LXC_MOUNT_OPTIONAL = 2,
LXC_MOUNT_RELATIVE = 3,
LXC_MOUNT_MAX = 4,
LXC_MOUNT_IDMAP = 4,
LXC_MOUNT_MAX = 5,
} lxc_mount_options_t;
__hidden extern const char *lxc_mount_options_info[LXC_MOUNT_MAX];
......@@ -196,6 +197,7 @@ struct lxc_mount_options {
int create_file : 1;
int optional : 1;
int relative : 1;
char userns_path[PATH_MAX];
};
/* Defines a structure to store the rootfs location, the
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment