<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 --- - shutdown-inhibitor from user session is ignored when calling org.freedesktop.login1.Manager.Suspend or org.freedesktop.login1.Manager.PowerOff"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=66321">66321</a>
          </td>
        </tr>

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

        <tr>
          <th>Summary</th>
          <td>shutdown-inhibitor from user session is ignored when calling org.freedesktop.login1.Manager.Suspend or org.freedesktop.login1.Manager.PowerOff
          </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>Linux (All)
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>alexander.grothe@gmail.com
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>x86-64 (AMD64)
          </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>Hello,
I am running Arch Linux with systemd-204
(<a href="https://projects.archlinux.org/svntogit/packages.git/tree/trunk?h=packages/systemd&id=770b03b35a8c53b5d5e23738ae66138856aebf3e">https://projects.archlinux.org/svntogit/packages.git/tree/trunk?h=packages/systemd&id=770b03b35a8c53b5d5e23738ae66138856aebf3e</a>)
and a gnome-session started by gdm (version 3.8.3).

I am trying to use a shutdown-inhibitor which reliably blocks a shutdown or
suspend if a script running in the background within the session is busy.

So I set up a "block" mode inhibitor from a terminal:
$ systemd-inhibit --who=test vim
It showed up correctly:
$ systemd-inhibit --list
[...]
     Who: test (UID 1000/alexander, PID 547/systemd-inhibit)
    What: shutdown:sleep:idle
     Why: Unknown reason
    Mode: block

systemctl itself respects this inhibitor:
$ systemctl poweroff
Operation inhibited by "test" (PID 547 "systemd-inhibit", user alexander),
reason is "Unknown reason".
Please retry operation after closing inhibitors and logging out other users.
Alternatively, ignore inhibitors and users with 'systemctl poweroff -i'.

But when calling login1 directly, the system is shut down without further
notice or authorization request(for example XBMC uses a dbus command like
this):
$ dbus-send --system --print-reply --dest=org.freedesktop.login1
/org/freedesktop/login1 org.freedesktop.login1.Manager.PowerOff boolean:false

If the inhibitor is set by root, both "systemctl poweroff" and a dbus-request
show the expected behavior:
# systemd-inhibit --who="test as root" vim
$ systemctl poweroff
Operation inhibited by "test as root" (PID 564 "systemd-inhibit", user root),
reason is "Unknown reason".
Please retry operation after closing inhibitors and logging out other users.
Alternatively, ignore inhibitors and users with 'systemctl poweroff -i'.
$ dbus-send --system --print-reply --dest=org.freedesktop.login1
/org/freedesktop/login1 org.freedesktop.login1.Manager.PowerOff boolean:false
Error org.freedesktop.DBus.Error.AccessDenied: Operation not permitted

I is possible that all inhibitor are reliably taken into account for
org.freedesktop.login1.Manager.* calls, regardless of the owner?</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>