core/execute: always set $USER and introduce SetLoginEnvironment=
Before this commit, $USER, $HOME, $LOGNAME and $SHELL are only set when User= is set for the unit. For system service, this results in different behaviors depending on whether User=root is set. $USER always makes sense on its own, so let's set it unconditionally. Ideally $HOME should be set too, but it causes trouble when e.g. getty passes '-p' to login(1), which then doesn't override $HOME. $LOGNAME and $SHELL are more like "login environments", and are generally not suitable for system services. Therefore, a new option SetLoginEnvironment= is also added to control the latter three variables. Fixes #23438 Replaces #8227
This commit is contained in:
@@ -254,6 +254,8 @@ struct ExecContext {
|
||||
char *group;
|
||||
char **supplementary_groups;
|
||||
|
||||
int set_login_environment;
|
||||
|
||||
char *pam_name;
|
||||
|
||||
char *utmp_id;
|
||||
|
||||
Reference in New Issue
Block a user