#975669 xpra.os_util.is_systemd_pid1() returns False on systemd

Package:
xpra
Source:
xpra
Description:
tool to detach/reattach running X programs
Submitter:
Sergio Gelato
Date:
2020-11-25 12:12:24 UTC
Severity:
normal
#975669#5
Date:
2020-11-24 20:47:33 UTC
From:
To:
(The same code is in upstream svn trunk.)

Consider this:

$ python
Python 2.7.16 (default, Oct 10 2019, 22:02:15)
[GCC 8.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
False
$ cat /proc/1/cmdline
/sbin/init$ ls -l /sbin/init
lrwxrwxrwx 1 root root 20 Apr 27  2020 /sbin/init -> /lib/systemd/systemd*

The test is confused by the symlink and returns a false negative.

I had been wondering why systemd-run wasn't being used even if I explicitly asked for it.

Fix with caution, as doing so may expose latent bugs.

#975669#10
Date:
2020-11-25 03:57:45 UTC
From:
To:
Thanks for report. However this version is obsolete and the problem is most
certainly fixed in newer release. I recommend to upgrade to version from
"buster-backports" as I hope it may have the fix already...
--- The end cannot justify the means for the simple and obvious reason that the means employed determine the nature of the ends produced. -- Aldous Huxley
--- And how long a lockdown is enough? If we open now, will lockdown recur in autumn? Next year? Whenever authoritarianism so wishes? No dictatorship could imagine a better precedent for absolute control. -- https://www.bmj.com/content/369/bmj.m1924.long :: BMJ 2020;369:m1924 "Should governments continue lockdown to slow the spread of covid-19?"
#975669#15
Date:
2020-11-25 12:03:25 UTC
From:
To:
control: found -1 3.0.4+dfsg1-1~bpo10+1

As I mentioned parenthetically in the original report, the same flawed
detection code is on upstream svn trunk. I've also checked that it is
still called from xpra/scripts/main.py in a relevant way. As far as I can
tell it affects all versions so far. I have explicitly checked 3.0.4:

$ python3
Python 3.7.3 (default, Jul 25 2020, 13:03:44)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
False
xpra v3.0.4-r24778

I now also have a suggested fix: read /proc/1/status and look for a line
matching ^Name:[[:space:]]+systemd$ (or whatever the proper regexp syntax is)
instead of /proc/1/cmdline which may read /sbin/init even on systemd.