# vncserver: Wrong type of access mode of .vnc



## hannibal80 (Aug 2, 2011)

Hello everyone,
I'm really a newbie to FreeBSD.

I'm trying to make vncserver able to automatic start up on boot with a user that's not root. 

So, I spent 3 nights reading everywhere about my issues and I was able to get vnc working with xfce4. The server I used is tightvnc.

Now, the last step for now is to make it start up on boot. 

I made a script, tightvnc, and I put it into /usr/local/etc/rc.d


```
#!/bin/sh
#

# REQUIRE: DAEMON
# PROVIDE: tightvnc

. /etc/rc.subr

USER=Lorenzo
HOME=/usr/home/Lorenzo

export USER HOME

PATH=$PATH:/usr/local/bin/ && export PATH
echo $PATH
echo $USER
echo $HOME

name="tightvnc"
rcvar=`set_rcvar`
load_rc_config $name
command="/usr/local/bin/vncserver"

tightvnc_enable=${tightvnc_enable-"NO"}
tightvnc_pidfile=${tightvnc_pidfile-"/var/run/tightvnc.pid"}

pidfile="${tightvnc_pidfile}"

run_rc_command "$1"
```

then I modified my /etc/rc.conf adding

```
tightvnc_enable="YES"
```

Now, when I reboot I have: 


```
[...]
/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
Lorenzo
/usr/home/Lorenzo
Starting tightvnc.
vncserver: Wrong type or access mode of /usr/home/Lorenzo/.vnc.
/etc/rc: WARNING: failed to start tightvnc
[...]
```

I've checked the .vnc permission that are:


```
# pwd
/usr/home/Lorenzo
# ls -l | grep vnc
drwxrwxrwx  2 Lorenzo  wheel      512 Aug  2 21:36 .vnc
```

and 


```
# pwd
/usr/home/Lorenzo/.vnc
# ls -l
total 4932
-rw-------  1 Lorenzo  wheel        8 Aug  2 00:04 passwd
-rw-------  1 Lorenzo  wheel  5025792 Aug  2 00:08 xfce4-settings-help.core
-rwxr-xr-x  1 Lorenzo  wheel      204 Aug  2 00:07 xstartup
```

this is the content of /usr/home/Lorenzo/.vnc/xstartup



```
#!/bin/sh

/usr/local/bin/startxfce4

#[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
#xsetroot -solid grey
#vncconfig -iconic &
#xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#twm &
```

Can you please help me?

Thanks in advice.


----------



## SirDice (Aug 3, 2011)

hannibal80 said:
			
		

> ```
> USER=Lorenzo
> HOME=/usr/home/Lorenzo
> 
> ...


It doesn't work that way. Use su(1).


----------



## hannibal80 (Aug 3, 2011)

Hi Sir, thanks for your replay. 

But, as I'm a real newbie, how can I use "su" directive in my script? How can I change it?

Something like this?


```
#!/bin/sh
#

# REQUIRE: DAEMON
# PROVIDE: tightvnc

. /etc/rc.subr
[color="Red"]
#USER=Lorenzo
#HOME=/usr/home/Lorenzo

#export USER HOME[/color]

PATH=$PATH:/usr/local/bin/ && export PATH
echo $PATH
[color="Red"]#echo $USER
#echo $HOME
[/color]
name="tightvnc"
rcvar=`set_rcvar`
load_rc_config $name
[color="Red"]command="su /usr/local/bin/vncserver"[/color]

tightvnc_enable=${tightvnc_enable-"NO"}
tightvnc_pidfile=${tightvnc_pidfile-"/var/run/tightvnc.pid"}

pidfile="${tightvnc_pidfile}"

run_rc_command "$1"
```

Thank you.


----------



## pbd (Aug 3, 2011)

```
command="su - Lorenzo -c /usr/local/bin/vncserver"
```

See su().


----------



## hannibal80 (Aug 3, 2011)

Ok, tonight I'll try with that and I'll give you a feedback,
thank you!


----------



## hannibal80 (Aug 3, 2011)

Yes, finally it works! Thank you!


----------

