]> jfr.im git - irc/evilnet/x3.git/blobdiff - src/nickserv.c
fixing delpeon bug
[irc/evilnet/x3.git] / src / nickserv.c
index 550d8b1bddbc49b4fe84c51c0d170cff451c178c..e189e7778e067b939e6a2bf422aa7f63df38f8b3 100644 (file)
@@ -984,10 +984,8 @@ set_user_handle_info(struct userNode *user, struct handle_info *hi, int stamp)
     if (hi && !hi->users && !hi->opserv_level)
         HANDLE_CLEAR_FLAG(hi, HELPING);
 
-    if (GetUserH(user->nick)) {
-        for (n=0; n<auth_func_used; n++)
-            auth_func_list[n](user, old_info);
-    } else
+    /* Call auth handlers */
+    if (!GetUserH(user->nick))
       user->loc = 1;
 
     if (hi) {
@@ -1000,12 +998,15 @@ set_user_handle_info(struct userNode *user, struct handle_info *hi, int stamp)
                 send_message(other, nickserv, "NSMSG_CLONE_AUTH", user->nick, user->ident, user->hostname);
         }
 
+        /* Add this auth to users list of current auths */
        user->next_authed = hi->users;
        hi->users = user;
        hi->lastseen = now;
+        /* Add to helpers list */
        if (IsHelper(user))
             userList_append(&curr_helpers, user);
 
+        /* Set the fakehost */
         if (hi->fakehost || old_info)
             apply_fakehost(hi);
 
@@ -1016,6 +1017,9 @@ set_user_handle_info(struct userNode *user, struct handle_info *hi, int stamp)
 #else
             const char *id = "???";
 #endif
+            /* Mark all the nicks registered to this
+             * account as registered nicks 
+             *  -  Why not just this one? -rubin */
             if (!nickserv_conf.disable_nicks) {
                 struct nick_info *ni;
                 for (ni = hi->nicks; ni; ni = ni->next) {
@@ -1025,15 +1029,23 @@ set_user_handle_info(struct userNode *user, struct handle_info *hi, int stamp)
                     }
                 }
             }
+            /* send the account to the ircd */
             StampUser(user, id, hi->registered);
         }
 
+        /* Stop trying to kick this user off their nick */
         if ((ni = get_nick_info(user->nick)) && (ni->owner == hi))
             timeq_del(0, nickserv_reclaim_p, user, TIMEQ_IGNORE_WHEN);
     } else {
         /* We cannot clear the user's account ID, unfortunately. */
        user->next_authed = NULL;
     }
+
+    /* Call auth handlers */
+    if (GetUserH(user->nick)) {
+        for (n=0; n<auth_func_used; n++)
+            auth_func_list[n](user, old_info);
+    }
 }
 
 static struct handle_info*
@@ -2168,6 +2180,32 @@ static NICKSERV_FUNC(cmd_odelcookie)
         return 0;
     }
 
+    switch (hi->cookie->type) {
+    case ACTIVATION:
+        safestrncpy(hi->passwd, hi->cookie->data, sizeof(hi->passwd));
+        if (nickserv_conf.sync_log)
+          SyncLog("ACCOUNTACC %s", hi->handle);
+        break;
+    case PASSWORD_CHANGE:
+        safestrncpy(hi->passwd, hi->cookie->data, sizeof(hi->passwd));
+        if (nickserv_conf.sync_log)
+          SyncLog("PASSCHANGE %s %s", hi->handle, hi->passwd);
+        break;
+    case EMAIL_CHANGE:
+        if (!hi->email_addr && nickserv_conf.sync_log) {
+          if (nickserv_conf.sync_log)
+            SyncLog("REGISTER %s %s %s %s", hi->handle, hi->passwd, hi->cookie->data, user->info);
+        }
+        nickserv_set_email_addr(hi, hi->cookie->data);
+        if (nickserv_conf.sync_log)
+          SyncLog("EMAILCHANGE %s %s", hi->handle, hi->cookie->data);
+        break;
+    default:
+        reply("NSMSG_BAD_COOKIE_TYPE", hi->cookie->type);
+        log_module(NS_LOG, LOG_ERROR, "Bad cookie type %d for account %s.", hi->cookie->type, hi->handle);
+        break;
+    }
+
     nickserv_eat_cookie(hi->cookie);
     reply("NSMSG_ATE_FOREIGN_COOKIE", hi->handle);
 
@@ -2972,20 +3010,27 @@ static OPTION_FUNC(opt_title)
         title = hi->fakehost + 1;
     else {
         /* If theres no title set then the default title will therefore
-           be the first part of hidden_host in x3.conf.example, so for
-           consistency with opt_fakehost we will print this here */
+           be the first part of hidden_host in x3.conf, so for
+           consistency with opt_fakehost we will print this here.
+           This isnt actually used in P10, its just handled to keep from crashing... */
         char *hs, *hidden_suffix, *rest;
 
         hs = conf_get_data("server/hidden_host", RECDB_QSTRING);
         hidden_suffix = strdup(hs);
 
         /* Yes we do this twice */
-        rest = strrchr(hidden_suffix, '.');
-        *rest++ = '\0';
-        rest = strrchr(hidden_suffix, '.');
-        *rest++ = '\0';
+        if((rest = strchr(hidden_suffix, '.')))
+        {
+            *rest = '\0';
+            title = hidden_suffix;
+        }
+        else
+        {
+            /* A lame default if someone configured hidden_host to something lame */
+            title = strdup("users");
+            free(hidden_suffix);
+        }
 
-        title = hidden_suffix;
     }
 
     if (!title)