linuxmint / cinnamon-session

The Cinnamon session manager
GNU General Public License v2.0
27 stars 36 forks source link

Logout not working as expected #142

Open dafanasiev opened 3 years ago

dafanasiev commented 3 years ago
 * cinnamon-session 4.8.0
 * Linux Mint 20.1 Ulyssa (clean install)
 * VGA compatible controller: Intel Corporation UHD Graphics 605 (rev 06)
 * 64 bit
 * Linux pc 5.4.0-70-generic #78-Ubuntu SMP Fri Mar 19 13:29:52 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Steps to reproduce My PC used by two users. After user1 logout and user2 login I can see some processes from user1.

# execute in user2 session:
$> sudo loginctl list-sessions 
SESSION  UID USER  SEAT  TTY
     c1 1001 user1   seat0    
     c3 1000 user2 seat0    

$> sudo loginctl session-status c1
c1 - user1 (1001)
           Since: Fri 2021-04-19:26:51 MSK; 1min 19s ago
          Leader: 827
            Seat: seat0; vc7
         Display: :0
         Service: lightdm-autologin; type x11; class user
         Desktop: cinnamon
           State: closing
            Unit: session-c1.scope
                  └─1185 /usr/libexec/geoclue-2.0/demos/agent

19:26:51 pc systemd[1]: Started Session c1 of user user1.
19:26:52 pc gnome-keyring-daemon[964]: couldn't access control socket: /run/user/1001/keyring/control: Нет такого файла или каталога
19:26:52 pc gnome-keyring-daemon[965]: couldn't access control socket: /run/user/1001/keyring/control: Нет такого файла или каталога
19:26:52 pc gnome-keyring-daemon[970]: couldn't access control socket: /run/user/1001/keyring/control: Нет такого файла или каталога
19:26:54 pc /cinnamon-killer-daemon[1184]: Bound Cinnamon restart to <Control><Alt>Escape.
19:27:00 pc cinnamon-session[842]: WARNING: t+7,88705s: Detected that screensaver has appeared on the bus
19:27:07 pc cinnamon-session[842]: WARNING: t+15,00500s: Playing logout sound '/usr/share/mint-artwork/sounds/logout.ogg'
19:27:07 pc cinnamon-session[842]: WARNING: t+15,08185s: Finished playing logout sound
19:27:07 pc cinnamon-session[842]: WARNING: t+15,08201s: Resuming logout sequence...
19:27:08 pc lightdm[827]: pam_unix(lightdm-autologin:session): session closed for user user1

I see process 1185 /usr/libexec/geoclue-2.0/demos/agent:

$> sudo ps -aux |grep user1
user1          832  0.0  0.1  18680 10100 ?        Ss   19:26   0:00 /lib/systemd/systemd --user
user1          833  0.0  0.0 171044  3640 ?        S    19:26   0:00 (sd-pam)
user1          864  0.0  0.0   7948  5160 ?        Ss   19:26   0:00 /usr/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
user1          934  0.0  0.1 239956  8020 ?        Ssl  19:26   0:00 /usr/libexec/gvfsd
user1          939  0.0  0.0 378336  5572 ?        Sl   19:26   0:00 /usr/libexec/gvfsd-fuse /run/user/1001/gvfs -f -o big_writes
user1         1044  0.0  0.0 156224  5400 ?        Sl   19:26   0:00 /usr/libexec/dconf-service
user1         1107  0.0  0.1 314488  9104 ?        Ssl  19:26   0:00 /usr/libexec/gvfs-udisks2-volume-monitor
user1         1117  0.0  0.0 235912  5796 ?        Ssl  19:26   0:00 /usr/libexec/gvfs-mtp-volume-monitor
user1         1121  0.0  0.0 238324  6612 ?        Ssl  19:26   0:00 /usr/libexec/gvfs-gphoto2-volume-monitor
user1         1131  0.0  0.0 236116  6308 ?        Ssl  19:26   0:00 /usr/libexec/gvfs-goa-volume-monitor
user1         1136  0.0  0.4 546684 36740 ?        Sl   19:26   0:00 /usr/libexec/goa-daemon
user1         1146  0.0  0.1 315160  9244 ?        Sl   19:26   0:00 /usr/libexec/goa-identity-service
user1         1148  0.0  0.1 316968  9028 ?        Ssl  19:26   0:00 /usr/libexec/gvfs-afc-volume-monitor
user1         1185  0.0  0.0 237092  4860 ?        Sl   19:26   0:00 /usr/libexec/geoclue-2.0/demos/agent
user1         1207  0.0  0.3 390904 25844 ?        Ssl  19:26   0:00 /usr/libexec/evolution-source-registry
user1         1213  0.0  0.3 1298072 31456 ?       Ssl  19:26   0:00 /usr/libexec/evolution-calendar-factory
user1         1224  0.0  0.3 673824 30276 ?        Ssl  19:26   0:00 /usr/libexec/evolution-addressbook-factory
user1         1342  0.0  0.1 314128  8636 ?        Sl   19:26   0:00 /usr/libexec/gvfsd-trash --spawner :1.8 /org/gtk/gvfs/exec_spaw/0
user1         1352  0.0  0.0 162492  6620 ?        Ssl  19:26   0:00 /usr/libexec/gvfsd-metadata

