nspawn: add --uuid= switch to allow setting the machine id for the container
This commit is contained in:
parent
5cd6eef69b
commit
144f0fc0c8
6
TODO
6
TODO
|
@ -43,8 +43,6 @@ Features:
|
||||||
|
|
||||||
* cg_shorten_controllers() misuses alloca()
|
* cg_shorten_controllers() misuses alloca()
|
||||||
|
|
||||||
* suspend/hibernate/hybrid support, auto-suspend logic with idle hint
|
|
||||||
|
|
||||||
* udev systemd unify:
|
* udev systemd unify:
|
||||||
- strpcpy(), strpcpyl(), strscpy(), strscpyl()
|
- strpcpy(), strpcpyl(), strscpy(), strscpyl()
|
||||||
- utf8 validator code
|
- utf8 validator code
|
||||||
|
@ -80,8 +78,6 @@ Features:
|
||||||
|
|
||||||
* add man page documenting all kernel cmdline options, including stuff like fsck.mode=
|
* add man page documenting all kernel cmdline options, including stuff like fsck.mode=
|
||||||
|
|
||||||
* show getty in container mode, not sulogin
|
|
||||||
|
|
||||||
* support container_ttys=
|
* support container_ttys=
|
||||||
|
|
||||||
* journald: make configurable "store-on-var", "store-on-run", "dont-store", "auto"
|
* journald: make configurable "store-on-var", "store-on-run", "dont-store", "auto"
|
||||||
|
@ -109,7 +105,7 @@ Features:
|
||||||
|
|
||||||
* add command to systemctl to plot dependency graph as tree (see rhbz 795365)
|
* add command to systemctl to plot dependency graph as tree (see rhbz 795365)
|
||||||
|
|
||||||
* make logind reserve tty10 or so for text logins, so that gdm never picks it up
|
* make logind reserve tty9 or so for text logins, so that gdm never picks it up
|
||||||
|
|
||||||
* add option to sockets to avoid activation. Instead just drop packets/connections, see http://cyberelk.net/tim/2012/02/15/portreserve-systemd-solution/
|
* add option to sockets to avoid activation. Instead just drop packets/connections, see http://cyberelk.net/tim/2012/02/15/portreserve-systemd-solution/
|
||||||
|
|
||||||
|
|
|
@ -164,6 +164,17 @@
|
||||||
</para></listitem>
|
</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><option>--uuid=</option></term>
|
||||||
|
|
||||||
|
<listitem><para>Set the specified uuid
|
||||||
|
for the container. The init system
|
||||||
|
will initialize
|
||||||
|
<filename>/etc/machine-id</filename>
|
||||||
|
from this if this file is not set yet.
|
||||||
|
</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><option>--controllers=</option></term>
|
<term><option>--controllers=</option></term>
|
||||||
<term><option>-C</option></term>
|
<term><option>-C</option></term>
|
||||||
|
|
|
@ -55,6 +55,7 @@
|
||||||
static char *arg_directory = NULL;
|
static char *arg_directory = NULL;
|
||||||
static char *arg_user = NULL;
|
static char *arg_user = NULL;
|
||||||
static char **arg_controllers = NULL;
|
static char **arg_controllers = NULL;
|
||||||
|
static char *arg_uuid = NULL;
|
||||||
static bool arg_private_network = false;
|
static bool arg_private_network = false;
|
||||||
static bool arg_boot = false;
|
static bool arg_boot = false;
|
||||||
|
|
||||||
|
@ -67,6 +68,7 @@ static int help(void) {
|
||||||
" -b --boot Boot up full system (i.e. invoke init)\n"
|
" -b --boot Boot up full system (i.e. invoke init)\n"
|
||||||
" -u --user=USER Run the command under specified user or uid\n"
|
" -u --user=USER Run the command under specified user or uid\n"
|
||||||
" -C --controllers=LIST Put the container in specified comma-separated cgroup hierarchies\n"
|
" -C --controllers=LIST Put the container in specified comma-separated cgroup hierarchies\n"
|
||||||
|
" --uuid=UUID Set a specific machine UUID for the container\n"
|
||||||
" --private-network Disable network in container\n",
|
" --private-network Disable network in container\n",
|
||||||
program_invocation_short_name);
|
program_invocation_short_name);
|
||||||
|
|
||||||
|
@ -76,7 +78,8 @@ static int help(void) {
|
||||||
static int parse_argv(int argc, char *argv[]) {
|
static int parse_argv(int argc, char *argv[]) {
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
ARG_PRIVATE_NETWORK = 0x100
|
ARG_PRIVATE_NETWORK = 0x100,
|
||||||
|
ARG_UUID
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct option options[] = {
|
static const struct option options[] = {
|
||||||
|
@ -86,6 +89,7 @@ static int parse_argv(int argc, char *argv[]) {
|
||||||
{ "controllers", required_argument, NULL, 'C' },
|
{ "controllers", required_argument, NULL, 'C' },
|
||||||
{ "private-network", no_argument, NULL, ARG_PRIVATE_NETWORK },
|
{ "private-network", no_argument, NULL, ARG_PRIVATE_NETWORK },
|
||||||
{ "boot", no_argument, NULL, 'b' },
|
{ "boot", no_argument, NULL, 'b' },
|
||||||
|
{ "uuid", required_argument, NULL, ARG_UUID },
|
||||||
{ NULL, 0, NULL, 0 }
|
{ NULL, 0, NULL, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -140,6 +144,10 @@ static int parse_argv(int argc, char *argv[]) {
|
||||||
arg_boot = true;
|
arg_boot = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case ARG_UUID:
|
||||||
|
arg_uuid = optarg;
|
||||||
|
break;
|
||||||
|
|
||||||
case '?':
|
case '?':
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
@ -912,6 +920,7 @@ int main(int argc, char *argv[]) {
|
||||||
NULL, /* HOME */
|
NULL, /* HOME */
|
||||||
NULL, /* USER */
|
NULL, /* USER */
|
||||||
NULL, /* LOGNAME */
|
NULL, /* LOGNAME */
|
||||||
|
NULL, /* container_uuid */
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1022,13 +1031,20 @@ int main(int argc, char *argv[]) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((asprintf((char**)(envp + 3), "HOME=%s", home? home: "/root") < 0) ||
|
if ((asprintf((char**)(envp + 3), "HOME=%s", home ? home: "/root") < 0) ||
|
||||||
(asprintf((char**)(envp + 4), "USER=%s", arg_user? arg_user : "root") < 0) ||
|
(asprintf((char**)(envp + 4), "USER=%s", arg_user ? arg_user : "root") < 0) ||
|
||||||
(asprintf((char**)(envp + 5), "LOGNAME=%s", arg_user? arg_user : "root") < 0)) {
|
(asprintf((char**)(envp + 5), "LOGNAME=%s", arg_user ? arg_user : "root") < 0)) {
|
||||||
log_error("Out of memory");
|
log_error("Out of memory");
|
||||||
goto child_fail;
|
goto child_fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (arg_uuid) {
|
||||||
|
if (asprintf((char**)(envp + 6), "container_uuid=%s", arg_uuid) < 0) {
|
||||||
|
log_error("Out of memory");
|
||||||
|
goto child_fail;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setup_hostname();
|
setup_hostname();
|
||||||
|
|
||||||
if (arg_boot) {
|
if (arg_boot) {
|
||||||
|
|
Loading…
Reference in New Issue