[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi] vim as root: "No protocol specified"
From: |
Greg Chicares |
Subject: |
[lmi] vim as root: "No protocol specified" |
Date: |
Tue, 1 Oct 2019 16:57:15 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 |
Vadim--Now that I'm using the wayland compositor, whenever I edit
a file as root, I see a "No protocol specified" message on the
screen when vim exits:
#vim /srv/chroot/centos-7/tmp/setup0.sh
No protocol specified
It seems to work fine, except that I can't access the X clipboard.
BTW, I'm using the gtk version of vim, not gvim:
$ls -l /usr/bin/vim
lrwxrwxrwx 1 root root 21 Sep 11 19:43 /usr/bin/vim -> /etc/alternatives/vim
$ls -l /etc/alternatives/vim
lrwxrwxrwx 1 root root 16 Sep 11 19:43 /etc/alternatives/vim -> /usr/bin/vim.gtk
...and:
#printf 'DISPLAY is "%s", and EDITOR is "%s"\n' $DISPLAY $EDITOR
DISPLAY is ":0.0", and EDITOR is ""
I suspect that this is due to wayland, because:
https://wiki.archlinux.org/index.php/Running_GUI_applications_as_root#Wayland
Arch suggests sudoedit, but that doesn't seem to work for me:
#sudoedit /srv/chroot/centos-7/tmp/setup0.sh
[:ls inside vim shows this:]
:ls
1 %a "/var/tmp/setup0XXm7c4EV.sh" line 1
[upon exit I see:]
No protocol specified
sudoedit: /srv/chroot/centos-7/tmp/setup0.sh unchanged
I can prevent the warning message from displaying with 'vim -X':
https://groups.google.com/forum/#!topic/vim_use/_KPOcTgfnOg
I haven't tried advice like this:
https://unix.stackexchange.com/questions/8249/no-protocol-specified-when-running-vim-with-sudo
| #do this for all other users who do not have .Xauthority file
| ln -s /home/userwithxauth/.Xauthority .Xauthority
|
| #run the following command to give read only access permission to .Xauthority
file
| chmod 644 /home/userwithxauth/.Xauthority
because, AIUI, that would give root open access to X, which
seems like a security issue. Is there a tidy way to grant X
access only when I invoke vim as root? The best I can come
up with is this:
XAUTHORITY=/home/greg/.Xauthority vim /srv/chroot/centos-7/tmp/setup0.sh
from which I could create an alias in a shell startup file
(on my own computer, I'm sure 'greg' is a normal X user).
Is that good, or am I missing a simpler approach?
- [lmi] vim as root: "No protocol specified",
Greg Chicares <=