TurboVNC / turbovnc

Main TurboVNC repository
https://TurboVNC.org
GNU General Public License v2.0
746 stars 136 forks source link

vncserver: Wrong type or access mode of /home/tyiot/.vnc #391

Closed ml232528 closed 6 months ago

ml232528 commented 6 months ago

Question 1: Non administrator run /opt/TurboVNC/bin/vncserver prompt: vncserver: Wrong type or access mode of /home/tyiot/.vnc

Question 2: Using root correctly for the first connection,Second connection prompt:

Session Manager Error:
Could not execute
    /opt/TurboVNC/bin/vncpasswd -o -display :1
on host 192.168.119.57:
    unable to open display ":1"
ml232528 commented 6 months ago

ubuntu:1.log

TurboVNC Server (Xvnc) 64-bit v3.0.3 (build 20230227)
Copyright (C) 1999-2022 The VirtualGL Project and many others (see README.txt)
Visit http://www.TurboVNC.org for more information on TurboVNC

12/12/2023 20:19:46 Using security configuration file /etc/turbovncserver-security.conf
12/12/2023 20:19:46 Enabled security type 'otp'
12/12/2023 20:19:46 Desktop name 'TurboVNC: ubuntu:1 (root)' (ubuntu:1)
12/12/2023 20:19:46 Protocol versions supported: 3.3, 3.7, 3.8, 3.7t, 3.8t
12/12/2023 20:19:46 Listening for VNC connections on TCP port 5901
12/12/2023 20:19:46   Interface 0.0.0.0
12/12/2023 20:19:46 Framebuffer: BGRX 8/8/8/8
12/12/2023 20:19:46 New desktop size: 1240 x 900
12/12/2023 20:19:46 New screen layout:
12/12/2023 20:19:46   0x00000040 (output 0x00000040): 1240x900+0+0
12/12/2023 20:19:46 Maximum clipboard transfer size: 1048576 bytes
12/12/2023 20:19:46 VNC extension running!
xstartup.turbovnc: Creating new session bus instance:
xstartup.turbovnc:   unix:abstract=/tmp/dbus-MQ0UqEePSA,guid=8de64bbc18aa9b96aa94b7c865784fe3
xstartup.turbovnc: Using 'ubuntu' window manager in
xstartup.turbovnc:   /usr/share/xsessions/ubuntu.desktop
xstartup.turbovnc: Executing /etc/X11/Xsession "env GNOME_SHELL_SESSION_MODE=ubuntu /usr/bin/gnome-session --systemd --session=ubuntu"

12/12/2023 20:19:47 Got connection from client 127.0.0.1
12/12/2023 20:19:47 Normal socket connection
12/12/2023 20:19:47 Using protocol version 3.8
12/12/2023 20:19:47 rfbSendSecurityTypeList: advertise sectype tight
12/12/2023 20:19:47 Full-control authentication enabled for 127.0.0.1
12/12/2023 20:19:47 Pixel format for client 127.0.0.1:
12/12/2023 20:19:47   32 bpp, depth 24, little endian
12/12/2023 20:19:47   true colour: max r 255 g 255 b 255, shift r 16 g 8 b 0
12/12/2023 20:19:47   no translation needed
12/12/2023 20:19:47 Enabling full-color cursor updates for client 127.0.0.1
12/12/2023 20:19:47 Enabling Desktop Size protocol extension for client 127.0.0.1
12/12/2023 20:19:47 Enabling Extended Desktop Size protocol extension for client 127.0.0.1
12/12/2023 20:19:47 rfbProcessClientNormalMessage: ignoring unknown encoding -307 (fffffecd)
12/12/2023 20:19:47 Enabling LastRect protocol extension for client 127.0.0.1
12/12/2023 20:19:47 Enabling Continuous Updates protocol extension for client 127.0.0.1
12/12/2023 20:19:47 Enabling Fence protocol extension for client 127.0.0.1
12/12/2023 20:19:47 Enabling GII protocol extension for client 127.0.0.1
12/12/2023 20:19:47 Using tight encoding for client 127.0.0.1
12/12/2023 20:19:47 Using JPEG subsampling 0, Q100 for client 127.0.0.1
12/12/2023 20:19:47 Using JPEG quality 95 for client 127.0.0.1
12/12/2023 20:19:47 Using JPEG subsampling 0 for client 127.0.0.1
12/12/2023 20:19:47 Using Tight compression level 1 for client 127.0.0.1
12/12/2023 20:19:47 Using 4 threads for Tight encoding
12/12/2023 20:19:47 Client supports GII version 1
12/12/2023 20:19:47 New screen layout:
12/12/2023 20:19:47   0x00000040 (output 0x00000040): 1240x900+0+0
12/12/2023 20:19:47 Continuous updates enabled
12/12/2023 20:19:47 Continuous updates enabled
12/12/2023 20:19:47 Continuous updates enabled
12/12/2023 20:19:49 New desktop size: 1920 x 987
12/12/2023 20:19:49 New screen layout:
12/12/2023 20:19:49   0x00000040 (output 0x00000040): 1920x987+0+0
12/12/2023 20:19:49 Continuous updates enabled
12/12/2023 20:19:49 Continuous updates enabled
double free or corruption (out)
(EE) 
Fatal server error:
(EE) Caught signal 6 (Aborted). Server aborting
(EE) 
dcommander commented 6 months ago

