mirror of
https://github.com/systemd/systemd.git
synced 2024-10-26 08:55:40 +03:00
exec-invoke: properly look up home dir for user
Previously get_home_dir was used in acquire_home; this provides the home directory of the current user. However, in this case, that is the user running the service manager, not the user which will be running the unit. The issue was masked because get_home_dir would not be reached most of the time; acquire_home returns early if home was already acquired from get_fixed_user. However, this may not happen if, for example, the user in question's home directory is root, since that will be suppressed to NULL.
This commit is contained in:
parent
8234db8bfe
commit
c67b7f4960
@ -3579,7 +3579,7 @@ static int send_user_lookup(
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int acquire_home(const ExecContext *c, const char **home, char **ret_buf) {
|
||||
static int acquire_home(const ExecContext *c, const char **home, uid_t uid, char **ret_buf) {
|
||||
int r;
|
||||
|
||||
assert(c);
|
||||
@ -3597,7 +3597,7 @@ static int acquire_home(const ExecContext *c, const char **home, char **ret_buf)
|
||||
if (c->dynamic_user)
|
||||
return -EADDRNOTAVAIL;
|
||||
|
||||
r = get_home_dir(ret_buf);
|
||||
r = get_home_dir_for_uid(uid, ret_buf);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@ -4331,7 +4331,7 @@ int exec_invoke(
|
||||
|
||||
params->user_lookup_fd = safe_close(params->user_lookup_fd);
|
||||
|
||||
r = acquire_home(context, &home, &home_buffer);
|
||||
r = acquire_home(context, &home, uid, &home_buffer);
|
||||
if (r < 0) {
|
||||
*exit_status = EXIT_CHDIR;
|
||||
return log_exec_error_errno(context, params, r, "Failed to determine $HOME for user: %m");
|
||||
|
Loading…
Reference in New Issue
Block a user