Skip to content

Commit 7f98dc0

Browse files
committed
libvncclient: add ARD principal and realm setters
1 parent 643bb4c commit 7f98dc0

3 files changed

Lines changed: 57 additions & 0 deletions

File tree

include/rfb/rfbclient.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,11 @@ typedef struct _rfbClient {
407407
* Set by function SetClientAuthSchemes() */
408408
uint32_t *clientAuthSchemes;
409409

410+
/** Optional configuration for ARD Kerberos auth. */
411+
char *ardAuthRealm;
412+
char *ardAuthClientPrincipal;
413+
char *ardAuthServicePrincipal;
414+
410415
/** When the server is a repeater, this specifies the final destination */
411416
char *destHost;
412417
int destPort;
@@ -529,6 +534,9 @@ extern rfbClientLogProc rfbClientLog,rfbClientErr;
529534
extern rfbBool ConnectToRFBServer(rfbClient* client,const char *hostname, int port);
530535
extern rfbBool ConnectToRFBRepeater(rfbClient* client,const char *repeaterHost, int repeaterPort, const char *destHost, int destPort);
531536
extern void SetClientAuthSchemes(rfbClient* client,const uint32_t *authSchemes, int size);
537+
extern rfbBool rfbClientSetARDAuthRealm(rfbClient *client, const char *realm);
538+
extern rfbBool rfbClientSetARDAuthClientPrincipal(rfbClient *client, const char *principal);
539+
extern rfbBool rfbClientSetARDAuthServicePrincipal(rfbClient *client, const char *principal);
532540
extern rfbBool InitialiseRFBConnection(rfbClient* client);
533541
/**
534542
* Sends format and encoding parameters to the server. Your application can

src/libvncclient/rfbclient.c

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,25 @@ rfbClientLogProc rfbClientErr=rfbDefaultClientLog;
102102

103103
rfbClientProtocolExtension* rfbClientExtensions = NULL;
104104

105+
static rfbBool
106+
SetOptionalClientString(char **dst, const char *value)
107+
{
108+
char *copy = NULL;
109+
110+
if (!dst)
111+
return FALSE;
112+
113+
if (value) {
114+
copy = strdup(value);
115+
if (!copy)
116+
return FALSE;
117+
}
118+
119+
free(*dst);
120+
*dst = copy;
121+
return TRUE;
122+
}
123+
105124
static rfbBool
106125
SupportsARDAuthScheme(uint8_t authScheme)
107126
{
@@ -987,6 +1006,30 @@ SetClientAuthSchemes(rfbClient* client,const uint32_t *authSchemes, int size)
9871006
}
9881007
}
9891008

1009+
rfbBool
1010+
rfbClientSetARDAuthRealm(rfbClient *client, const char *realm)
1011+
{
1012+
if (!client)
1013+
return FALSE;
1014+
return SetOptionalClientString(&client->ardAuthRealm, realm);
1015+
}
1016+
1017+
rfbBool
1018+
rfbClientSetARDAuthClientPrincipal(rfbClient *client, const char *principal)
1019+
{
1020+
if (!client)
1021+
return FALSE;
1022+
return SetOptionalClientString(&client->ardAuthClientPrincipal, principal);
1023+
}
1024+
1025+
rfbBool
1026+
rfbClientSetARDAuthServicePrincipal(rfbClient *client, const char *principal)
1027+
{
1028+
if (!client)
1029+
return FALSE;
1030+
return SetOptionalClientString(&client->ardAuthServicePrincipal, principal);
1031+
}
1032+
9901033
/*
9911034
* InitialiseRFBConnection.
9921035
*/

src/libvncclient/vncviewer.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,9 @@ rfbClient* rfbGetClient(int bitsPerSample,int samplesPerPixel,
396396
client->listen6Sock = RFB_INVALID_SOCKET;
397397
client->listen6Address = NULL;
398398
client->clientAuthSchemes = NULL;
399+
client->ardAuthRealm = NULL;
400+
client->ardAuthClientPrincipal = NULL;
401+
client->ardAuthServicePrincipal = NULL;
399402

400403
#ifdef LIBVNCSERVER_HAVE_SASL
401404
client->GetSASLMechanism = NULL;
@@ -588,6 +591,9 @@ void rfbClientCleanup(rfbClient* client) {
588591
free(client->serverHost);
589592
free(client->destHost);
590593
free(client->clientAuthSchemes);
594+
free(client->ardAuthRealm);
595+
free(client->ardAuthClientPrincipal);
596+
free(client->ardAuthServicePrincipal);
591597
free(client->rcSource);
592598
free(client->rcMask);
593599

0 commit comments

Comments
 (0)