diff --git a/man/systemd-nspawn.xml b/man/systemd-nspawn.xml index 3623ef015a..e84ac6ae42 100644 --- a/man/systemd-nspawn.xml +++ b/man/systemd-nspawn.xml @@ -527,14 +527,14 @@ - - + + - Specifies an environment variable assignment - to pass to the init process in the container, in the format - NAME=VALUE. This may be used to override - the default variables or to set additional variables. This - parameter may be used more than once. + Specifies an environment variable to pass to the init process in the container. This + may be used to override the default variables or to set additional variables. It may be used more + than once to set multiple variables. When = and VALUE + are omitted, the value of the variable with the same name in the program environment will be used. + diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index cf89b27dfa..3d7e20e72e 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -338,7 +338,7 @@ static int help(void) { " -a --as-pid2 Maintain a stub init as PID1, invoke binary as PID2\n" " -b --boot Boot up full system (i.e. invoke init)\n" " --chdir=PATH Set working directory in the container\n" - " -E --setenv=NAME=VALUE Pass an environment variable to PID 1\n" + " -E --setenv=NAME[=VALUE] Pass an environment variable to PID 1\n" " -u --user=USER Run the command under specified user or UID\n" " --kill-signal=SIGNAL Select signal to use for shutting down PID 1\n" " --notify-ready=BOOLEAN Receive notifications from the child init process\n\n" @@ -1121,17 +1121,13 @@ static int parse_argv(int argc, char *argv[]) { arg_settings_mask |= SETTING_CUSTOM_MOUNTS; break; - case 'E': { - if (!env_assignment_is_valid(optarg)) - return log_error_errno(SYNTHETIC_ERRNO(EINVAL), - "Environment variable assignment '%s' is not valid.", optarg); - r = strv_env_replace_strdup(&arg_setenv, optarg); + case 'E': + r = strv_env_replace_strdup_passthrough(&arg_setenv, optarg); if (r < 0) - return r; + return log_error_errno(r, "Cannot assign environment variable %s: %m", optarg); arg_settings_mask |= SETTING_ENVIRONMENT; break; - } case 'q': arg_quiet = true;