diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-11-09 16:50:57 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2015-11-09 16:50:57 +0100 |
commit | f094cb287ed535a8f45e0ce61a57a06bec642876 (patch) | |
tree | f7c9de5feb185fa3d1de52f275953625f7cf86b0 /src/nspawn/nspawn.c | |
parent | 4286219103a7791ff9114b7dcc8e9938d154af3e (diff) | |
parent | 9fb16425199c2b9cf1d6cc1cafb974bdfbceec5c (diff) |
Merge pull request #1817 from iaguis/nspawn-custom-service-3
nspawn: support custom container service name
Diffstat (limited to 'src/nspawn/nspawn.c')
-rw-r--r-- | src/nspawn/nspawn.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index ff12ca6498..4c426e6874 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -178,6 +178,7 @@ static bool arg_unified_cgroup_hierarchy = false; static SettingsMask arg_settings_mask = 0; static int arg_settings_trusted = -1; static char **arg_parameters = NULL; +static const char *arg_container_service_name = "systemd-nspawn"; static void help(void) { printf("%s [OPTIONS...] [PATH] [ARGUMENTS...]\n\n" @@ -387,7 +388,7 @@ static int parse_argv(int argc, char *argv[]) { }; int c, r; - const char *p; + const char *p, *e; uint64_t plus = 0, minus = 0; bool mask_all_settings = false, mask_no_settings = false; @@ -909,6 +910,10 @@ static int parse_argv(int argc, char *argv[]) { if (r < 0) return r; + e = getenv("SYSTEMD_NSPAWN_CONTAINER_SERVICE"); + if (e) + arg_container_service_name = e; + return 1; } @@ -2404,10 +2409,10 @@ static int inner_child( FDSet *fds) { _cleanup_free_ char *home = NULL; - unsigned n_env = 2; + unsigned n_env = 1; const char *envp[] = { "PATH=" DEFAULT_PATH_SPLIT_USR, - "container=systemd-nspawn", /* LXC sets container=lxc, so follow the scheme here */ + NULL, /* container */ NULL, /* TERM */ NULL, /* HOME */ NULL, /* USER */ @@ -2508,6 +2513,9 @@ static int inner_child( if (r < 0) return r; + /* LXC sets container=lxc, so follow the scheme here */ + envp[n_env++] = strjoina("container=", arg_container_service_name); + envp[n_env] = strv_find_prefix(environ, "TERM="); if (envp[n_env]) n_env ++; @@ -3426,7 +3434,8 @@ int main(int argc, char *argv[]) { arg_custom_mounts, arg_n_custom_mounts, arg_kill_signal, arg_property, - arg_keep_unit); + arg_keep_unit, + arg_container_service_name); if (r < 0) goto finish; } |