2

I'm new with dbus. I know how to logout current user from terminal using dbus messages dbus-send --session --type=method_call --print-reply --dest=org.gnome.SessionManager /org/gnome/SessionManager org.gnome.SessionManager.Logout uint32:1
It sends messages to SessionManager but currently I'm logged with user B, but switched account with user A(not I'm logged in as A). Now I have 2 session. My goal is to send Dbus messages and logout user B. When I'm typing

dbus-send --session \ --dest=org.freedesktop.DBus \ --type=method_call \ --print-reply \ /org/freedesktop/DBus \ org.freedesktop.DBus.ListNames

It only shows me 1 string "org.gnome.SessionManager" which is current users. Is it possible to use dbus messages and accomplish what I want?

  • You have to send the message to that user session bus so you'd need to su - to that user and use their respective DBUS_SESSION_BUS_ADDRESS and in theory it should work (with side effects maybe, like logging you out too - I'm not sure this would work OK). But why ? – don_crissti Jun 3 '16 at 11:49
  • So there is no way that I can get dbus address of other user? – user173408 Jun 3 '16 at 11:55
  • There are ways to do that, e.g. if the other user has a nautilus window open you could run as root sed -nz 's/DBUS_SESSION_BUS_ADDRESS=//p' /proc/$(pgrep -U 1001 nautilus)/environ (where 1001 is the UID) - basically you have to get it from /proc/$pid/environ where $pid is something unique to that user – don_crissti Jun 3 '16 at 11:58
  • I used id -u username return value but it gives me error sayig sed: can't read /proc//envir: No such file or directory. – user173408 Jun 3 '16 at 12:38
  • It's /proc/$pid/environ not envir and as I said you gotta get the pid of an app from that user session... whatever that is... – don_crissti Jun 3 '16 at 12:39
0

From the comments:

you can't send messages to another session bus unless you do it as that user and have that session bus address

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.