diff --git a/man/systemctl.xml b/man/systemctl.xml index 47bb608459..27207fcf49 100644 --- a/man/systemctl.xml +++ b/man/systemctl.xml @@ -1118,7 +1118,7 @@ Jan 12 10:46:45 example.com bluetoothd[8900]: gatt-time-server: Input/output err import-environment - VARIABLE… + VARIABLE… @@ -1129,6 +1129,11 @@ Jan 12 10:46:45 example.com bluetoothd[8900]: gatt-time-server: Input/output err arguments are passed, the entire environment block inherited by the systemctl process is imported. In this mode, any inherited invalid environment variables are quietly ignored. + + Importing of the full inherited environment block (calling this command without any + arguments) is deprecated. A shell will set dozens of variables which only make sense locally and + are only meant for processes which are descendants of the shell. Such variables in the global + environment block are confusing to other processes. diff --git a/man/systemd.exec.xml b/man/systemd.exec.xml index a9d863bfda..ed8ab6205c 100644 --- a/man/systemd.exec.xml +++ b/man/systemd.exec.xml @@ -2854,7 +2854,8 @@ StandardInputData=SWNrIHNpdHplIGRhIHVuJyBlc3NlIEtsb3BzLAp1ZmYgZWVtYWwga2xvcHAncy configuration, with just a few environment variables. The user manager inherits environment variables as any other system service, but in addition may receive additional environment variables from PAM, and, typically, additional imported variables when the user starts a graphical session. It is recommended to - keep the environment blocks in both the system and user managers managers lean. + keep the environment blocks in both the system and user managers managers lean. Importing all variables + inherited by the graphical session or by one of the user shells is strongly discouraged. Hint: systemd-run -P env and systemd-run --user -P env print the effective system and user service environment blocks. diff --git a/src/systemctl/systemctl-set-environment.c b/src/systemctl/systemctl-set-environment.c index b68e6f6f66..3be2c57778 100644 --- a/src/systemctl/systemctl-set-environment.c +++ b/src/systemctl/systemctl-set-environment.c @@ -119,9 +119,9 @@ int import_environment(int argc, char *argv[], void *userdata) { return bus_log_create_error(r); if (argc < 2) { - _cleanup_strv_free_ char **copy = NULL; + log_warning("Calling import-environment without a list of variable names is deprecated."); - copy = strv_copy(environ); + _cleanup_strv_free_ char **copy = strv_copy(environ); if (!copy) return log_oom(); diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index 9a934badce..7fe1e4e65b 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -193,7 +193,7 @@ static int systemctl_help(void) { " show-environment Dump environment\n" " set-environment VARIABLE=VALUE... Set one or more environment variables\n" " unset-environment VARIABLE... Unset one or more environment variables\n" - " import-environment [VARIABLE...] Import all or some environment variables\n" + " import-environment VARIABLE... Import all or some environment variables\n" "\n%3$sManager State Commands:%4$s\n" " daemon-reload Reload systemd manager configuration\n" " daemon-reexec Reexecute systemd manager\n"