James Budiono 2013
GPL Version 3 or later.

This patch does:
a) Disable PAM (can easily be re-enabled - that's the first patch)
b) Make turbovnc build if PAM is disabled (add a couple of conditional defines)
c) Change the project root to /usr instead of /usr/X11R6 (for modern xorg build)
d) Change the font dir to /usr/share/fonts/X11 (for modern xorg build)
e) Fix errors with password-less authentication, and authentication with
   RFB protocol less than 3.8 (e.g., 3.7 and 3.3) - e.g. the one used by 
   xrdp.   
--

diff -ur vnc-old/unix/Xvnc/config/cf/linux.cf vnc/unix/Xvnc/config/cf/linux.cf
--- vnc-old/unix/Xvnc/config/cf/linux.cf	2012-03-09 00:24:52.000000000 +0700
+++ vnc/unix/Xvnc/config/cf/linux.cf	2013-10-05 13:34:46.956884948 +0700
@@ -399,7 +399,7 @@
 #endif
 
 #ifndef XvncAuthPAM
-#define XvncAuthPAM     YES
+#define XvncAuthPAM     NO
 #endif
 
 #ifndef JPEGIncludeFlags
diff -ur vnc-old/unix/Xvnc/config/cf/vnc.def vnc/unix/Xvnc/config/cf/vnc.def
--- vnc-old/unix/Xvnc/config/cf/vnc.def	2012-03-09 00:24:52.000000000 +0700
+++ vnc/unix/Xvnc/config/cf/vnc.def	2013-10-05 13:34:46.956884948 +0700
@@ -121,7 +121,7 @@
 #define ProjectRoot /usr/openwin
 #else
 #ifdef LinuxArchitecture
-#define ProjectRoot /usr/X11R6
+#define ProjectRoot /usr
 #endif
 #endif
 
diff -ur vnc-old/unix/Xvnc/config/cf/X11.tmpl vnc/unix/Xvnc/config/cf/X11.tmpl
--- vnc-old/unix/Xvnc/config/cf/X11.tmpl	2012-03-09 00:24:52.000000000 +0700
+++ vnc/unix/Xvnc/config/cf/X11.tmpl	2013-10-05 13:34:46.966884943 +0700
@@ -705,7 +705,7 @@
 #define ConfigDir $(LIBDIR)/config
 #endif
 #ifndef FontDir
-#define FontDir $(LIBDIR)/fonts
+#define FontDir /usr/share/fonts/X11
 #endif
 #ifndef AdmDir
 #define AdmDir /usr/adm
diff -ur vnc-old/unix/Xvnc/programs/Xserver/hw/vnc/auth.c vnc/unix/Xvnc/programs/Xserver/hw/vnc/auth.c
--- vnc-old/unix/Xvnc/programs/Xserver/hw/vnc/auth.c	2012-03-09 00:24:52.000000000 +0700
+++ vnc/unix/Xvnc/programs/Xserver/hw/vnc/auth.c	2013-10-05 17:56:09.498715918 +0700
@@ -264,11 +264,17 @@
 static AuthCapData  authCapVncauth   = { rfbAuthVNC, rfbStandardVendor, sig_rfbAuthVNC,
                                          rfbVncAuthSendChallenge, rfbVncAuthProcessResponse};
 
+#ifdef XVNC_AuthPAM
 static AuthCapData  authCapUnixLogin = { rfbAuthUnixLogin, rfbTightVncVendor, sig_rfbAuthUnixLogin,
                                          AuthPAMUserPwdStartFunc, AuthPAMUserPwdRspFunc};
+#endif
 
 static AuthCapData* authCaps[] = {
-    &authCapNone, &authCapVncauth, &authCapUnixLogin, NULL
+    &authCapNone, &authCapVncauth,
+#ifdef XVNC_AuthPAM
+    &authCapUnixLogin,
+#endif 
+    NULL
 };
 
 typedef struct {
@@ -521,7 +527,8 @@
 
         FatalError("ERROR: no authentication methods enabled!\n");
     } else {
-        secTypeNone.advertise = FALSE;
+		/* if at least one auth method is selected, disable password-less login */
+        if (nSelected) secTypeNone.advertise = FALSE;
     }
 
 #ifdef XVNC_AuthPAM
@@ -1157,7 +1164,7 @@
 {
     CARD32 authResult;
 
-    if (cl->protocol_minor_ver >= 8) {
+	if (authType != rfbAuthNone || cl->protocol_minor_ver >= 8) {
         authResult = Swap32IfLE(rfbAuthOK);
         if (WriteExact(cl->sock, (char *)&authResult, 4) < 0) {
             rfbLogPerror("rfbClientAuthSucceeded: write");
