Need: quick switch between pairs of users.
On a system there is a pair of user accounts that are somehow equivalent.
More concretely, for a given pair:
- Both account are regular Unix accounts, they just happened to be used by the same physical user (person).
- The same person has nearly always two graphical X sessions opened, one for each user account, but only needs to see one at a time on the screen.
- These are completely separate accounts with different mail configurations, browser histories, files, with different levels of security.
- Nothing is shared between the accounts, there would be no point in mixing those accounts on same X session (even a copy-paste between those would be useless).
- Yet the user needs to switch between them many times a day.
- It is easy to put a button that calls
dm-tool switch-to-user
but practically the user then has to re-authenticate on every switch and that is a productivity loss.
The need is to allow quick switch between the two graphical X sessions (e.g. at the click on a button on a panel) without having to reauthenticate.
System info and security implication (relaxing local security should be okay)
- System is Xubuntu 16.04 Xenial.
- X seats, login, locking, switching is done by lightdm out-of-the-box.
I am aware that relaxing security between pair of users while keeping other operations secure is more complicated than the usual lock-and-switch approach. Fortunately, in our case it's okay if some local security is lost since the machine is in controlled premises. For example, if a solution to the need causes some scenario that would normally automatically lock session (like suspend+resume) to no longer lock, for this pair of users, or even every user on the system, it may be acceptable.
Still, it's good if the user can manually lock the session.
Also, remote security must be preserved (for example SSH access to those accounts must not be affected by a solution to this problem).
Search before you post
Approach 1: use lightdm tools but adjust somehow
Basically, use dm-tool switch-to-user *username*
and arrange for the user's session to not get locked.
Worked in 12.04
In Ubuntu 12.04 we disabled light-locker to prevent session locking, plus set an icon on each user's desktop that ran this command:
dbus-send --system --type=method_call --print-reply --dest=org.freedesktop.DisplayManager $XDG_SEAT_PATH org.freedesktop.DisplayManager.Seat.SwitchToUser string:$CALLEDUSERNAME string:somesessionname
This worked: session switched to the user mentioned as $CALLEDUSERNAME
.
Fails in 16.04
This is unsatisfactory on 16.04: it switches to a greeter with $CALLEDUSERNAME
pre-selected but authentication is still needed. So, basically the result is the same as dm-tool switch-to-user *username*
. I haven't checked fully but probably it's just going exactly the same code paths as what dm-tool
causes.
More search
Looked for hints in Bug #1205384 “Lock can be circumvented by switching to console” : Bugs : lxsession package : Ubuntu, nothing concretely working.
I've looked at dm-tool
source code at http://archive.ubuntu.com/ubuntu/pool/main/l/lightdm/lightdm_1.18.1-0ubuntu1.tar.gz (from link on Ubuntu – Details of package lightdm in xenial).
Principle looks like this:
dm-tool
executable calls dbus to send message tolightdm
.lightdm
receives dbus event inhandle_seat_call()
, callsseat_switch_to_user()
seat_switch_to_user()
callsg_signal_connect (session, SESSION_SIGNAL_AUTHENTICATION_COMPLETE, G_CALLBACK (switch_authentication_complete_cb), seat);
to register callbackswitch_authentication_complete_cb()
.seat_switch_to_user()
then callssession_start()
which apparently creates a whole new X session to get authentication (not sure about the details, perhaps runssession_child_run()
which calls PAM)switch_authentication_complete_cb()
then switches to existing session or create new one
Next step
Can we somehow instruct PAM to just allow without prompting in this case, but without that change disturbing any other case? Ideally PAM behavior would change only in the switch-user case, not in the login case or the unlock case. Maybe the extra X session would still be started but not waiting for the user to type a password.
Approach 2: just figure out the VT number and use chvt
- Get at any time which VT corresponds to target user (perhaps because at login time, a script would read XDG_SEAT_PATH to get seat number, join with
Xorg
command line which tells the corresponding vt number and write the result into a conventional place). When needing to switch to user, get the vt number and use
chvt
. Probably some sudo config will be needed.Advantage: simpler, no mess with
lightdm
, PAM or whatever, not even an explicit dependency onlightdm
so might work elsewhere.- Drawback: hackish way to figure out the join between user and VT number?
Conclusion, retell question
- Any comment about the first approach (via
dm-tool
, PAM adjust)? - Any comment about the second approach (via
chvt
)?
Thank you for your attention.
XDG_VTNR
environment variable which directly tell VT number without joining to Xorg command line. Yet those variables are not known outside. Users could run a script that advertises these. Switch would use chvt and therefore probably need a sudo config. – Stéphane Gourichon Aug 15 '16 at 05:19