Hi all,

This is actually a 2-in-1 patch (not sure if that is a good idea). I ran 
into 2 problems with the old version:

1) When a VNC desktop is running, most users (accidentally) log out once 
or twice, and then complain that their screen is black (or worse, has a 
ghost image of the desktop). The users are usually not very interested 
in what went wrong, they want to be able to simply restart the desktop. 
I share their opinion, since the vncserver script is set-up in such a 
way that it starts a virtual desktop (rather than X alone), and on 
logout, no one is happy with an empty X session.

I have added an option -TermOnLogout to the script, which runs vncserver 
-kill after the desktop was shut down. The patch was inspired from here:
http://markmail.org/message/wh6avdxdbqm5kfwu#query:terminate%20vncserver%20on%20logout+page:1+mid:apdzqspklbhhhcdj+state:results

(Optionally, the vncserver script can be run with an & so users can log 
out of their shell.)


2) When using the VeNCrypt security type, the ~/.vnc/passwd is not 
necessary, yet the user is asked to create one. Same when using the 
securitytype none. The script now checks for the -SecurityType option 
and checks wether VeNCrypt type or none is specified. (That is, I am in 
the assumption that the VeNCrypt type does not use the vnc password.)


Greetings,
Sebastiaan

--- /usr/bin/vncserver    2011-01-24 00:23:33.000000000 +0100
+++ vncserver    2011-03-01 10:34:01.000000000 +0100
@@ -121,7 +121,7 @@
  # Check command line options

&ParseOptions("-geometry",1,"-depth",1,"-pixelformat",1,"-name",1,"-kill",1,
-          "-help",0,"-h",0,"--help",0,"-fp",1);
+          "-help",0,"-h",0,"--help",0,"-fp",1,"-TermOnLogout", 0);

&Usage() if ($opt{'-help'} || $opt{'-h'} || $opt{'--help'});

@@ -146,6 +146,25 @@
      $fpArgSpecified = 1;
  }

+# Check the arguments to check if the VeNCrypt security type is set
+# If so, there is no need for a user password
+$needvncpass = 1;
+foreach $arg (@ARGV) {
+    my @splitargs = split('=', $arg);
+
+    if (lc(@splitargs[0]) eq "-securitytypes")
+    {
+        my @splitargs2 = split(',', @splitargs[1]);
+
+        if ((lc(@splitargs2[0]) eq "vencrypt") || (lc(@splitargs2[0]) 
eq "none"))
+        {
+            # No password necessary
+            $needvncpass = 0;
+        }
+    }
+}
+
+
&CheckGeometryAndDepth();


@@ -157,14 +176,17 @@
      }
  }

-# 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;
+# Make sure the user has a password, if required
+if ($needvncpass)
+{
+    ($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;
+        }
      }
  }

@@ -303,7 +325,16 @@
  }
  $ENV{VNCDESKTOP}= $desktopName;

-system("$vncUserDir/xstartup >> " . &quotedString($desktopLog) . " 2>&1 
&");
+if ($opt{'-TermOnLogout'})
+{
+    system("$vncUserDir/xstartup >> " . &quotedString($desktopLog) . " 
2>&1");
+    system("vncserver -kill :$displayNumber");
+}
+else
+{
+    system("$vncUserDir/xstartup >> " . &quotedString($desktopLog) . " 
2>&1 &");
+}
+

  exit;

@@ -524,6 +555,7 @@
      "                 [-geometry <width>x<height>]\n".
      "                 [-pixelformat rgbNNN|bgrNNN]\n".
      "                 [-fp <font-path>]\n".
+    "                 [-TermOnLogout]\n".
      " <Xvnc-options>...\n\n".
      "       $prog -kill <X-display>\n\n");
  }


------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in 
Real-Time with Splunk. Collect, index and harness all the fast moving IT data 
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business 
insights. http://p.sf.net/sfu/splunk-dev2dev 
_______________________________________________
Tigervnc-devel mailing list
Tigervnc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tigervnc-devel

Reply via email to