]> jfr.im git - irc/evilnet/x3.git/commitdiff
Added support for LOC
authorrubin <redacted>
Mon, 18 Oct 2004 07:10:00 +0000 (07:10 +0000)
committerrubin <redacted>
Mon, 18 Oct 2004 07:10:00 +0000 (07:10 +0000)
src/nickserv.c
src/nickserv.h
src/proto-p10.c

index 3b446c068cfecd96f6dfda1ef363c38a35f82a70..3944b46128605cbd114a562cc92e66149e833515 100644 (file)
@@ -1528,6 +1528,48 @@ reg_failpw_func(failpw_func_t func)
     failpw_func_list[failpw_func_used++] = func;
 }
 
+/*
+ * Return 1 if the handle/pass pair matches, 0 if it doesnt.
+ *
+ * called by nefariouses enhanced AC login-on-connect code
+ *
+ */
+int loc_auth(struct userNode *user, char *handle, char *password)
+{
+    int pw_arg, used, maxlogins;
+    struct handle_info *hi;
+    /*
+    struct userNode *other;
+    */
+
+    hi = dict_find(nickserv_handle_dict, handle, NULL);
+        pw_arg = 2;
+    if (!hi) {
+        return 0;
+    }
+    /* Responses from here on look up the language used by the handle they asked about. */
+    if (!checkpass(password, hi->passwd)) {
+        return 0;
+    }
+    if (HANDLE_FLAGGED(hi, SUSPENDED)) {
+        return 0;
+    }
+    maxlogins = hi->maxlogins ? hi->maxlogins : nickserv_conf.default_maxlogins;
+    /*  Do we want to deny if they already have more logins? I dont see why but
+     *  someone else might? -Rubin
+    for (used = 0, other = hi->users; other; other = other->next_authed) {
+        if (++used >= maxlogins) {
+            send_message_type(4, user, cmd->parent->bot,
+                              handle_find_message(hi, "NSMSG_MAX_LOGINS"),
+                              maxlogins);
+            argv[pw_arg] = "MAXLOGINS";
+            return 1;
+        }
+    }
+    */
+    return 1;
+}
+
 static NICKSERV_FUNC(cmd_auth)
 {
     int pw_arg, used, maxlogins;
index 34345e8d2ff8f46cbf68686a60628614e4dca9b2..23bb8287b959b481a7961cfde0e0ccdfb9efab7a 100644 (file)
@@ -128,6 +128,8 @@ int nickserv_modify_handle_flags(struct userNode *user, struct userNode *bot, co
 int oper_has_access(struct userNode *user, struct userNode *bot, unsigned int min_level, unsigned int quiet);
 void nickserv_show_oper_accounts(struct userNode *user, struct svccmd *cmd);
 
+int loc_auth(struct userNode *user, char *handle, char *password);
+
 /* auth_funcs are called when a user gets a new handle_info.  They are
  * called *after* user->handle_info has been updated.  */
 typedef void (*auth_func_t)(struct userNode *user, struct handle_info *old_handle);
index 40b03a60c4fe253a7beac9afd7ad449d82776907..1afd9b5b8fc8eda535ce28ce84248ffbc62704db 100644 (file)
@@ -427,7 +427,7 @@ irc_user(struct userNode *user)
 void
 irc_account(struct userNode *user, const char *stamp)
 {
-    putsock("%s " P10_ACCOUNT " %s %s", self->numeric, user->numeric, stamp);
+    putsock("%s " P10_ACCOUNT " %s %s", self->numeric, user->numeric, stamp);
 }
 
 void
@@ -1042,13 +1042,35 @@ static CMD_FUNC(cmd_nick)
 static CMD_FUNC(cmd_account)
 {
     struct userNode *user;
+    struct server *server;
 
-    if ((argc < 3) || !origin || !GetServerH(origin))
+    if ((argc < 3) || !origin || !(server = GetServerH(origin)))
         return 0; /* Origin must be server. */
+    
+    /* This next line appears to tremple origin.. why? */
     user = GetUserN(argv[1]);
     if (!user)
         return 1; /* A QUIT probably passed the ACCOUNT. */
-    call_account_func(user, argv[2]);
+    
+    if(!strcmp(argv[2],"C"))
+    {
+        if(loc_auth(user, argv[4], argv[5]))
+        {
+            /* Return a AC A */
+            putsock("%s " P10_ACCOUNT " %s A %s", self->numeric, server->numeric , argv[3]);
+
+        }
+        else
+        {
+            /* Return a AC D */
+            putsock("%s " P10_ACCOUNT " %s D %s", self->numeric, server->numeric , argv[3]);
+        }
+        return 1;
+    }
+    else if(!strcmp(argv[2],"R"))
+       call_account_func(user, argv[3]);
+    else
+        call_account_func(user, argv[2]); /* For backward compatability */
     return 1;
 }