]> jfr.im git - irc/quakenet/newserv.git/commitdiff
Various changes to support authname being stored inside the authext.
authorChris Porter <redacted>
Thu, 7 Aug 2008 00:58:41 +0000 (01:58 +0100)
committerChris Porter <redacted>
Thu, 7 Aug 2008 00:58:41 +0000 (01:58 +0100)
Q and ticketauth now send authflags.

12 files changed:
chanserv/Makefile.in
chanserv/authcmds/login.c
chanserv/chanserv.c
chanserv/chanserv.h
chanserv/chanserv_flags.c [new file with mode: 0644]
chanserv/usercmds/userflags.c
localuser/localuser.c
localuser/localuser.h
nick/nick.c
nick/nick.h
nick/nickhandlers.c
ticketauth/ticketauth.c

index f17b0447780e15cabc6796ca95918a8436259f08..c41221d6a4da52fc92b1074dc0ad60aa287297d5 100644 (file)
@@ -4,7 +4,7 @@
 CSDIRS=database chancmds usercmds authcmds authtracker newsearch
 
 .PHONY: all dirs $(CSDIRS) clean
-all: chanserv.so chanserv_protect.so chanserv_grep.so chanserv_relay.so dirs
+all: chanserv.so chanserv_protect.so chanserv_grep.so chanserv_relay.so chanserv_flags.so dirs
 
 dirs: $(CSDIRS)
        ln -sf */*.so .
@@ -27,3 +27,4 @@ chanserv_grep.so: chanserv_grep.o
 
 chanserv_relay.so: chanserv_relay.o
 
+chanserv_flags.so: chanserv_flags.o
index a12bcbdd3e0ba61718e264ce48a1a1bb3d347bb7..9599de10732400e62cd812a8912b2938cb69486b 100644 (file)
@@ -138,7 +138,8 @@ int csa_auth(void *source, int cargc, char **cargv, CRAlgorithm alg) {
   chanservstdmessage(sender, QM_AUTHOK, rup->username);
 
   cs_log(sender,"%s OK username %s", authtype,rup->username);
-  localusersetaccountflags(sender, rup->username, rup->ID, 0, rup->lastauth);
+
+  localusersetaccount(sender, rup->username, rup->ID, cs_accountflagmap(rup), rup->lastauth);
 
   return CMD_OK;
 }
index 1ed71168d8f76ee6330d6127692143b9b53e6304..09bcd4254abd309aa86fb9c0db89a19f98748cd9 100644 (file)
@@ -18,67 +18,6 @@ int chanserv_init_status;
 sstring **chantypes;
 sstring *cs_quitreason;
 
-const flag rcflags[] = {
-  { 'a', QCFLAG_AUTOOP },
-  { 'b', QCFLAG_BITCH },
-  { 'c', QCFLAG_AUTOLIMIT },
-  { 'e', QCFLAG_ENFORCE },
-  { 'f', QCFLAG_FORCETOPIC },
-  { 'g', QCFLAG_AUTOVOICE },
-  { 'i', QCFLAG_INFO },
-  { 'j', QCFLAG_JOINED },
-  { 'k', QCFLAG_KNOWNONLY },
-  { 'p', QCFLAG_PROTECT },
-  { 's', QCFLAG_NOINFO },
-  { 't', QCFLAG_TOPICSAVE },
-  { 'v', QCFLAG_VOICEALL },
-  { 'w', QCFLAG_WELCOME },
-  { 'z', QCFLAG_SUSPENDED },
-  { '\0', 0 } };   
-
-const flag rcuflags[] = {
-  { 'a', QCUFLAG_AUTOOP },
-  { 'b', QCUFLAG_BANNED },
-  { 'd', QCUFLAG_DENY },
-  { 'g', QCUFLAG_AUTOVOICE },
-  { 'i', QCUFLAG_INFO },
-  { 'j', QCUFLAG_AUTOINVITE },
-  { 'k', QCUFLAG_KNOWN },
-  { 'm', QCUFLAG_MASTER },
-  { 'n', QCUFLAG_OWNER },
-  { 'o', QCUFLAG_OP },
-  { 'p', QCUFLAG_PROTECT },
-  { 'q', QCUFLAG_QUIET },
-  { 's', QCUFLAG_NOINFO },
-  { 't', QCUFLAG_TOPIC },
-  { 'v', QCUFLAG_VOICE },
-  { 'w', QCUFLAG_HIDEWELCOME },
-  { '\0', 0 } };
-
-const flag ruflags[] = {
-  { 'a',  QUFLAG_ADMIN },
-  { 'd',  QUFLAG_DEV },
-  { 'D',  QUFLAG_CLEANUPEXEMPT },
-  { 'g',  QUFLAG_GLINE },
-  { 'G',  QUFLAG_DELAYEDGLINE },
-  { 'h',  QUFLAG_HELPER },
-  { 'i',  QUFLAG_INFO },
-  { 'L',  QUFLAG_NOAUTHLIMIT },
-  { 'n',  QUFLAG_NOTICE },
-  { 'o',  QUFLAG_OPER },
-  { 'p',  QUFLAG_PROTECT },
-  { 'q',  QUFLAG_STAFF },
-  { 's',  QUFLAG_NOINFO },
-  { 'T',  QUFLAG_TRUST },
-  { 'z',  QUFLAG_SUSPENDED },
-  { '\0', 0 } };
-
-const flag mdflags[] = {
-  { 'l', MDFLAG_LIMIT },
-  { 'b', MDFLAG_BANNED },
-  { 'u', MDFLAG_ACTLIMIT },
-  { '\0', 0 } };
-
 void chanservfreestuff();
 void chanservfinishinit(int hooknum, void *arg);
 
index 6aa48a2ca04718bf71f56727a0e043983a7aaf28..8b0d8b8455462066435bf6429915b78a0ebf0d09 100644 (file)
@@ -895,4 +895,9 @@ void csdb_updatemaillock(maillock *mlp);
 /* q9snprintf.c */
 void q9snprintf(char *buf, size_t size, const char *format, const char *args, ...);
 void q9vsnprintf(char *buf, size_t size, const char *format, const char *args, va_list ap);
