<html>
    <head>
      <base href="https://bugs.freedesktop.org/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - systemd will change permission of /dev/null when using User=, ExecStop= with StandardInput=tty"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=85255">85255</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>systemd will change permission of /dev/null when using User=, ExecStop= with StandardInput=tty
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>systemd
          </td>
        </tr>

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

        <tr>
          <th>Hardware</th>
          <td>Other
          </td>
        </tr>

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

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

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

        <tr>
          <th>Priority</th>
          <td>medium
          </td>
        </tr>

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

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

        <tr>
          <th>Reporter</th>
          <td>bernat@luffy.cx
          </td>
        </tr>

        <tr>
          <th>QA Contact</th>
          <td>systemd-bugs@lists.freedesktop.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Hi!

With the following unit:

[Unit]
Description = XBMC Media Center
After = remote-fs.target
After = syslog.target

[Service]
User = xbmc
Group = xbmc
Type = simple
Restart = always
RestartSec = 15
ExecStart = /bin/sleep 3600
ExecStop = /bin/sleep 2
TTYPath = /dev/tty9
StandardInput = tty
StandardOutput = journal

[Install]
WantedBy = multi-user.target

On stop, systemd will change permissions of /dev/null to user xbmc:

crw--w---- 1 xbmc root 1, 3 Oct 19 12:57 /dev/null

systemd 215 (as in Debian Jessie)

Looking at the source code, I suppose the culprit could be exec_spawn()
function (called with ExitStop), checking context->user (true) and checking if
context->std_input is a terminal, which should not be the case for ExecStop
since only the ExecStart process will be leader of the terminal. I suppose
ExecStop stdin is linked to /dev/null.</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>