1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

vncserver: Wrong type of access mode of .vnc

Discussion in 'Userland Programming and Scripting' started by hannibal80, Aug 2, 2011.

  1. hannibal80

    hannibal80 New Member

    Messages:
    42
    Thanks Received:
    0
    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

    Code:
    #!/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
    Code:
    tightvnc_enable="YES"


    Now, when I reboot I have:

    Code:
    [...]
    /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:

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


    and

    Code:
    # 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


    Code:
    #!/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.
     
  2. SirDice

    SirDice Moderator Staff Member Moderator

    Messages:
    17,523
    Thanks Received:
    2,351
    It doesn't work that way. Use su(1).
     
    hannibal80 thanks for this.
  3. hannibal80

    hannibal80 New Member

    Messages:
    42
    Thanks Received:
    0
    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?

    Code:
    #!/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="su /usr/local/bin/vncserver"
    
    tightvnc_enable=${tightvnc_enable-"NO"}
    tightvnc_pidfile=${tightvnc_pidfile-"/var/run/tightvnc.pid"}
    
    pidfile="${tightvnc_pidfile}"
    
    run_rc_command "$1"


    Thank you.
     
  4. pbd

    pbd New Member

    Messages:
    191
    Thanks Received:
    31
    Code:
    command="su - Lorenzo -c /usr/local/bin/vncserver"


    See su().
     
    hannibal80 thanks for this.
  5. hannibal80

    hannibal80 New Member

    Messages:
    42
    Thanks Received:
    0
    Ok, tonight I'll try with that and I'll give you a feedback,
    thank you!
     
  6. hannibal80

    hannibal80 New Member

    Messages:
    42
    Thanks Received:
    0
    Yes, finally it works! Thank you!