0

Full error message for sudo /usr/local/bin/tlmgr -gui (TeX Live 2017 manager) I'm getting on my OpenSUSE Tumbleweed with Gnome 3:

No protocol specified
perl/Tk unusable, cannot create main windows.
That could be a consequence of not having X Windows installed or started!
Error message from creating MainWindow:
  couldn't connect to display ":0" at /usr/lib/perl5/vendor_perl/5.24.1/x86_64-linux-thread-multi/Tk/MainWindow.pm line 53.
Tk::MainWindow->new() at /usr/local/bin/tlmgr line 4704.

No such error message when starting it without sudo (can't use it this way though since I installed it system-wide).

Same result if

Then I tried being clever and played around with the X authority file (got the idea from posts such as https://unix.stackexchange.com/a/8250):

ln -s /run/user/1000/gdm/Xauthority /root/.Xauthority

# inside sudo -i then
export XAUTHORITY=/root/.Xauthority

After that I'm getting the error message with the following first two lines (and the rest the same as previously):

Invalid MIT-MAGIC-COOKIE-1 keyperl/Tk unusable, cannot create main windows.
That could be a consequence of not having X Windows installed or started!

Output for xauth list:

linux-q1xc/unix:  MIT-MAGIC-COOKIE-1  fa445a3c038b19300e8e45d4ae0ae55a
#ffff#6c696e75782d71317863#:  MIT-MAGIC-COOKIE-1  fa445a3c038b19300e8e45d4ae0ae55a

For sudo xauth list:

linux-q1xc/unix:10  MIT-MAGIC-COOKIE-1  7e608058d97a6bf4ae346879f4f5fd46

For ssh -X localhost xauth list:

linux-q1xc/unix:10  MIT-MAGIC-COOKIE-1  faaf2ba1724d5efe85aa5ef6cb4fcc52

For ssh -X root@localhost xauth list:

linux-q1xc/unix:10  MIT-MAGIC-COOKIE-1  e8168ff05f56458663f187ec38f744fe

After sudo ln -sf ~/.Xauthority /root

Output for xauth list:

linux-q1xc/unix:  MIT-MAGIC-COOKIE-1  fa445a3c038b19300e8e45d4ae0ae55a
#ffff#6c696e75782d71317863#:  MIT-MAGIC-COOKIE-1  fa445a3c038b19300e8e45d4ae0ae55a

Output for sudo xauth list:

linux-q1xc/unix:10  MIT-MAGIC-COOKIE-1  faaf2ba1724d5efe85aa5ef6cb4fcc52

Error message is again the first one.

xauth list output inside su - or using sudo -E (both where it works):

linux-q1xc/unix:  MIT-MAGIC-COOKIE-1  fa445a3c038b19300e8e45d4ae0ae55a                                                                                                                        
#ffff#6c696e75782d71317863#:  MIT-MAGIC-COOKIE-1  fa445a3c038b19300e8e45d4ae0ae55a

(Same as the first one.)


Works with ssh -X localhost tlmgr -gui. Also works inside su - and using sudo -E.

What is the underlying issue and how can it be solved?

phk
  • 5,953
  • 7
  • 42
  • 71
  • Does it work with standard ssh X tunneling? – Mark Plotnick Jun 06 '17 at 12:56
  • @MarkPlotnick Interestingly enough, it does, even with root (and I just noticed that I have root login activated for my SSH server). – phk Jun 06 '17 at 12:59
  • What is the output of xauth list? – Satō Katsura Jun 06 '17 at 13:41
  • @SatoKatsura Added. – phk Jun 06 '17 at 13:45
  • Try ln -sf /home/your_user/.Xauthority /root/. After that xauth list and sudo xauth list should have the same output. – Satō Katsura Jun 06 '17 at 13:59
  • @SatoKatsura Interestingly enough it works inside su -, which as opposed to sudo -i has e.g. XAUTHLOCALHOSTNAME and DISPLAY set. Also XAUTHORITY is set to /root/.auth<RANDOM>. – phk Jun 06 '17 at 14:37
  • 1
    Lack of DISPLAY (or a -display option, if the command accepts it) would be a showstopper. The answer to this question https://unix.stackexchange.com/questions/203136/how-do-i-run-gui-applications-as-root-by-using-pkexec tells how to get pkexec to retain your DISPLAY variable. – Mark Plotnick Jun 06 '17 at 19:39

1 Answers1

0

As discussed in the comments the problem has to do with DISPLAY not being preserved with sudo, therefore using sudo -E is a possible solution.

phk
  • 5,953
  • 7
  • 42
  • 71