]> jfr.im git - irc/evilnet/x3.git/blobdiff - src/nickserv.c
rename sync log support, plus extended p10 accounts support added for rename and...
[irc/evilnet/x3.git] / src / nickserv.c
index fe50e2ceb6d0877622b98df93b4b840156fab360..619e61e9d3d65ff04abf7f38f7845f8ffdf993b8 100644 (file)
@@ -565,23 +565,30 @@ free_handle_info(void *vhi)
 static void set_user_handle_info(struct userNode *user, struct handle_info *hi, int stamp);
 
 static void
-nickserv_unregister_handle(struct handle_info *hi, struct userNode *notify)
+nickserv_unregister_handle(struct handle_info *hi, struct userNode *notify, struct userNode *bot)
 {
     unsigned int n;
+    struct userNode *uNode;
 
     for (n=0; n<unreg_func_used; n++)
         unreg_func_list[n](notify, hi);
-    while (hi->users)
+    while (hi->users) {
+        if (nickserv_conf.sync_log) {
+            uNode = GetUserH(hi->users->nick);
+            if (uNode)
+                irc_delete(uNode);
+        }
         set_user_handle_info(hi->users, NULL, 0);
+    }
     if (notify) {
         if (nickserv_conf.disable_nicks)
-            send_message(notify, nickserv, "NSMSG_UNREGISTER_SUCCESS", hi->handle);
+            send_message(notify, bot, "NSMSG_UNREGISTER_SUCCESS", hi->handle);
         else
-            send_message(notify, nickserv, "NSMSG_UNREGISTER_NICKS_SUCCESS", hi->handle);
+            send_message(notify, bot, "NSMSG_UNREGISTER_NICKS_SUCCESS", hi->handle);
     }
 
     if (nickserv_conf.sync_log)
-      SyncLog("UNREGISTER %s", hi->handle);
+        SyncLog("UNREGISTER %s", hi->handle);
 
     dict_remove(nickserv_handle_dict, hi->handle);
 }
@@ -906,6 +913,17 @@ apply_fakehost(struct handle_info *handle)
         assign_fakehost(target, fake, 1);
 }
 
+void send_func_list(struct userNode *user)
+{
+    unsigned int n;
+    struct handle_info *old_info;
+
+    old_info = user->handle_info;
+
+    for (n=0; n<auth_func_used; n++)
+        auth_func_list[n](user, old_info);
+}
+
 static void
 set_user_handle_info(struct userNode *user, struct handle_info *hi, int stamp)
 {
@@ -949,7 +967,8 @@ set_user_handle_info(struct userNode *user, struct handle_info *hi, int stamp)
     if (GetUserH(user->nick)) {
         for (n=0; n<auth_func_used; n++)
             auth_func_list[n](user, old_info);
-    }
+    } else
+      user->loc = 1;
 
     if (hi) {
         struct nick_info *ni;
@@ -1330,7 +1349,7 @@ static NICKSERV_FUNC(cmd_register)
     if (nickserv_conf.sync_log) {
       cryptpass(password, syncpass);
       /*
-       * An 0 is only sent if theres no email address. Thios should only happen if email functions are
+      * An 0 is only sent if theres no email address. Thios should only happen if email functions are
        * disabled which they wont be for us. Email Required MUST be set on if you are using this.
        * -SiRVulcaN
        */
@@ -1601,6 +1620,7 @@ static NICKSERV_FUNC(cmd_nickinfo)
 static NICKSERV_FUNC(cmd_rename_handle)
 {
     struct handle_info *hi;
+    struct userNode *uNode;
     char msgbuf[MAXLEN], *old_handle;
     unsigned int nn;
 
@@ -1627,6 +1647,15 @@ static NICKSERV_FUNC(cmd_rename_handle)
     for (nn=0; nn<rf_list_used; nn++)
         rf_list[nn](hi, old_handle);
     snprintf(msgbuf, sizeof(msgbuf), "%s renamed account %s to %s.", user->handle_info->handle, old_handle, hi->handle);
+
+
+    if (nickserv_conf.sync_log) {
+        for (uNode = hi->users; uNode; uNode = uNode->next_authed)
+            irc_rename(uNode, hi->handle);
+
+        SyncLog("RENAME %s %s", hi->handle);
+    }
+
     reply("NSMSG_HANDLE_CHANGED", old_handle, hi->handle);
     global_message(MESSAGE_RECIPIENT_STAFF, msgbuf);
     free(old_handle);
@@ -2857,7 +2886,7 @@ static NICKSERV_FUNC(cmd_unregister)
     passwd = argv[1];
     argv[1] = "****";
     if (checkpass(passwd, hi->passwd)) {
-        nickserv_unregister_handle(hi, user);
+        nickserv_unregister_handle(hi, user, cmd->parent->bot);
         return 1;
     } else {
        log_module(NS_LOG, LOG_INFO, "Account '%s' tried to unregister with the wrong password.", hi->handle);
@@ -2873,7 +2902,7 @@ static NICKSERV_FUNC(cmd_ounregister)
     NICKSERV_MIN_PARMS(2);
     if (!(hi = get_victim_oper(user, argv[1])))
         return 0;
-    nickserv_unregister_handle(hi, user);
+    nickserv_unregister_handle(hi, user, cmd->parent->bot);
     return 1;
 }
 
@@ -3152,7 +3181,7 @@ static NICKSERV_FUNC(cmd_merge)
     global_message(MESSAGE_RECIPIENT_STAFF, buffer);
 
     /* Unregister the "from" handle. */
-    nickserv_unregister_handle(hi_from, NULL);
+    nickserv_unregister_handle(hi_from, NULL, cmd->parent->bot);
 
     return 1;
 }
@@ -3375,7 +3404,7 @@ static void
 search_unregister_func (struct userNode *source, struct handle_info *match)
 {
     if (oper_has_access(source, nickserv, match->opserv_level, 0))
-        nickserv_unregister_handle(match, source);
+        nickserv_unregister_handle(match, source, nickserv); // XXX nickserv hard coded
 }
 
 static int
@@ -3670,7 +3699,7 @@ expire_handles(UNUSED_ARG(void *data))
         expiry = hi->channels ? nickserv_conf.handle_expire_delay : nickserv_conf.nochan_handle_expire_delay;
         if ((now - hi->lastseen) > expiry) {
             log_module(NS_LOG, LOG_INFO, "Expiring account %s for inactivity.", hi->handle);
-            nickserv_unregister_handle(hi, NULL);
+            nickserv_unregister_handle(hi, NULL, NULL);
         }
     }