<html>
    <head>
      <base href="https://bugs.freedesktop.org/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Priority</th>
          <td>medium
          </td>
        </tr>

        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - systemd fails to close user sessions with nonexistent home (nobody)"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=83100">83100</a>
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>systemd-bugs@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>systemd fails to close user sessions with nonexistent home (nobody)
          </td>
        </tr>

        <tr>
          <th>QA Contact</th>
          <td>systemd-bugs@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>george@nsup.org
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>general
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>systemd
          </td>
        </tr></table>
      <p>
        <div>
        <pre>This was tested on Debian packaged version 208-6, and confirmed on version
214-6, but a careful look at the code from Git head seems to indicate it still
happens. Please forgive me if it is not.

If a session was opened for user nobody, or probably any user with a
nonexistent home directory:

|-1 /sbin/init
|-user.slice
| |-user-65534.slice
| | `-<a href="mailto:user@65534.service">user@65534.service</a>
| |   |-1353 /lib/systemd/systemd --user
| |   `-1354 (sd-pam)
| |-user-1000.slice

Aug 26 09:54:12 aimlin systemd[2719]: Failed at step CHDIR spawning /bin/kill:
No such file or directory
Aug 26 09:54:12 aimlin systemd[1353]: systemd-exit.service: main process
exited, code=exited, status=200/CHDIR
Aug 26 09:54:12 aimlin systemd[1353]: Failed to start Exit the Session.
Aug 26 09:54:12 aimlin systemd[1353]: Dependency failed for Exit the Session.
Aug 26 09:54:12 aimlin systemd[1353]: Unit systemd-exit.service entered failed
state.

That causes a 60-90 seconds timeout, making it seem shutdown is stuck.

The problem is that "step CHDIR" tries to chdir to the nonexistent home
directory, and considers the failure as fatal.

With vesion 208, the timeout happens at shutdown and makes it appear to be
stuck. With version 214, I believe that due to this commit the timeout happens
immediately, fully in background; the service still goes into "fail" state:
<a href="http://cgit.freedesktop.org/systemd/systemd/commit/?id=b58b227a53ee2b9feba8433a1558b51132ffb18b">http://cgit.freedesktop.org/systemd/systemd/commit/?id=b58b227a53ee2b9feba8433a1558b51132ffb18b</a>

I am surprised to see systemd trying to spawn /bin/kill instead of just killing
the processes directly, but there may be a valid reason for it that I did not
thought of.

Please see also the Debian bug report for a few more details:
<a href="https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=749268">https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=749268</a></pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the QA Contact for the bug.</li>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>