Skip to content

Commit 23deef8

Browse files
committed
Revert "core/execute: set HOME, USER also for root users"
This reverts commit 8b89628. This broke systemd#5246
1 parent 6f844e3 commit 23deef8

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

man/systemd.exec.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1705,7 +1705,9 @@
17051705
<term><varname>$SHELL</varname></term>
17061706

17071707
<listitem><para>User name (twice), home directory, and the
1708-
login shell. See
1708+
login shell. The variables are set for the units that have
1709+
<varname>User=</varname> set, which includes user
1710+
<command>systemd</command> instances. See
17091711
<citerefentry project='die-net'><refentrytitle>passwd</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
17101712
</para></listitem>
17111713
</varlistentry>

src/core/execute.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -815,10 +815,13 @@ static int get_fixed_user(const ExecContext *c, const char **user,
815815

816816
assert(c);
817817

818+
if (!c->user)
819+
return 0;
820+
818821
/* Note that we don't set $HOME or $SHELL if they are not particularly enlightening anyway
819822
* (i.e. are "/" or "/bin/nologin"). */
820823

821-
name = c->user ?: "root";
824+
name = c->user;
822825
r = get_user_creds_clean(&name, uid, gid, home, shell);
823826
if (r < 0)
824827
return r;

0 commit comments

Comments
 (0)