+
+/* chanserv_flags.c */
+flag_t cs_accountflagmap(reguser *rup);
+flag_t cs_accountflagmap_str(char *flags);
+
 #endif
diff --git a/chanserv/chanserv_flags.c b/chanserv/chanserv_flags.c
new file mode 100644 (file)
index 0000000..0836f48
--- /dev/null
@@ -0,0 +1,93 @@
+#include "../chanserv/chanserv.h"
+
+const flag rcflags[] = {
+  { 'a', QCFLAG_AUTOOP },
+  { 'b', QCFLAG_BITCH },
+  { 'c', QCFLAG_AUTOLIMIT },
+  { 'e', QCFLAG_ENFORCE },
+  { 'f', QCFLAG_FORCETOPIC },
+  { 'g', QCFLAG_AUTOVOICE },
+  { 'i', QCFLAG_INFO },
+  { 'j', QCFLAG_JOINED },
+  { 'k', QCFLAG_KNOWNONLY },
+  { 'p', QCFLAG_PROTECT },
+  { 's', QCFLAG_NOINFO },
+  { 't', QCFLAG_TOPICSAVE },
+  { 'v', QCFLAG_VOICEALL },
+  { 'w', QCFLAG_WELCOME },
+  { 'z', QCFLAG_SUSPENDED },
+  { '\0', 0 } };
+
+const flag rcuflags[] = {
+  { 'a', QCUFLAG_AUTOOP },
+  { 'b', QCUFLAG_BANNED },
+  { 'd', QCUFLAG_DENY },
+  { 'g', QCUFLAG_AUTOVOICE },
+  { 'i', QCUFLAG_INFO },
+  { 'j', QCUFLAG_AUTOINVITE },
+  { 'k', QCUFLAG_KNOWN },
+  { 'm', QCUFLAG_MASTER },
+  { 'n', QCUFLAG_OWNER },
+  { 'o', QCUFLAG_OP },
+  { 'p', QCUFLAG_PROTECT },
+  { 'q', QCUFLAG_QUIET },
+  { 's', QCUFLAG_NOINFO },
+  { 't', QCUFLAG_TOPIC },
+  { 'v', QCUFLAG_VOICE },
+  { 'w', QCUFLAG_HIDEWELCOME },
+
+  { '\0', 0 } };
+
+const flag ruflags[] = {
+  { 'a',  QUFLAG_ADMIN },
+  { 'd',  QUFLAG_DEV },
+  { 'D',  QUFLAG_CLEANUPEXEMPT },
+  { 'g',  QUFLAG_GLINE },
+  { 'G',  QUFLAG_DELAYEDGLINE },
+  { 'h',  QUFLAG_HELPER },
+  { 'i',  QUFLAG_INFO },
+  { 'L',  QUFLAG_NOAUTHLIMIT },
+  { 'n',  QUFLAG_NOTICE },
+  { 'o',  QUFLAG_OPER },
+  { 'p',  QUFLAG_PROTECT },
+  { 'q',  QUFLAG_STAFF },
+  { 's',  QUFLAG_NOINFO },
+  { 'T',  QUFLAG_TRUST },
+  { 'z',  QUFLAG_SUSPENDED },
+  { '\0', 0 } };
+
+const flag mdflags[] = {
+  { 'l', MDFLAG_LIMIT },
+  { 'b', MDFLAG_BANNED },
+  { 'u', MDFLAG_ACTLIMIT },
+  { '\0', 0 } };
+
+flag_t cs_accountflagmap(reguser *rup) {
+  authname a2, *a = &a2;
+  a->flags = 0;
+
+  if(UIsOper(rup))
+    SetOperFlag(a);
+
+  if(UIsDev(rup))
+    SetDeveloper(a);
+
+  if(UIsAdmin(rup))
+    SetAdmin(a);
+
+  if(UIsStaff(rup))
+    SetStaff(a);
+
+  if(UIsHelper(rup))
+    SetSupport(a);
+
+  return a->flags;
+}
+
+flag_t cs_accountflagmap_str(char *flags) {
+  reguser r2, *r = &r2;
+
+  setflags(&r->flags, QUFLAG_ALL, flags, ruflags, REJECT_NONE);
+
+  return cs_accountflagmap(r);
+}
index e29ec6406a8ef61f8b2ca4cdac71feb3dcc01422..d1e4d940983536d00b92fdb4d08d3e2377c2488e 100644 (file)
@@ -23,6 +23,7 @@
 int csu_douserflags(void *source, int cargc, char **cargv) {
   nick *sender=source;
   reguser *rup=getreguserfromnick(sender), *target;
+  authname *anp;
   int arg=0, wasorisoper;
   flag_t flagmask, changemask, oldflags;
   char flagbuf[30];
@@ -95,6 +96,10 @@ int csu_douserflags(void *source, int cargc, char **cargv) {
 #endif
     }
     csdb_updateuser(target);
+
+    if ((anp=findauthname(rup->ID)))
+      localusersetaccountflags(anp, cs_accountflagmap(target));
+
     chanservstdmessage(sender, QM_DONE);
   }
 
