Sunday, May 5, 2024
3
rated 0 times [  3] [ 0]  / answers: 1 / hits: 18920  / 3 Years ago, thu, july 15, 2021, 10:34:23

If I switch user in a terminal.



su bob



I can't open gedit because bob doesn't own the display.



If I execute



xhost +



before switching to bob I can open the display for some applications but not all. I get the following output when trying to execute gedit:




(crashreporter:4415): GnomeUI-WARNING
*: While connecting to session manager: None of the authentication
protocols specified are supported.

*
GLib-GIO:ERROR:/build/buildd/glib2.0-2.28.6/./gio/gdbusconnection.c:2279:initable_init:
assertion failed:
(connection->initialization_error ==
NULL)



More From » command-line

 Answers
0

If you want to allow user bob to access your existing X session from
the command line, you can enter these commands at the terminal prompt:



xauth nextract - $DISPLAY | sudo -u bob xauth nmerge -


Thius uses the xauth command to
extract the authentication information for the current user (first
part of the command, before the |) and then merge it into user
bob's $HOME/.Xauthority file. Note that it requires
/etc/sudoers to be configured so that you are allowed to run
commands as user bob (this is the default if you're the admin user
on a Ubuntu box).



You can then switch to user bob with su -l.



Alternatively, you can issue these separate commands:



xauth nextract - $DISPLAY > /tmp/xauth.temporary.file
su -l bob -c 'xauth nmerge - < /tmp/xauth.temporary.file'
rm /tmp/xauth.temporary.file


Note that:



1) the temporary file must have permissions such that user bob can
read it (which often means that any user on the system can read
it);



2) there is a time window during which any user that can read the
temporary file can get access to your X display.



Therefore, it is better to use the sudo approach as it does not have
these downsides.


[#44418] Saturday, July 17, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
eballxeye

Total Points: 370
Total Questions: 91
Total Answers: 139

Location: Suriname
Member since Sat, Jan 1, 2022
2 Years ago
;