summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Pitt <martinpitt@users.noreply.github.com>2017-02-05 22:31:02 +0100
committerGitHub <noreply@github.com>2017-02-05 22:31:02 +0100
commitd2697a95fede9d51f2cd9a6c9184cd3971973478 (patch)
tree422c473b98c80c7370e0a2bad94e544a2b705b1b
parentd20a328f97ae3709342f6176e6e54ee12e26f321 (diff)
parent6a93917df9c8c852387d71004ccb43b33da962cd (diff)
downloadsystemd-d2697a95fede9d51f2cd9a6c9184cd3971973478.tar.gz
Merge pull request #5223 from keszybz/root-workdir
Fix WorkDir=~ with empty User=
-rw-r--r--man/systemd.exec.xml4
-rw-r--r--src/core/execute.c10
2 files changed, 5 insertions, 9 deletions
diff --git a/man/systemd.exec.xml b/man/systemd.exec.xml
index 699f6e263f..8079b4b210 100644
--- a/man/systemd.exec.xml
+++ b/man/systemd.exec.xml
@@ -1694,9 +1694,7 @@
<term><varname>$SHELL</varname></term>
<listitem><para>User name (twice), home directory, and the
- login shell. The variables are set for the units that have
- <varname>User=</varname> set, which includes user
- <command>systemd</command> instances. See
+ login shell. See
<citerefentry project='die-net'><refentrytitle>passwd</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
</para></listitem>
</varlistentry>
diff --git a/src/core/execute.c b/src/core/execute.c
index 47cc4311c1..aa0ddb564e 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -815,13 +815,10 @@ static int get_fixed_user(const ExecContext *c, const char **user,
assert(c);
- if (!c->user)
- return 0;
-
/* Note that we don't set $HOME or $SHELL if they are not particularly enlightening anyway
* (i.e. are "/" or "/bin/nologin"). */
- name = c->user;
+ name = c->user ?: "root";
r = get_user_creds_clean(&name, uid, gid, home, shell);
if (r < 0)
return r;
@@ -2439,11 +2436,12 @@ static int exec_child(
}
if (context->utmp_id)
- utmp_put_init_process(context->utmp_id, getpid(), getsid(0), context->tty_path,
+ utmp_put_init_process(context->utmp_id, getpid(), getsid(0),
+ context->tty_path,
context->utmp_mode == EXEC_UTMP_INIT ? INIT_PROCESS :
context->utmp_mode == EXEC_UTMP_LOGIN ? LOGIN_PROCESS :
USER_PROCESS,
- username ? "root" : context->user);
+ username);
if (context->user) {
r = chown_terminal(STDIN_FILENO, uid);