</listitem>
</varlistentry>
+ <varlistentry>
+ <term>
+ <option>--share-uts <replaceable>name|pid</replaceable></option>
+ </term>
+ <listitem>
+ <para>
+ Inherit a UTS namespace from
+ a <replaceable>name</replaceable> container or
+ a <replaceable>pid</replaceable>. The starting LXC will
+ not set the hostname, but the container OS may do it
+ anyway.
+ </para>
+ </listitem>
+ </varlistentry>
+
</variablelist>
</refsect1>
int lxc_setup(const char *name, struct lxc_conf *lxc_conf, const char *lxcpath, struct cgroup_process_info *cgroup_info)
{
- if (setup_utsname(lxc_conf->utsname)) {
- ERROR("failed to setup the utsname for '%s'", name);
- return -1;
+ if (lxc_conf->inherit_ns_fd[LXC_NS_UTS] == -1) {
+ if (setup_utsname(lxc_conf->utsname)) {
+ ERROR("failed to setup the utsname for '%s'", name);
+ return -1;
+ }
}
if (setup_network(&lxc_conf->network)) {
#define OPT_SHARE_NET OPT_USAGE+1
#define OPT_SHARE_IPC OPT_USAGE+2
+#define OPT_SHARE_UTS OPT_USAGE+3
lxc_log_define(lxc_start_ui, lxc_start);
case 'p': args->pidfile = arg; break;
case OPT_SHARE_NET: args->share_ns[LXC_NS_NET] = arg; break;
case OPT_SHARE_IPC: args->share_ns[LXC_NS_IPC] = arg; break;
+ case OPT_SHARE_UTS: args->share_ns[LXC_NS_UTS] = arg; break;
}
return 0;
}
{"pidfile", required_argument, 0, 'p'},
{"share-net", required_argument, 0, OPT_SHARE_NET},
{"share-ipc", required_argument, 0, OPT_SHARE_IPC},
+ {"share-uts", required_argument, 0, OPT_SHARE_UTS},
LXC_COMMON_OPTIONS
};
-s, --define KEY=VAL Assign VAL to configuration variable KEY\n\
--share-net=NAME Share a network namespace with another container or pid\n\
--share-ipc=NAME Share an IPC namespace with another container or pid\n\
+ --share-uts=NAME Share a UTS namespace with another container or pid\n\
",
.options = my_longopts,
.parser = my_parser,
int preserve_mask = 0, i;
for (i = 0; i < LXC_NS_MAX; i++)
- if (handler->conf->inherit_ns_fd[i] > -1)
+ if (handler->conf->inherit_ns_fd[i] != -1)
preserve_mask |= ns_info[i].clone_flag;
if (lxc_sync_init(handler))
return -1;
- handler->clone_flags = CLONE_NEWUTS|CLONE_NEWPID|CLONE_NEWNS;
+ handler->clone_flags = CLONE_NEWPID|CLONE_NEWNS;
if (!lxc_list_empty(&handler->conf->id_map)) {
INFO("Cloning a new user namespace");
handler->clone_flags |= CLONE_NEWUSER;
INFO("Inheriting an IPC namespace");
}
+ if (handler->conf->inherit_ns_fd[LXC_NS_UTS] == -1) {
+ handler->clone_flags |= CLONE_NEWUTS;
+ } else {
+ INFO("Inheriting a UTS namespace");
+ }
+
cgroup_meta = lxc_cgroup_load_meta();
if (!cgroup_meta) {