<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">
<p>Frank Steiner:</p>
<blockquote type="cite">
<p>[...] I see such messages:<br>
<blockquote type="cite">
<pre>About to execute: /bin/echo -e 'Welcome to emergency mode! After logging in, ...
Forked /bin/echo as 4290
Failed at step CHDIR spawning /bin/echo: No such file or directory
</pre>
</blockquote>
</p>
<p><br>
[...] But <code>/usr/lib/systemd/system/emergency.service</code>
contains: </p>
<blockquote type="cite">
<pre wrap="">[Service]
Environment=HOME=/root
WorkingDirectory=/root
...
ExecStartPre=-/bin/echo -e 'Welcome to emergency mode! After logging in, ...
ExecStart=-/bin/sh -c "/sbin/sulogin; /usr/bin/systemctl --fail --no-block default"
...
</pre>
</blockquote>
<p wrap=""><br>
[...] That was caused by <code>/root</code> being a symbolic
link to <code>/local/home/root</code> [...]<br>
</p>
</blockquote>
<p><br>
Andrei Borzenkov:</p>
</div>
<blockquote
cite="mid:CAA91j0UKyWXehcVB5mTSOAWRip9Xobbcn26hnMVSbVWEQWKCYQ@mail.gmail.com"
type="cite">
<p>
[...] So I would vote for changing it to <code>/</code> as
well.</p>
</blockquote>
<p><code><br>
/bin/echo</code> certainly doesn't care what its working
directory is.</p>
<p>When it comes to the later <code>ExecStart</code>, which hasn't
yet been reached in the scenario at hand, the convention is that
the "userinit" part of the procedure (i.e. the part that sets up
the environment variables like <code>HOME</code><code><cite> </cite></code>and
changes working directory) is the responsibility of the login
program. The <code>@SULOGIN@</code> that is Miquel van
Smoorenburg's <code>sulogin</code> (as exemplified above) is no
exception to this.</p>
<p>It <i>itself</i> reads the home directory out of the password
database, and changes directory to it and sets the <code>HOME</code>
environment variable to it; without need for the invoking systemd
unit to do so, and with less drastic failure modes in the absence
of root's home directory or when the system administrator has
decided that it isn't <code>/root</code>. Witness:</p>
<blockquote type="cite">
<pre style="color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"> if (chdir(pwd->pw_dir) < 0) {
if (chdir("/") < 0)
fprintf(stderr, "sulogin: change of working directory failed: %m\n\r");
}</pre>
</blockquote>
</body>
</html>