Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tigervncserver crashes unless started with sudo

I've installed the following pkgs:

ii  tigervnc-common                          1.10.1+dfsg-1                        amd64        Virtual network computing; Common software needed >
ii  tigervnc-standalone-server               1.10.1+dfsg-1                        amd64        Standalone virtual network computing server
ii  tigervnc-viewer                          1.10.1+dfsg-1                        amd64        Virtual network computing client for X
ii  tigervnc-xorg-extension                  1.10.1+dfsg-1                        amd64        Virtual network computing X server extension

I've run vncserver and configured a passwd and added no additional configurations.

(This is with an already working VNC session) Command without sudo:

root@kali:~# vncserver -localhost

New 'kali.'"'':2 (root)' desktop at :2 on machine kali.'"''

Starting applications specified in /etc/X11/Xvnc-session
Log file is /root/.vnc/kali.'"'':2.log

Use xtigervncviewer -SecurityTypes VncAuth -passwd /root/.vnc/passwd :2 to connect to the VNC server.


vncserver: Failed command '/etc/X11/Xvnc-session': 256!

=================== tail -15 /root/.vnc/kali.'"'':2.log ===================

Xvnc TigerVNC 1.10.0 - built Dec 30 2019 14:38:21
Copyright (C) 1999-2019 TigerVNC Team and many others (see README.rst)
See https://www.tigervnc.org for information on TigerVNC.
Underlying X server release 12006000, The X.Org Foundation


Sun Jan 12 18:52:25 2020
 vncext:      VNC extension running!
 vncext:      Listening for VNC connections on local interface(s), port 5902
 vncext:      created VNC server for screen 0
X connection to :2 broken (explicit kill or server shutdown).
 ComparingUpdateTracker: 0 pixels in / 0 pixels out
 ComparingUpdateTracker: (1:-nan ratio)
Killing Xtigervnc process ID 4108... which seems to be deadlocked. Using SIGKILL!

===========================================================================

Starting applications specified in /etc/X11/Xvnc-session has failed.
Maybe try something simple first, e.g.,
        tigervncserver -xstartup /usr/bin/xterm

When running with sudo and this works:

root@kali:~# sudo vncserver -localhost

New 'kali.'"'':2 (root)' desktop at :2 on machine kali.'"''

Starting applications specified in /etc/X11/Xvnc-session
Log file is /root/.vnc/kali.'"'':2.log

Use xtigervncviewer -SecurityTypes VncAuth -passwd /root/.vnc/passwd :2 to connect to the VNC server.

I'm root for both - so I'm looking to understand why sudo makes the difference

like image 404
Michael Z Avatar asked Jan 13 '20 00:01

Michael Z


1 Answers

create executable file ~/.vnc/xstartup with the next content:

#!/bin/bash

PATH=/usr/bin:/usr/sbin
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
exec startxfce4 &

for the exec value check your desktop session with:

ls /usr/share/xsessions/

there you'll find .desktop files like:

cinnamon2d.desktop  cinnamon.desktop  gnome.desktop  gnome-xorg.desktop  
kodi.desktop

Open the file with the desktop environment you are interested in for your vnc session and check Exec variable there, for me it was cinnamon-session-cinnamon. So my ~/.vnc/xstartup looked like this:

#!/bin/bash

PATH=/usr/bin:/usr/sbin
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
exec cinnamon-session-cinnamon &

after this vncserver should start without any sudo requirements, at least, it did in my case. I guess the absence of the executable prevents vncserver from starting, but with sudo privileges it manages to start with default settings pulled from some files accessible for sudoers only.

like image 171
Victor Di Avatar answered Oct 06 '22 12:10

Victor Di