index 518c8aa4f047847bbd01ea1180f343f62b12c54b..a32c602123fa495687df198c6b7b141f6dc314a5 100644 (file)
@@ -100,7 +100,7 @@ nick *registerlocaluserflags(char *nickname, char *ident, char *host, char *real
   newuser->nextbyrealname=newuser->realname->nicks;
   newuser->realname->nicks=newuser;
   newuser->umodes=umodes;
-  
+
   memset(&ipaddress, 0, sizeof(ipaddress));
   ((unsigned short *)(ipaddress.in6_16))[5] = 65535;
   ((unsigned short *)(ipaddress.in6_16))[6] = 127;
@@ -121,24 +121,31 @@ nick *registerlocaluserflags(char *nickname, char *ident, char *host, char *real
   } else {
     newuser->opername = NULL;
   }
+
+  newuser->accountts=0;
+  newuser->auth=NULL;
+  newuser->authname=NULL;  
   if (IsAccount(newuser)) {
-    strncpy(newuser->authname,authname,ACCOUNTLEN);
     newuser->accountts=newuser->timestamp;
     if (authid) {
-      newuser->auth=findorcreateauthname(authid, newuser->authname);
+      newuser->auth=findorcreateauthname(authid, authname);
+      newuser->authname=newuser->auth->name;
       newuser->auth->usercount++;
       newuser->nextbyauthname=newuser->auth->nicks;
       newuser->auth->nicks=newuser;
       newuser->auth->flags=accountflags;
     } else {
-      newuser->auth=NULL;
+      /*
+         this is done for three reasons:
+         1: so I don't have to change 500 pieces of code
+         2: so services can be authed with special reserved ids
+         3: saves space over the old authname per user method
+       */
+      newuser->authname=malloc(strlen(authname) + 1);
+      strcpy(newuser->authname,authname);
     }
-  } else {
-    newuser->authname[0]='\0';
-    newuser->accountts=0;
-    newuser->auth=NULL;
   }
-  
+
   if (connected) {
     /* Check for nick collision */
     if ((np=getnickbynick(nickname))!=NULL) {
@@ -276,6 +283,7 @@ void sendnickmsg(nick *np) {
     operbuf[0] = '\0';
   }
 
+  accountbuf[0]='\0';
   if (IsAccount(np)) {
     if (np->auth) {
       if(np->auth->flags) {
@@ -283,11 +291,9 @@ void sendnickmsg(nick *np) {
       } else {
         snprintf(accountbuf,sizeof(accountbuf)," %s:%ld:%lu",np->authname,np->accountts,np->auth->userid);
       }
-    } else {
+    } else if(np->authname) {
       snprintf(accountbuf,sizeof(accountbuf)," %s:%ld:0",np->authname,np->accountts);
     }
-  } else {
-    accountbuf[0]='\0';
   }
 
   irc_send("%s N %s 1 %ld %s %s %s%s%s %s %s :%s",
@@ -554,39 +560,44 @@ void checkpendingkills(int hooknum, void *arg) {
   }
 }
 
-/* Auth user */
-void localusersetaccountflags(nick *np, char *accname, unsigned long accid, flag_t accountflags, time_t authTS) {
+void sendaccountmessage(nick *np) {
+  if (connected) {
+    if (np->auth) {
+      if (np->auth->flags) {
+        irc_send("%s AC %s %s %ld %lu %lu",mynumeric->content, longtonumeric(np->numeric,5), np->authname, np->accountts, np->auth->userid, np->auth->flags);
+      } else {
+        irc_send("%s AC %s %s %ld %lu",mynumeric->content, longtonumeric(np->numeric,5), np->authname, np->accountts, np->auth->userid);
+      }
+    } else {
+      irc_send("%s AC %s %s %ld 0",mynumeric->content, longtonumeric(np->numeric,5), np->authname, np->accountts);
+    }
+  }
+}
+
+/* Auth user, don't use to set flags after authing */
+void localusersetaccount(nick *np, char *accname, unsigned long accid, flag_t accountflags, time_t authTS) {
   if (IsAccount(np)) {
     Error("localuser",ERR_WARNING,"Tried to set account on user %s already authed", np->nick);
     return;
   }
 
   SetAccount(np);
-  strncpy(np->authname, accname, ACCOUNTLEN);
-  np->authname[ACCOUNTLEN]='\0';
   np->accountts=authTS?authTS:getnettime();
 
   if (accid) {
     np->auth=findorcreateauthname(accid, accname);
     np->auth->usercount++;
+    np->authname=np->auth->name;
     np->nextbyauthname=np->auth->nicks;
     np->auth->nicks=np;
     np->auth->flags=accountflags;
   } else {
     np->auth=NULL;
+    np->authname=malloc(strlen(accname) + 1);
+    strcpy(np->authname,accname);
   }
 
-  if (connected) {
-    if (np->auth) {
-      if (np->auth->flags) {
-        irc_send("%s AC %s %s %ld %lu %lu",mynumeric->content, longtonumeric(np->numeric,5), np->authname, np->accountts, np->auth->userid, np->auth->flags);
-      } else {
-        irc_send("%s AC %s %s %ld %lu",mynumeric->content, longtonumeric(np->numeric,5), np->authname, np->accountts, np->auth->userid);
-      }
-    } else {
-      irc_send("%s AC %s %s %ld 0",mynumeric->content, longtonumeric(np->numeric,5), np->authname, np->accountts);
-    }
-  }
+  sendaccountmessage(np);
 
   triggerhook(HOOK_NICK_ACCOUNT, np);
 }
@@ -598,3 +609,17 @@ void localusersetumodes(nick *np, flag_t newmodes) {
 
   np->umodes = newmodes;
 }
+
+void localusersetaccountflags(authname *anp, flag_t accountflags) {
+  void *arg[2];
+  nick *np;
+
+  arg[0] = (void *)anp;
+  arg[1] = (void *)(long)anp->flags;
+  anp->flags = accountflags;
+
+  for(np=anp->nicks;np;np=np->next)
+    sendaccountmessage(np);
+
+  triggerhook(HOOK_AUTH_FLAGSUPDATED, arg);  
+}
index 6b3b078e5395262ca78ce696268f3665d8e5b327..2227a7f1523cecca397924cccef2d558c8b56c30 100644 (file)
@@ -37,9 +37,9 @@ void sendmessagetouser(nick *source, nick *target, char *format, ... );
 void sendsecuremessagetouser(nick *source, nick *target, char *servername, char *format, ... );
 void sendnoticetouser(nick *source, nick *target, char *format, ... );
 void killuser(nick *source, nick *target, char *format, ... );
-#define localusersetaccount(np, accname) localusersetaccountflags(np, accname, 0)
-void localusersetaccountflags(nick *np, char *accname, unsigned long accid, flag_t accountflags, time_t authTS);
+void localusersetaccount(nick *np, char *accname, unsigned long accid, flag_t accountflags, time_t authTS);
 void localusersetumodes(nick *np, flag_t newmodes);
 void sethostuser(nick *target, char *ident, char *host);
+void localusersetaccountflags(authname *anp, flag_t accountflags);
 
 #endif
index 809a41d331b2c05a005b077bab6697127a64e130..bc2b3db07bf77a2c2c60e9192fd29c99483ea2bc 100644 (file)
@@ -39,7 +39,7 @@ const flag umodeflags[] = {
 
 const flag accountflags[] = {
    { 'q', AFLAG_STAFF },
-   { 's', AFLAG_SUPPORT },
+   { 'h', AFLAG_SUPPORT },
    { 'o', AFLAG_OPER },
    { 'a', AFLAG_ADMIN },
    { 'd', AFLAG_DEVELOPER },
@@ -98,6 +98,8 @@ void _fini() {
       freesstring(np->shident);
       freesstring(np->sethost);
       freesstring(np->opername);
+      if(!np->auth && np->authname)
+        free(np->authname);
     }
   }
 
@@ -179,18 +181,22 @@ void deletenick(nick *np) {
   releaserealname(np->realname);
   releasehost(np->host);
   
-  if(IsAccount(np) && np->auth)
-  {
-    np->auth->usercount--;
+  if(IsAccount(np)) {
+    if(!np->auth) {
+      if(np->authname)
+        free(np->authname);
+    } else {
+      np->auth->usercount--;
     
-    for (nh=&(np->auth->nicks);*nh;nh=&((*nh)->nextbyauthname)) {
-      if (*nh==np) {
-        *nh=np->nextbyauthname;
-        break;
+      for (nh=&(np->auth->nicks);*nh;nh=&((*nh)->nextbyauthname)) {
+        if (*nh==np) {
+          *nh=np->nextbyauthname;
+          break;
+        }
       }
-    }
     
-    releaseauthname(np->auth);
+      releaseauthname(np->auth);
+    }
   }
   
   freesstring(np->shident); /* freesstring(NULL) is OK */
index 9076c7ad1523272a15a4000d51b7d61cebf6fab7..c24c0089f087021267512d7a4d8264eccd63ac99 100644 (file)
 #define ClearHideIdle(x)     ((x)->umodes &= ~UMODE_HIDEIDLE)
 #define ClearParanoid(x)     ((x)->umodes &= ~UMODE_PARANOID)
 
-#define IsStaff(x)           ((x)->umodes & AFLAG_STAFF)
-#define IsDeveloper(x)       ((x)->umodes & AFLAG_DEVELOPER)
-#define IsSupport(x)         ((x)->umodes & AFLAG_SUPPORT)
-#define IsAdmin(x)           ((x)->umodes & AFLAG_ADMIN)
-#define IsOperFlag(x)        ((x)->umodes & AFLAG_OPER)
-
-#define SetStaff(x)          ((x)->umodes |= AFLAG_STAFF)
-#define SetDeveloper(x)      ((x)->umodes |= AFLAG_DEVELOPER)
-#define SetSupport(x)        ((x)->umodes |= AFLAG_SUPPORT)
-#define SetAdmin(x)          ((x)->umodes |= AFLAG_ADMIN)
-#define SetOperFlag(x)       ((x)->umodes |= AFLAG_OPER)
-
-#define ClearStaff(x)        ((x)->umodes &= ~AFLAG_STAFF)
-#define ClearDeveloper(x)    ((x)->umodes &= ~AFLAG_DEVELOPER)
-#define ClearSupport(x)      ((x)->umodes &= ~AFLAG_SUPPORT)
-#define ClearAdmin(x)        ((x)->umodes &= ~AFLAG_ADMIN)
-#define ClearOperFlag(x)     ((x)->umodes &= ~AFLAG_OPER)
+#define IsStaff(x)           ((x)->flags & AFLAG_STAFF)
+#define IsDeveloper(x)       ((x)->flags & AFLAG_DEVELOPER)
+#define IsSupport(x)         ((x)->flags & AFLAG_SUPPORT)
+#define IsAdmin(x)           ((x)->flags & AFLAG_ADMIN)
+#define IsOperFlag(x)        ((x)->flags & AFLAG_OPER)
+
+#define SetStaff(x)          ((x)->flags |= AFLAG_STAFF)
+#define SetDeveloper(x)      ((x)->flags |= AFLAG_DEVELOPER)
+#define SetSupport(x)        ((x)->flags |= AFLAG_SUPPORT)
+#define SetAdmin(x)          ((x)->flags |= AFLAG_ADMIN)
+#define SetOperFlag(x)       ((x)->flags |= AFLAG_OPER)
+
+#define ClearStaff(x)        ((x)->flags &= ~AFLAG_STAFF)
+#define ClearDeveloper(x)    ((x)->flags &= ~AFLAG_DEVELOPER)
+#define ClearSupport(x)      ((x)->flags &= ~AFLAG_SUPPORT)
+#define ClearAdmin(x)        ((x)->flags &= ~AFLAG_ADMIN)
+#define ClearOperFlag(x)     ((x)->flags &= ~AFLAG_OPER)
 
 typedef struct host {
   sstring *name;
@@ -134,7 +134,7 @@ typedef struct nick {
   sstring *sethost;
   sstring *opername;
   flag_t umodes;
-  char authname[ACCOUNTLEN+1];
+  char *authname;
   authname *auth; /* This requires User ID numbers to work */
   time_t timestamp;
   time_t accountts;
index 8d78e8d7dd275ca628749423d6fad27d203277f3..7118601e83496831a92796c57740131b63726b81 100644 (file)
@@ -148,7 +148,7 @@ int handlenickmsg(void *source, int cargc, char **cargv) {
     np->umodes=0;
     np->marker=0;
     memset(np->exts, 0, MAXNICKEXTS * sizeof(void *));
-    np->authname[0]='\0';
+    np->authname=NULL;
     np->auth=NULL;
     np->accountts=0;
     if(cargc>=9) {
@@ -167,24 +167,22 @@ int handlenickmsg(void *source, int cargc, char **cargv) {
         sethostarg++;
 
         if ((accountts=strchr(cargv[accountarg],':'))) {
-          time_t accountts_t=strtoul(accountts,&accountid,10)
           *accountts++='\0';
+          np->accountts=strtoul(accountts,&accountid,10);
           if(accountid) {
-            strncpy(np->authname,cargv[accountarg],ACCOUNTLEN);
-            np->authname[ACCOUNTLEN]='\0';
-            np->accountts=accountts_t;
-
             userid=strtoul(accountid + 1,&accountflags,10);
-            if(!userid) {
-              np->auth=NULL;
-            } else {
+            if(userid) {
               np->auth=findorcreateauthname(userid, cargv[accountarg]);
+              np->authname=np->auth->name;
               np->auth->usercount++;
               np->nextbyauthname=np->auth->nicks;
               np->auth->nicks=np;
               if(accountflags)
                 np->auth->flags=strtoul(accountflags + 1,NULL,10);
             }
+          } else {
+            np->authname=malloc(strlen(cargv[accountarg]) + 1);
+            strcpy(np->authname,cargv[accountarg]);
           }
         }        
       } 
@@ -400,14 +398,14 @@ int handleaccountmsg(void *source, int cargc, char **cargv) {
   
   accountts=strtoul(cargv[2],NULL,10);
   userid=strtoul(cargv[3],NULL,10);
-  if(cargv>=5)
+  if(cargc>=5)
     accountflags=strtoul(cargv[4],NULL,10);
 
   /* allow user flags to change if all fields match */
   if (IsAccount(target)) {
     void *arg[2];
 
-    if (!target->auth || strcmp(target->authname,cargv[1]) || (target->auth->userid != userid) || (target->accountts != accountts)) {
+    if (!target->auth || strcmp(target->auth->name,cargv[1]) || (target->auth->userid != userid) || (target->accountts != accountts)) {
       return CMD_OK;
     }
 
@@ -424,15 +422,16 @@ int handleaccountmsg(void *source, int cargc, char **cargv) {
   }
   
   SetAccount(target);
-  strncpy(target->authname,cargv[1],ACCOUNTLEN);
-  target->authname[ACCOUNTLEN]='\0';
   target->accountts=accountts;
 
   if(!userid) {
     target->auth=NULL;
+    target->authname=malloc(strlen(cargv[1]) + 1);
+    strcpy(target->authname,cargv[1]);
   } else {
     target->auth=findorcreateauthname(userid, target->authname);
     target->auth->usercount++;
+    target->authname=target->auth->name;
     target->nextbyauthname = target->auth->nicks;
     target->auth->nicks = target;
     if (cargc>=5)
index dd24e5ec97e935d66e6d62ab20c93ad604e67e47..99de12603af4ebd7ed6fe74eb5c5dbb154d5a408 100644 (file)
@@ -13,6 +13,7 @@
 #include "../localuser/localuser.h"
 #include "../core/hooks.h"
 #include "../irc/irc.h"
+#include "../chanserv/chanserv.h"
 
 #define WARN_CHANNEL "#twilightzone"
 
@@ -22,7 +23,7 @@ sstring *sharedsecret = NULL;
 
 int ta_ticketauth(void *source, int cargc, char **cargv) {
   nick *np = (nick *)source;
-  char buffer[1024], *uhmac, *acc, *junk;
+  char buffer[1024], *uhmac, *acc, *junk, *flags;
   unsigned char digest[32];
   int expiry, acclen, id;
   hmacsha256 hmac;
@@ -33,15 +34,16 @@ int ta_ticketauth(void *source, int cargc, char **cargv) {
     return CMD_ERROR;
   }
 
-  if(cargc != 5)
+  if(cargc != 6)
     return CMD_USAGE;
 
   acc = cargv[0];
   expiry = atoi(cargv[1]);
   id = atoi(cargv[2]);
   acclen = strlen(acc);
-  junk = cargv[3];
-  uhmac = cargv[4];
+  flags = cargv[3];
+  junk = cargv[4];
+  uhmac = cargv[5];
 
   if((acclen <= 1) || (acclen > ACCOUNTLEN)) {
     controlreply(np, "Bad account.");
@@ -76,7 +78,7 @@ int ta_ticketauth(void *source, int cargc, char **cargv) {
 
   controlreply(np, "Ticket valid, authing. . .");
 
-  localusersetaccountflags(np, acc, id, 0, 0);
+  localusersetaccount(np, acc, id, 0, cs_accountflagmap_str(flags));
 
   controlreply(np, "Done.");
   return CMD_OK;