Question 1:

/opt/TurboVNC/bin/vncserver will create the ~/.vnc directory if it doesn't exist, and if /opt/TurboVNC/bin/vncserver creates ~/.vnc, then the directory will have the correct ownership and permissions for your user account. However, apparently you did something that caused ~/.vnc to be created with incorrect ownership or permissions. ~/.vnc should be owned by your user account and should have mode 700 (u+rwx,g-rwx,o-rwx).

Question 2:

I need to understand what you mean by "using root correctly for the first connection." Normally, it should never be necessary to run TurboVNC with root credentials, and doing so it not advised. What exactly are you trying to do?

ml232528 commented 6 months ago

Question 1:

/opt/TurboVNC/bin/vncserver will create the ~/.vnc directory if it doesn't exist, and if /opt/TurboVNC/bin/vncserver creates ~/.vnc, then the directory will have the correct ownership and permissions for your user account. However, apparently you did something that caused ~/.vnc to be created with incorrect ownership or permissions. ~/.vnc should be owned by your user account and should have mode 700 (u+rwx,g-rwx,o-rwx).

The folder permissions are sufficient:

tyiot@ubuntu:/root/.vnc$ ll ~/.vnc
总用量 12
drwxrwxrwx  2 root  root  4096 12月 14 09:14 ./
drwxrwxrwx 23 tyiot tyiot 4096 12月 14 09:14 ../
-rwxrwxrwx  1 root  root    39 12月 14 09:14 turbovncserver.conf*
tyiot@ubuntu:/root/.vnc$ /opt/TurboVNC/bin/vncserver :3
vncserver: Wrong type or access mode of /home/tyiot/.vnc.
tyiot@ubuntu:/root/.vnc$ sudo /opt/TurboVNC/bin/vncserver :3
[sudo] tyiot 的密码: 

Desktop 'TurboVNC: ubuntu:3 (root)' started on display ubuntu:3

Starting applications specified in /opt/TurboVNC/bin/xstartup.turbovnc
Log file is /root/.vnc/ubuntu:3.log

tyiot@ubuntu:/root/.vnc$ 

Question 2:

I need to understand what you mean by "using root correctly for the first connection." Normally, it should never be necessary to run TurboVNC with root credentials, and doing so it not advised. What exactly are you trying to do?

I used root because of Question 1. Currently, I am using the following command to restore normal operation, apt-get -f install ubuntu-desktop but I still need the root user to connect

ml232528 commented 6 months ago

chown tyiot:tyiot -R /home/tyiot/.vnc /opt/TurboVNC/bin/vncserver :4

After changing the owner, the following error occurred:dbus[373298]: Unable to set up transient service directory: XDG_RUNTIME_DIR "/run/user/0" is owned by uid 0, not our uid 1000

cat /home/tyiot/.vnc/ubuntu:4.log

TurboVNC Server (Xvnc) 64-bit v3.1 (build 20231117)
Copyright (C) 1999-2023 The VirtualGL Project and many others (see README.md)
Visit http://www.TurboVNC.org for more information on TurboVNC

14/12/2023 11:41:02 Using security configuration file /etc/turbovncserver-security.conf
14/12/2023 11:41:02 Enabled security type 'tlsnone'
14/12/2023 11:41:02 Desktop name 'TurboVNC: ubuntu:4 (tyiot)' (ubuntu:4)
14/12/2023 11:41:02 Protocol versions supported: 3.3, 3.7, 3.8, 3.7t, 3.8t
14/12/2023 11:41:02 Listening for VNC connections on TCP port 5904
14/12/2023 11:41:02   Interface 0.0.0.0
14/12/2023 11:41:02 Framebuffer: BGRX 8/8/8/8
14/12/2023 11:41:02 New desktop size: 1240 x 900
14/12/2023 11:41:02 New screen layout:
14/12/2023 11:41:02   0x00000040 (output 0x00000040): 1240x900+0+0
14/12/2023 11:41:02 Maximum clipboard transfer size: 1048576 bytes
14/12/2023 11:41:02 VNC extension running!
dbus[378934]: Unable to set up transient service directory: XDG_RUNTIME_DIR "/run/user/0" is owned by uid 0, not our uid 1000
xstartup.turbovnc: Creating new session bus instance:
xstartup.turbovnc:   unix:abstract=/tmp/dbus-2rZrpOYQby,guid=b2cf7835b418832da6d831d1657a794f
xstartup.turbovnc: Using 'ubuntu' window manager in
xstartup.turbovnc:   /usr/share/xsessions/ubuntu.desktop
xstartup.turbovnc: Executing /etc/X11/Xsession "env GNOME_SHELL_SESSION_MODE=ubuntu /usr/bin/gnome-session --systemd --session=ubuntu"
Killing Xvnc process ID 378885
dcommander commented 6 months ago

The permissions on ~/.vnc must be exactly 700, not 777 as you showed above. That is to protect the VNC password from being read by other users.

dcommander commented 6 months ago

As far as the XDG error, I'm not sure what you did to change the permissions of your XDG runtime directory, but you need to change them back. That is not a TurboVNC issue.