Add support for viewers to select security types on demand

Signed-off-by: Vic Lee <llyzs@163.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
pull/1/head
Vic Lee 15 years ago committed by Johannes Schindelin
parent a795da8d7b
commit b019572e73

@ -508,13 +508,31 @@ ReadSupportedSecurityType(rfbClient* client, uint32_t *result, rfbBool subAuth)
if (flag) continue; if (flag) continue;
if (tAuth[loop]==rfbVncAuth || tAuth[loop]==rfbNoAuth || tAuth[loop]==rfbMSLogon || if (tAuth[loop]==rfbVncAuth || tAuth[loop]==rfbNoAuth || tAuth[loop]==rfbMSLogon ||
(!subAuth && (tAuth[loop]==rfbTLS || tAuth[loop]==rfbVeNCrypt))) (!subAuth && (tAuth[loop]==rfbTLS || tAuth[loop]==rfbVeNCrypt)))
{
if (!subAuth && client->clientAuthSchemes)
{
int i;
for (i=0;client->clientAuthSchemes[i];i++)
{
if (client->clientAuthSchemes[i]==(uint32_t)tAuth[loop])
{
flag++;
authScheme=tAuth[loop];
break;
}
}
}
else
{ {
flag++; flag++;
authScheme=tAuth[loop]; authScheme=tAuth[loop];
}
if (flag)
{
rfbClientLog("Selecting security type %d (%d/%d in the list)\n", authScheme, loop, count); rfbClientLog("Selecting security type %d (%d/%d in the list)\n", authScheme, loop, count);
/* send back a single byte indicating which security type to use */ /* send back a single byte indicating which security type to use */
if (!WriteToRFBServer(client, (char *)&tAuth[loop], 1)) return FALSE; if (!WriteToRFBServer(client, (char *)&tAuth[loop], 1)) return FALSE;
}
} }
} }
if (authScheme==0) if (authScheme==0)
@ -718,6 +736,35 @@ HandleMSLogonAuth(rfbClient *client)
return TRUE; return TRUE;
} }
/*
* SetClientAuthSchemes.
*/
void
SetClientAuthSchemes(rfbClient* client,const uint32_t *authSchemes, int size)
{
int i;
if (client->clientAuthSchemes)
{
free(client->clientAuthSchemes);
client->clientAuthSchemes = NULL;
}
if (authSchemes)
{
if (size<0)
{
/* If size<0 we assume the passed-in list is also 0-terminate, so we
* calculate the size here */
for (size=0;authSchemes[size];size++) ;
}
client->clientAuthSchemes = (uint32_t*)malloc(sizeof(uint32_t)*(size+1));
for (i=0;i<size;i++)
client->clientAuthSchemes[i] = authSchemes[i];
client->clientAuthSchemes[size] = 0;
}
}
/* /*
* InitialiseRFBConnection. * InitialiseRFBConnection.
*/ */

@ -192,6 +192,7 @@ rfbClient* rfbGetClient(int bitsPerSample,int samplesPerPixel,
#endif #endif
client->sock = -1; client->sock = -1;
client->listenSock = -1; client->listenSock = -1;
client->clientAuthSchemes = NULL;
return client; return client;
} }
@ -341,5 +342,7 @@ void rfbClientCleanup(rfbClient* client) {
close(client->listenSock); close(client->listenSock);
free(client->desktopName); free(client->desktopName);
free(client->serverHost); free(client->serverHost);
if (client->clientAuthSchemes)
free(client->clientAuthSchemes);
free(client); free(client);
} }

@ -305,6 +305,10 @@ typedef struct _rfbClient {
* be bypassed. * be bypassed.
*/ */
GetCredentialProc GetCredential; GetCredentialProc GetCredential;
/* The 0-terminated security types supported by the client.
* Set by function SetClientAuthSchemes() */
uint32_t *clientAuthSchemes;
} rfbClient; } rfbClient;
/* cursor.c */ /* cursor.c */
@ -322,6 +326,7 @@ extern rfbBool rfbEnableClientLogging;
typedef void (*rfbClientLogProc)(const char *format, ...); typedef void (*rfbClientLogProc)(const char *format, ...);
extern rfbClientLogProc rfbClientLog,rfbClientErr; extern rfbClientLogProc rfbClientLog,rfbClientErr;
extern rfbBool ConnectToRFBServer(rfbClient* client,const char *hostname, int port); extern rfbBool ConnectToRFBServer(rfbClient* client,const char *hostname, int port);
extern void SetClientAuthSchemes(rfbClient* client,const uint32_t *authSchemes, int size);
extern rfbBool InitialiseRFBConnection(rfbClient* client); extern rfbBool InitialiseRFBConnection(rfbClient* client);
extern rfbBool SetFormatAndEncodings(rfbClient* client); extern rfbBool SetFormatAndEncodings(rfbClient* client);
extern rfbBool SendIncrementalFramebufferUpdateRequest(rfbClient* client); extern rfbBool SendIncrementalFramebufferUpdateRequest(rfbClient* client);

Loading…
Cancel
Save