Mailinglist Archive: opensuse-factory (498 mails)

< Previous Next >
Re: [opensuse-factory] Perl Net::DBus and org.freedesktop.login1
24.05.2016 21:57, Michael Hirmke пишет:
Hi *,

this is not a question specific to openSuSE or Tumbleweed, but here are
lots of experts, who nevertheless might help me - or point me in the
right direction - so I give it a try ;)

I'd like to write a script, which can listen to the PepareForSleep
signal from systemd-logind. When it catches the signal, it should do a
few things in the context of the user. While doing this, it should
inhibit the sleep process. It gets started as autostart script in KDE.
For this purpose I use perl and the module Net::DBus.
Actually I am able to connect to the bus, attach to the appropriate
signal and run something, when getting the signal.

But:
- I only can take delay locks. Whenever I try to take a *blocking* lock,
nothing happens, as if it is completely ignored. I don't get any
error message, though.
When using *delay* locks and the maximum inhibition time has been
exceeded, I get
"systemd-logind: Delay lock is active (UID <uid>/<user>, PID
<pid>/dbus_logind) but inhibitor timeout is reached."
So it seems to work in this case, but why not with blocking locks?

One possible reason is that blocking is privileged by default, so you
must be root or have working policykit infrastructure. Or you need to
explicitly allow those calls for your user without authentication (I
think it is possible in D-Bus).

- I am not able to close the file descriptor in the pre block of the
signal handler. Whenever I try, I get an error, that the descriptor
is closed.
When I try to take the lock again in the post block of the signal
handler, I get a second entry in the inhibitor list with the same
contents. After a few sleep/resume cycles the entries get more and
more.


My hunch is that you need to use different D-Bus connections for
listening to signals and for managing locks. You seem to be reusing it,
at least initially.

I suggest you ask this in systemd-devel, the question is just fine for
this list.

--
To unsubscribe, e-mail: opensuse-factory+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: opensuse-factory+owner@xxxxxxxxxxxx

< Previous Next >
Follow Ups
References