diff options
author | Adam Tkac <atkac@redhat.com> | 2011-04-27 11:20:18 +0000 |
---|---|---|
committer | Adam Tkac <atkac@redhat.com> | 2011-04-27 11:20:18 +0000 |
commit | f586b840bf71f08b900cd3475382a2a5c6d47156 (patch) | |
tree | 0900de241cbb126032301bd2368be595faa43311 /unix/vncserver | |
parent | ed2ab6d8660f23835682499c7edb91eefe451f34 (diff) | |
download | tigervnc-f586b840bf71f08b900cd3475382a2a5c6d47156.tar.gz tigervnc-f586b840bf71f08b900cd3475382a2a5c6d47156.zip |
Merged r4342 - r4359 from 1_1 branch.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4383 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'unix/vncserver')
-rwxr-xr-x | unix/vncserver | 56 |
1 files changed, 42 insertions, 14 deletions
diff --git a/unix/vncserver b/unix/vncserver index 0fbed190..7fe93bd1 100755 --- a/unix/vncserver +++ b/unix/vncserver @@ -160,17 +160,48 @@ if (!(-e $vncUserDir)) { } } -# Make sure the user has a password. - -($z,$z,$mode) = stat("$vncUserDir/passwd"); -if (!(-e "$vncUserDir/passwd") || ($mode & 077)) { - warn "\nYou will require a password to access your desktops.\n\n"; - system($exedir."vncpasswd -q $vncUserDir/passwd"); - if (($? >> 8) != 0) { - exit 1; +# Check whether VNC authentication is enabled, and if so, prompt the user to +# create a VNC password if they don't already have one. + +$securityTypeArgSpecified = 0; +$vncAuthEnabled = 0; +$passwordArgSpecified = 0; + +for ($i = 0; $i < @ARGV; ++$i) { + # -SecurityTypes can be followed by a space or "=" + my @splitargs = split('=', $ARGV[$i]); + if (@splitargs <= 1 && $i < @ARGV - 1) { + push(@splitargs, $ARGV[$i + 1]); + } + if (lc(@splitargs[0]) eq "-securitytypes") { + if (@splitargs > 1) { + $securityTypeArgSpecified = 1; + } + foreach $arg2 (split(',', @splitargs[1])) { + if (lc($arg2) eq "vncauth" || lc($arg2) eq "tlsvnc" + || lc($arg2) eq "x509vnc") { + $vncAuthEnabled = 1; + } + } + } + if ((lc(@splitargs[0]) eq "-password") + || (lc(@splitargs[0]) eq "-passwordfile" + || (lc(@splitargs[0]) eq "-rfbauth"))) { + $passwordArgSpecified = 1; } } +if ((!$securityTypeArgSpecified || $vncAuthEnabled) && !$passwordArgSpecified) { + ($z,$z,$mode) = stat("$vncUserDir/passwd"); + if (!(-e "$vncUserDir/passwd") || ($mode & 077)) { + warn "\nYou will require a password to access your desktops.\n\n"; + system($exedir."vncpasswd -q $vncUserDir/passwd"); + if (($? >> 8) != 0) { + exit 1; + } + } +} + # Find display number. if ((@ARGV > 0) && ($ARGV[0] =~ /^:(\d+)$/)) { @@ -307,13 +338,10 @@ if (-e "/tmp/.X11-unix/X$displayNumber" || $ENV{VNCDESKTOP}= $desktopName; if ($opt{'-fg'}) { - system("$vncUserDir/xstartup >> " . "edString($desktopLog) . " 2>&1"); - if (kill 0, `cat $pidFile`) { - $opt{'-kill'} = ':'.$displayNumber; - &Kill(); - } + close(STDIN); + system("($vncUserDir/xstartup; $0 -kill :$displayNumber) >> " . "edString($desktopLog) . " 2>&1"); } else { - system("($vncUserDir/xstartup; $0 -kill :$displayNumber) >> " . "edString($desktopLog) . " 2>&1 &"); + system("$vncUserDir/xstartup >> " . "edString($desktopLog) . " 2>&1 &"); } exit; |