but cant see it in tree:

$>sudo pstree -p -s user1
agent(1185)─┬─{agent}(1187)
            └─{agent}(1190)

systemd(832)─┬─(sd-pam)(833)
             ├─dbus-daemon(864)
             ├─dconf-service(1044)─┬─{dconf-service}(1046)
             │                     └─{dconf-service}(1047)
             ├─evolution-addre(1224)─┬─{evolution-addre}(1232)
             │                       ├─{evolution-addre}(1234)
             │                       ├─{evolution-addre}(1236)
             │                       ├─{evolution-addre}(1237)
             │                       └─{evolution-addre}(1239)
             ├─evolution-calen(1213)─┬─{evolution-calen}(1214)
             │                       ├─{evolution-calen}(1215)
             │                       ├─{evolution-calen}(1216)
             │                       ├─{evolution-calen}(1217)
             │                       ├─{evolution-calen}(1222)
             │                       └─{evolution-calen}(1223)
             ├─evolution-sourc(1207)─┬─{evolution-sourc}(1208)
             │                       ├─{evolution-sourc}(1209)
             │                       └─{evolution-sourc}(1210)
             ├─goa-daemon(1136)─┬─{goa-daemon}(1140)
             │                  ├─{goa-daemon}(1142)
             │                  └─{goa-daemon}(1143)
             ├─goa-identity-se(1146)─┬─{goa-identity-se}(1149)
             │                       └─{goa-identity-se}(1151)
             ├─gvfs-afc-volume(1148)─┬─{gvfs-afc-volume}(1152)
             │                       ├─{gvfs-afc-volume}(1153)
             │                       └─{gvfs-afc-volume}(1155)
             ├─gvfs-goa-volume(1131)─┬─{gvfs-goa-volume}(1133)
             │                       └─{gvfs-goa-volume}(1134)
             ├─gvfs-gphoto2-vo(1121)─┬─{gvfs-gphoto2-vo}(1126)
             │                       └─{gvfs-gphoto2-vo}(1130)
             ├─gvfs-mtp-volume(1117)─┬─{gvfs-mtp-volume}(1118)
             │                       └─{gvfs-mtp-volume}(1120)
             ├─gvfs-udisks2-vo(1107)─┬─{gvfs-udisks2-vo}(1113)
             │                       ├─{gvfs-udisks2-vo}(1114)
             │                       └─{gvfs-udisks2-vo}(1115)
             ├─gvfsd(934)─┬─gvfsd-trash(1342)─┬─{gvfsd-trash}(1343)
             │            │                   └─{gvfsd-trash}(1344)
             │            ├─{gvfsd}(935)
             │            └─{gvfsd}(936)
             ├─gvfsd-fuse(939)─┬─{gvfsd-fuse}(941)
             │                 ├─{gvfsd-fuse}(942)
             │                 ├─{gvfsd-fuse}(943)
             │                 ├─{gvfsd-fuse}(944)
             │                 └─{gvfsd-fuse}(946)
             └─gvfsd-metadata(1352)─┬─{gvfsd-metadata}(1353)
                                    └─{gvfsd-metadata}(1354)

ok, I try to find parent:

#  ppid as the 4th parameter of /proc/pid/stat
$> cat /proc/1185/stat
1185 (agent) S 1 842 842 0 -1 4194304 342 0 2 0 0 0 0 0 20 0 3 0 1001 242782208 1215 18446744073709551615 93863577436160 93863577470165 140730787656192 0 0 0 0 4096 0 0 0 0 17 2 0 0 0 0 0 93863577486800 93863577489536 93863591579648 140730787662226 140730787662263 140730787662263 140730787663827 0

#parentpid = 1
$> ps -p 1185 -o ppid=
      1

But I cant understood why systemd run this process (can anyone help?).

