update LOC hostmask in the authlog when the "real" user connects and show current...
[srvx.git] / src / nickserv.c
index 31ee22f2e29b4273d52c526076e4d2900395afac..bc507adf659b2be8c7e871ce4c1dbce8e10f2a0c 100644 (file)
@@ -417,7 +417,7 @@ static struct {
 } nickserv_conf;
 
 struct pendingLOCUser {
-    char numeric[COMBO_NUMERIC_LEN+1];
+    struct handle_info *handle_info;
     unsigned long time;
     struct authlogEntry *authlog;
     struct pendingLOCUser *next;
@@ -1974,9 +1974,7 @@ struct handle_info *checklogin(const char *user, const char *pass, const char *n
     struct authlogEntry *authlog = authlog_add(hi, NULL, ptr);
     struct pendingLOCUser *pending;
     if(authlog && (pending = malloc(sizeof(*pending)))) {
-        for(ii = 0; ii < COMBO_NUMERIC_LEN; ii++)
-            pending->numeric[ii] = numeric[ii];
-        pending->numeric[COMBO_NUMERIC_LEN] = '\0';
+        pending->handle_info = hi;
         pending->time = now;
         pending->authlog = authlog;
         pending->next = pendingLOCUsers;
@@ -2054,8 +2052,12 @@ static MODCMD_FUNC(cmd_authlog)
         tbl.contents[i][1] = ptr;
         if(authlog->logout_time)
             str = intervalString(intervalBuf, now - authlog->logout_time, hi);
-        else
-            str = (authlog->user ? "Never" : "Unknown");
+        else if(!authlog->user)
+            str = "Unknown";
+        else {
+            sprintf(intervalBuf, "Never (%s)", authlog->user->nick);
+            str = intervalBuf;
+        }
         ptr = malloc(strlen(str)+1);
         strcpy(ptr, str);
         tbl.contents[i][2] = ptr;
@@ -4680,23 +4682,27 @@ nickserv_reclaim_p(void *data) {
 static void
 check_user_nick(struct userNode *user) {
     //check if this user is a pending LOC user
-    struct pendingLOCUser *pending, *next, *prev = NULL;
-    for(pending = pendingLOCUsers; pending; pending = next) {
-        next = pending->next;
-        if(!strcmp(user->numeric, pending->numeric)) {
-            pending->authlog->user = user;
-            if(prev)
-                prev->next = next;
-            else
-                pendingLOCUsers = next;
-            free(pending);
-        }
-        if(now - pending->time > 10) {
-            if(prev)
-                prev->next = next;
-            else
-                pendingLOCUsers = next;
-            free(pending);
+    if(pendingLOCUsers) {
+        struct pendingLOCUser *pending, *next, *prev = NULL;
+        for(pending = pendingLOCUsers; pending; pending = next) {
+            next = pending->next;
+            if(user->handle_info == pending->handle_info) {
+                pending->authlog->user = user;
+                free((char*) pending->authlog->hostmask);
+                pending->authlog->hostmask = generate_hostmask(user, GENMASK_USENICK|GENMASK_STRICT_IDENT|GENMASK_NO_HIDING|GENMASK_STRICT_HOST);
+                if(prev)
+                    prev->next = next;
+                else
+                    pendingLOCUsers = next;
+                free(pending);
+            }
+            if(now - pending->time > 10) {
+                if(prev)
+                    prev->next = next;
+                else
+                    pendingLOCUsers = next;
+                free(pending);
+            }
         }
     }
     struct nick_info *ni;