summaryrefslogtreecommitdiffstats
path: root/libvncserver/auth.c
diff options
context:
space:
mode:
Diffstat (limited to 'libvncserver/auth.c')
-rwxr-xr-xlibvncserver/auth.c58
1 files changed, 54 insertions, 4 deletions
diff --git a/libvncserver/auth.c b/libvncserver/auth.c
index e3a89eb..fd4c487 100755
--- a/libvncserver/auth.c
+++ b/libvncserver/auth.c
@@ -35,18 +35,68 @@
static rfbSecurityHandler* securityHandlers = NULL;
+/*
+ * This method registers a list of new security types.
+ * It avoids same security type getting registered multiple times.
+ * The order is not preserved if multiple security types are
+ * registered at one-go.
+ */
void
rfbRegisterSecurityHandler(rfbSecurityHandler* handler)
{
- rfbSecurityHandler* last = handler;
+ rfbSecurityHandler *head = securityHandlers, *next = NULL;
+
+ if(handler == NULL)
+ return;
- while(last->next)
- last = last->next;
+ next = handler->next;
- last->next = securityHandlers;
+ while(head != NULL) {
+ if(head == handler) {
+ rfbRegisterSecurityHandler(next);
+ return;
+ }
+
+ head = head->next;
+ }
+
+ handler->next = securityHandlers;
securityHandlers = handler;
+
+ rfbRegisterSecurityHandler(next);
}
+/*
+ * This method unregisters a list of security types.
+ * These security types won't be available for any new
+ * client connection.
+ */
+void
+rfbUnregisterSecurityHandler(rfbSecurityHandler* handler)
+{
+ rfbSecurityHandler *cur = NULL, *pre = NULL;
+
+ if(handler == NULL)
+ return;
+
+ if(securityHandlers == handler) {
+ securityHandlers = securityHandlers->next;
+ rfbUnregisterSecurityHandler(handler->next);
+ return;
+ }
+
+ cur = pre = securityHandlers;
+
+ while(cur) {
+ if(cur == handler) {
+ pre->next = cur->next;
+ break;
+ }
+ pre = cur;
+ cur = cur->next;
+ }
+ rfbUnregisterSecurityHandler(handler->next);
+}
/*
* Send the authentication challenge.