mirror of
https://github.com/systemd/systemd.git
synced 2025-03-28 02:50:16 +03:00
systemctl: warn when importing environment variables with control characters
I don't think it is useful to warn about about environemnt variables where the user explicitly configured some value. If they went through the effort of escaping the cc to include it in the setting (e.g. Environment="VAR=\efoo"), and we pass this through, there isn't anything to warn about. This also applies to 'systemctl set-environment', where the variable name and value are passed as arguments. The only case where the warning *might* be useful is where the user might be surprised by the value. This occurs when importing variables from the inherited environment, i.e. in 'systemctl import-environment'. In not convinced that this is useful, since the user better control their shell environment anyway. $ systemctl import-environment Calling import-environment without a list of variable names is deprecated. Environment variable $LESS_TERMCAP_mb contains control characters, importing anyway. Environment variable $LESS_TERMCAP_md contains control characters, importing anyway. Environment variable $LESS_TERMCAP_me contains control characters, importing anyway. Environment variable $LESS_TERMCAP_se contains control characters, importing anyway. Environment variable $LESS_TERMCAP_so contains control characters, importing anyway. Environment variable $LESS_TERMCAP_ue contains control characters, importing anyway. Environment variable $LESS_TERMCAP_us contains control characters, importing anyway. Environment variable $ZZZ contains control characters, importing anyway.
This commit is contained in:
parent
30927a2484
commit
e9155cd077
@ -127,6 +127,12 @@ int import_environment(int argc, char *argv[], void *userdata) {
|
||||
|
||||
strv_env_clean_with_callback(copy, invalid_callback, NULL);
|
||||
|
||||
char **e;
|
||||
STRV_FOREACH(e, copy)
|
||||
if (string_has_cc(*e, NULL))
|
||||
log_notice("Environment variable $%.*s contains control characters, importing anyway.",
|
||||
(int) strcspn(*e, "="), *e);
|
||||
|
||||
r = sd_bus_message_append_strv(m, copy);
|
||||
|
||||
} else {
|
||||
@ -148,6 +154,10 @@ int import_environment(int argc, char *argv[], void *userdata) {
|
||||
|
||||
eq = startswith(*b, *a);
|
||||
if (eq && *eq == '=') {
|
||||
if (string_has_cc(eq + 1, NULL))
|
||||
log_notice("Environment variable $%.*s contains control characters, importing anyway.",
|
||||
(int) (eq - *b), *b);
|
||||
|
||||
r = sd_bus_message_append(m, "s", *b);
|
||||
if (r < 0)
|
||||
return bus_log_create_error(r);
|
||||
|
Loading…
x
Reference in New Issue
Block a user