After I kill process 1185 (kill -9 1185) session for user1 and all other user1 processes (that listed above) gone away.

I not sure that this is bug in cinnamon-session.

Expected behaviour

Session for user must be closed when user logout.

Additinal info

gdb 1185

$> sudo gdb --pid=1185 /usr/libexec/geoclue-2.0/demos/agent
Reading symbols from /usr/libexec/geoclue-2.0/demos/agent...
(No debugging symbols found in /usr/libexec/geoclue-2.0/demos/agent)
Attaching to program: /usr/libexec/geoclue-2.0/demos/agent, process 1185
[New LWP 1187]
[New LWP 1190]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
0x00007efd2839aaff in __GI___poll (fds=0x555e520a7ce0, nfds=1, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
29  ../sysdeps/unix/sysv/linux/poll.c: No such file or directory.
(gdb) thread apply all where

Thread 3 (Thread 0x7efd26910700 (LWP 1190)):
#0  0x00007efd2839aaff in __GI___poll (fds=0x7efd18011740, nfds=2, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
#1  0x00007efd2871536e in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#2  0x00007efd287156f3 in g_main_loop_run () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#3  0x00007efd28600f8a in ?? () from /lib/x86_64-linux-gnu/libgio-2.0.so.0
#4  0x00007efd2873ead1 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#5  0x00007efd281f6609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#6  0x00007efd283a7293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 2 (Thread 0x7efd2793b700 (LWP 1187)):
#0  0x00007efd2839aaff in __GI___poll (fds=0x555e52097130, nfds=1, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
#1  0x00007efd2871536e in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#2  0x00007efd287154a3 in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#3  0x00007efd287154f1 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#4  0x00007efd2873ead1 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#5  0x00007efd281f6609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#6  0x00007efd283a7293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 1 (Thread 0x7efd27eaef00 (LWP 1185)):
#0  0x00007efd2839aaff in __GI___poll (fds=0x555e520a7ce0, nfds=1, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
#1  0x00007efd2871536e in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#2  0x00007efd287156f3 in g_main_loop_run () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#3  0x0000555e51311579 in ?? ()
#4  0x00007efd282ac0b3 in __libc_start_main (main=0x555e51311470, argc=1, argv=0x7ffe709b7208, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7ffe709b71f8) at ../csu/libc-start.c:308
#5  0x0000555e5131162e in ?? ()
leigh123linux commented 3 years ago

It's systemd/logind job to clean up not cinnamon-session.

Maybe this Pr would help. https://github.com/linuxmint/cinnamon-session/pull/141

dafanasiev commented 3 years ago

@leigh123linux hmm.. I try to recompile cinnamon-session from master branch with apply patch from #141 (in docker container):

git clone https://github.com/linuxmint/cinnamon-session.git
cd cinnamon-session
wget https://github.com/linuxmint/cinnamon-session/pull/141.patch -O /tmp/141.patch
git am /tmp/141.patch
docker run -it --rm -v $PWD:/app -w /app linuxmintd/mint20.1-amd64 /bin/bash

#inside docker
$> apt update && apt upgrade && mint-build && exit

#in host:
sudo mv /usr/bin/cinnamon-session /usr/bin/cinnamon-session.bak
sudo cp ./debian/cinnamon-session/usr/bin/cinnamon-session /usr/bin/cinnamon-session
reboot

## do logout(user1)-login(user2) steps

But I see the same picture in processes.

Do you have any other ideas other than "apt remove gnome-calendar geoclue-2.0" ?

leigh123linux commented 3 years ago

Try editing /etc/systemd/logind.conf and uncomment / change

#KillUserProcesses=no

to

KillUserProcesses=yes

https://www.freedesktop.org/software/systemd/man/logind.conf.d.html

leigh123linux commented 3 years ago

I found this https://bugs.launchpad.net/ubuntu/+source/geoclue-2.0/+bug/1871728

You could edit /etc/xdg/autostart/geoclue-demo-agent.desktop

NotShowIn=GNOME;

And add X-Cinnamon

NotShowIn=GNOME;X-Cinnamon;

dafanasiev commented 3 years ago

@leigh123linux ok, I think that KillUserProcesses=yes will work, but this is bad option.

About editing /etc/xdg/autostart/geoclue-demo-agent.desktop.

I install fresh (and clean) linux mint cinnamon edition 20.1 into VM and apply geoclue-demo-agent.desktop "patch". Yes, now geclue-demo agent wont start. But there is the similar problem, now with "printer applet":

Steps

  1. login as user1, wait some time (while printer applet starts).
  2. logout
  3. login as user2
    
    user2@user1-vm:~$ sudo loginctl list-sessions 
    SESSION  UID USER  SEAT  TTY
     c2 1000 user1 seat0    
     c4 1001 user2 seat0    

2 sessions listed. user2@user1-vm:~$ sudo loginctl session-status c2 c2 - user1 (1000) Since: Sun 2021-04-11 09:22:10 MSK; 1min 33s ago Leader: 981 Seat: seat0; vc7 Display: :0 Service: lightdm; type x11; class user Desktop: cinnamon State: closing Unit: session-c2.scope └─1629 /usr/bin/python3 /usr/share/system-config-printer/applet.py


"applet.py(1629)" in processes without "parent":
```sh
user2@user1-vm:~$ sudo pstree -p -s user1
applet.py(1629)

systemd(995)─┬─(sd-pam)(996)
             ├─dbus-daemon(1013)
             ├─dconf-service(1256)─┬─{dconf-service}(1257)
             │                     └─{dconf-service}(1274)
             ├─evolution-addre(1498)─┬─{evolution-addre}(1504)
             │                       ├─{evolution-addre}(1506)
             │                       ├─{evolution-addre}(1512)
             │                       ├─{evolution-addre}(1513)
             │                       └─{evolution-addre}(1517)
             ├─evolution-calen(1489)─┬─{evolution-calen}(1490)
             │                       ├─{evolution-calen}(1491)
             │                       ├─{evolution-calen}(1492)
             │                       ├─{evolution-calen}(1493)
             │                       ├─{evolution-calen}(1496)
             │                       └─{evolution-calen}(1497)
             ├─evolution-sourc(1452)─┬─{evolution-sourc}(1462)
             │                       ├─{evolution-sourc}(1467)
             │                       └─{evolution-sourc}(1472)
             ├─goa-daemon(1333)─┬─{goa-daemon}(1338)
             │                  ├─{goa-daemon}(1340)
             │                  └─{goa-daemon}(1343)
             ├─goa-identity-se(1346)─┬─{goa-identity-se}(1347)
             │                       └─{goa-identity-se}(1349)
             ├─gvfs-afc-volume(1310)─┬─{gvfs-afc-volume}(1321)
             │                       ├─{gvfs-afc-volume}(1322)
             │                       └─{gvfs-afc-volume}(1324)
             ├─gvfs-goa-volume(1329)─┬─{gvfs-goa-volume}(1330)
             │                       └─{gvfs-goa-volume}(1331)
             ├─gvfs-gphoto2-vo(1325)─┬─{gvfs-gphoto2-vo}(1326)
             │                       └─{gvfs-gphoto2-vo}(1328)
             ├─gvfs-mtp-volume(1297)─┬─{gvfs-mtp-volume}(1303)
             │                       └─{gvfs-mtp-volume}(1306)
             ├─gvfs-udisks2-vo(1269)─┬─{gvfs-udisks2-vo}(1282)
             │                       ├─{gvfs-udisks2-vo}(1285)
             │                       └─{gvfs-udisks2-vo}(1294)
             ├─gvfsd(1021)─┬─gvfsd-trash(1522)─┬─{gvfsd-trash}(1523)
             │             │                   └─{gvfsd-trash}(1524)
             │             ├─{gvfsd}(1023)
             │             └─{gvfsd}(1024)
             ├─gvfsd-fuse(1027)─┬─{gvfsd-fuse}(1031)
             │                  ├─{gvfsd-fuse}(1032)
             │                  ├─{gvfsd-fuse}(1033)
             │                  ├─{gvfsd-fuse}(1034)
             │                  └─{gvfsd-fuse}(1041)
             ├─gvfsd-metadata(1530)─┬─{gvfsd-metadata}(1531)
             │                      └─{gvfsd-metadata}(1532)
             └─obexd(1485)

After kill "printer applet":

user2@user1-vm:~$ sudo kill -9 1629
user2@user1-vm:~$ sudo loginctl list-sessions 
SESSION  UID USER  SEAT  TTY
     c4 1001 user2 seat0    

1 sessions listed.

UPD: as I see this applet starts by cinnamon-session.

leigh123linux commented 3 years ago

@leigh123linux ok, I think that KillUserProcesses=yes will work, but this is bad option.

Why do you consider it bad to ensure logind cleans up it own mess? TBH the guy from the bug report I linked who claims it to be the nuclear option is totally clueless and doesn't understand logind role.

dafanasiev commented 3 years ago

@leigh123linux yes, KillUserProcesses=yes works as expected.