Make getting the environment from gnome-session more robust
readlink() on /proc/<pid>/exe can have results like: /usr/bin/gnome-keyring-daemon.#prelink#.5DFZsF (deleted) /usr/bin/gnome-session (deleted) To find gnome-session in a more robust way, read /proc/<pid>/cmdline instead. https://bugzilla.gnome.org/show_bug.cgi?id=616706
This commit is contained in:
parent
3bd2f75866
commit
c4406d4ace
@ -37,10 +37,15 @@ def get_running_session_environs():
|
|||||||
if not stat.st_uid == myuid:
|
if not stat.st_uid == myuid:
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
exe = os.readlink(piddir + '/exe')
|
f = open(piddir + "/cmdline")
|
||||||
except OSError, e:
|
command = f.read()
|
||||||
|
f.close()
|
||||||
|
except IOError, e:
|
||||||
continue
|
continue
|
||||||
if os.path.basename(exe) != 'gnome-session':
|
# /proc/cmdline is separated and terminated by NULs
|
||||||
|
command = command.split("\x00")[0]
|
||||||
|
command = os.path.basename(command)
|
||||||
|
if command != 'gnome-session':
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
f = open(os.path.join(piddir, 'environ'))
|
f = open(os.path.join(piddir, 'environ'))
|
||||||
|
Loading…
Reference in New Issue
Block a user