Package: ssvnc
Severity: wishlist
Tags: upstream patch

I've implemented scprompt "auth" request, used by ultravnc when passing 
-sc_exit or -sc_prompt
The relevant code is:
http://ultravnc.svn.sourceforge.net/viewvc/ultravnc/UltraVNC%20Project%20Root/UltraVNC/winvnc/winvnc/vncclient.cpp?revision=753&view=markup

I'm not sure about the use of Swap32IfBE(), but since the ultravnc code is le I 
think it should be correct to
use this function.

Regards


-- System Information:
Debian Release: wheezy/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.32-5-xen-amd64 (SMP w/8 CPU cores)
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/bash

Versions of packages ssvnc depends on:
ii  bind9-host [host]  1:9.8.4.dfsg-1
ii  libc6              2.13-37
ii  libice6            2:1.0.8-2
ii  libjpeg8           8d-1
ii  libsm6             2:1.2.1-2
ii  libssl1.0.0        1.0.1c-4
ii  libx11-6           2:1.5.0-1
ii  libxaw7            2:1.0.10-2
ii  libxext6           2:1.3.1-2
ii  libxmu6            2:1.1.1-1
ii  libxpm4            1:3.5.10-1
ii  libxt6             1:1.1.3-1
ii  openssh-client     1:6.0p1-3
ii  openssl            1.0.1c-4
ii  procps             1:3.3.4-2
ii  psmisc             22.20-1
pn  stunnel4           <none>
pn  tk                 <none>
ii  xterm              278-4
ii  zlib1g             1:1.2.7.dfsg-13

Versions of packages ssvnc recommends:
pn  default-jre | java5-runtime  <none>

ssvnc suggests no packages.
--- ssvnc-1.0.29.orig/vnc_unixsrc/vncviewer/rfbproto.c
+++ ssvnc-1.0.29/vnc_unixsrc/vncviewer/rfbproto.c
@@ -46,6 +46,7 @@ static int SelectSecurityType(void);
 static Bool PerformAuthenticationTight(void);
 static Bool AuthenticateVNC(void);
 static Bool AuthenticateUltraVNC(void);
+static Bool AuthenticateSCPrompt(void);
 static Bool AuthenticateUnixLogin(void);
 static Bool ReadInteractionCaps(void);
 static Bool ReadCapabilityList(CapsContainer *caps, int count);
@@ -935,6 +936,11 @@ InitialiseRFBConnection(void)
 				return False;
 			}
 			break;
+		case rfbUltraVNC_SCPrompt:
+			if (!AuthenticateSCPrompt()) {
+				return False;
+			}
+			break;
 		default:                      /* should never happen */
 			sprintf(msgbuf, "Internal error: Invalid security type: %d\n", secType);
 			wmsg(msgbuf, 1);
@@ -1075,7 +1081,7 @@ static int
 SelectSecurityType(void)
 {
 	CARD8 nSecTypes;
-	CARD8 knownSecTypes[] = {rfbSecTypeNone, rfbSecTypeVncAuth, rfbSecTypeUltra};
+	CARD8 knownSecTypes[] = {rfbSecTypeNone, rfbSecTypeVncAuth, rfbSecTypeUltra, rfbUltraVNC_SCPrompt};
 	int nKnownSecTypes = sizeof(knownSecTypes);
 	CARD8 *secTypes;
 	CARD8 secType = rfbSecTypeInvalid;
@@ -1083,6 +1089,7 @@ SelectSecurityType(void)
 	int have_none = 0;
 	int have_vncauth = 0;
 	int have_ultra = 0;
+	int have_scprompt = 0;
 
 	fprintf(stderr, "\nSelectSecurityType:\n");
 
@@ -1110,6 +1117,8 @@ SelectSecurityType(void)
 			have_vncauth = 1;
 		} else if (rfbSecTypeUltra == secTypes[j]) {
 			have_ultra = 1;
+		} else if (rfbUltraVNC_SCPrompt == secTypes[j]) {
+			have_scprompt = 1;
 		}
 	}
 
@@ -1135,10 +1144,11 @@ SelectSecurityType(void)
 	}
 
 	if (have_ultra) {
-		if(have_none || have_vncauth) {
-			knownSecTypes[0] = rfbSecTypeUltra; 
-			knownSecTypes[1] = rfbSecTypeNone; 
-			knownSecTypes[2] = rfbSecTypeVncAuth; 
+		if(have_none || have_vncauth || have_scprompt) {
+			knownSecTypes[0] = rfbUltraVNC_SCPrompt;
+			knownSecTypes[1] = rfbSecTypeUltra; 
+			knownSecTypes[2] = rfbSecTypeNone; 
+			knownSecTypes[3] = rfbSecTypeVncAuth; 
 		} else {
 			fprintf(stderr, "Info: UltraVNC server not offering security types 'None' or 'VncAuth'.\n");
 		}
@@ -1843,6 +1853,38 @@ AuthenticateUltraVNC(void)
 	return False;
 }
 
+static Bool
+AuthenticateSCPrompt(void)
+{
+	char message[1025];
+	CARD32 size, accepted = Swap32IfBE(1);
+
+	if (!ReadFromRFBServer((char *)&size, 4)) {
+		return False;
+	}
+
+	size = Swap32IfBE(size);
+
+	if ((size < 0) || (size > 1024)) {
+		fprintf(stderr, "UltraVNC SCPrompt invalid message size %d\n", size);
+		if (size < 0) size = 0;
+		if (size > 1024) size = 1024;
+	}
+
+	if (!ReadFromRFBServer((char *)&message, size)) {
+		return False;
+	}
+
+	message[size] = 0;
+	fprintf(stderr, "UltraVNC SCPrompt message:\n%s", message);
+
+	if (!WriteExact(rfbsock, (char *)&accepted, 4)) {
+		return False;
+	}
+
+	return AuthenticateUltraVNC();
+}
+
 /*
  * Unix login-style authentication.
  */

Reply via email to