Commit 6bd995ec authored by steven_carr's avatar steven_carr

Better support for RFB >= 3.8 protocols

parent a75a576e
...@@ -119,6 +119,28 @@ rfbVncAuthSendChallenge(rfbClientPtr cl) ...@@ -119,6 +119,28 @@ rfbVncAuthSendChallenge(rfbClientPtr cl)
cl->state = RFB_AUTHENTICATION; cl->state = RFB_AUTHENTICATION;
} }
/*
* Send the NO AUTHENTICATION. SCARR
*/
static void
rfbVncAuthNone(rfbClientPtr cl)
{
uint32_t authResult;
if (cl->protocolMajorVersion==3 && cl->protocolMinorVersion > 7) {
rfbLog("rfbProcessClientSecurityType: returning securityResult for client rfb versin >= 3.8\n");
authResult = Swap32IfLE(rfbVncAuthOK);
if (rfbWriteExact(cl, (char *)&authResult, 4) < 0) {
rfbLogPerror("rfbAuthProcessClientMessage: write");
rfbCloseClient(cl);
return;
}
}
cl->state = RFB_INITIALISATION;
return;
}
/* /*
* Advertise the supported security types (protocol 3.7). Here before sending * Advertise the supported security types (protocol 3.7). Here before sending
...@@ -129,12 +151,18 @@ rfbVncAuthSendChallenge(rfbClientPtr cl) ...@@ -129,12 +151,18 @@ rfbVncAuthSendChallenge(rfbClientPtr cl)
* Different security types will be added by applications using this library. * Different security types will be added by applications using this library.
*/ */
static rfbSecurityHandler primaryVncSecurityHandler = { static rfbSecurityHandler VncSecurityHandlerVncAuth = {
1, rfbSecTypeVncAuth,
rfbVncAuthSendChallenge, rfbVncAuthSendChallenge,
NULL NULL
}; };
static rfbSecurityHandler VncSecurityHandlerNone = {
rfbSecTypeNone,
rfbVncAuthNone,
NULL
};
static void static void
rfbSendSecurityTypeList(rfbClientPtr cl, int primaryType) rfbSendSecurityTypeList(rfbClientPtr cl, int primaryType)
...@@ -146,10 +174,15 @@ rfbSendSecurityTypeList(rfbClientPtr cl, int primaryType) ...@@ -146,10 +174,15 @@ rfbSendSecurityTypeList(rfbClientPtr cl, int primaryType)
#define MAX_SECURITY_TYPES 255 #define MAX_SECURITY_TYPES 255
uint8_t buffer[MAX_SECURITY_TYPES+1]; uint8_t buffer[MAX_SECURITY_TYPES+1];
/* Fill in the list of security types in the client structure. */
if (primaryType != rfbSecTypeInvalid) { /* Fill in the list of security types in the client structure. (NOTE: Not really in the client structure) */
primaryVncSecurityHandler.type = primaryType; switch (primaryType) {
rfbRegisterSecurityHandler(&primaryVncSecurityHandler); case rfbSecTypeNone:
rfbRegisterSecurityHandler(&VncSecurityHandlerNone);
break;
case rfbSecTypeVncAuth:
rfbRegisterSecurityHandler(&VncSecurityHandlerVncAuth);
break;
} }
for (handler = securityHandlers; for (handler = securityHandlers;
...@@ -265,7 +298,6 @@ rfbProcessClientSecurityType(rfbClientPtr cl) ...@@ -265,7 +298,6 @@ rfbProcessClientSecurityType(rfbClientPtr cl)
int n; int n;
uint8_t chosenType; uint8_t chosenType;
rfbSecurityHandler* handler; rfbSecurityHandler* handler;
uint32_t authResult;
/* Read the security type. */ /* Read the security type. */
n = rfbReadExact(cl, (char *)&chosenType, 1); n = rfbReadExact(cl, (char *)&chosenType, 1);
...@@ -281,24 +313,13 @@ rfbProcessClientSecurityType(rfbClientPtr cl) ...@@ -281,24 +313,13 @@ rfbProcessClientSecurityType(rfbClientPtr cl)
/* Make sure it was present in the list sent by the server. */ /* Make sure it was present in the list sent by the server. */
for (handler = securityHandlers; handler; handler = handler->next) { for (handler = securityHandlers; handler; handler = handler->next) {
if (chosenType == handler->type) { if (chosenType == handler->type) {
if (chosenType == rfbSecTypeNone) { rfbLog("rfbProcessClientSecurityType: executing handler for type %d\n", chosenType);
authResult = Swap32IfLE(rfbVncAuthOK);
if (rfbWriteExact(cl, (char *)&authResult, 4) < 0) {
rfbLogPerror("rfbAuthProcessClientMessage: write");
rfbCloseClient(cl);
return;
}
cl->state = RFB_INITIALISATION;
return;
} else {
handler->handler(cl); handler->handler(cl);
return; return;
} }
} }
}
rfbLog("rfbProcessClientSecurityType: wrong security type requested\n"); rfbLog("rfbProcessClientSecurityType: wrong security type (%d) requested\n", chosenType);
rfbCloseClient(cl); rfbCloseClient(cl);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment