]> jfr.im git - irc/quakenet/newserv.git/blobdiff - chanserv/chanservuser.c
CHANSERV: more checks on lastchannelID / lastuserID
[irc/quakenet/newserv.git] / chanserv / chanservuser.c
index db70abd4ee388180be68820069c404652396e8ed..0428050082ac734a2cb7debc510c15c8ed498114 100644 (file)
@@ -40,7 +40,7 @@ void chanservreguser(void *arg) {
   csuser=getcopyconfigitem("chanserv","user","TheQBot",USERLEN);
   cshost=getcopyconfigitem("chanserv","host","some.host",HOSTLEN);
   csrealname=getcopyconfigitem("chanserv","realname","ChannelService",REALLEN);
-  csaccount=getcopyconfigitem("chanserv","account",csnick&&csnick->content&&csnick->content[0]?csnick->content:"Q",ACCOUNTLEN);
+  csaccount=getcopyconfigitem("chanserv","account",csnick&&csnick->content[0]?csnick->content:"Q",ACCOUNTLEN);
 
   Error("chanserv",ERR_INFO,"Connecting %s...",csnick->content);
 
@@ -1131,7 +1131,16 @@ int cs_removechannelifempty(nick *sender, regchan *rcp) {
         return 0;
     }
   }
-  
+
+  /*
+   * don't cleanup the last channel to prevent channel id reuse.
+   * the channel will be orphaned but will be cleaned up by cleanup eventually
+   */
+  if(rcp->ID == lastchannelID) {
+    cs_log(sender,"DELCHAN FAILED %s (last id)",rcp->index->name->content);
+    return 0;
+  }
+
   cs_log(sender,"DELCHAN %s (Empty)",rcp->index->name->content);
   cs_removechannel(rcp, "Last user removed - channel deleted.");
   
@@ -1445,7 +1454,7 @@ int checkreason(nick *np, char *reason) {
   return 1;
 }
 
-regchan *cs_addchan(chanindex *cip, nick *sender, reguser *addedby, reguser *founder, flag_t flags, short type) {
+regchan *cs_addchan(chanindex *cip, nick *sender, reguser *addedby, reguser *founder, flag_t flags, flag_t forcemodes, flag_t denymodes, short type) {
   regchan *rcp;
   regchanuser *rcup;
   void *args[3];
@@ -1469,8 +1478,8 @@ regchan *cs_addchan(chanindex *cip, nick *sender, reguser *addedby, reguser *fou
   rcp->lastcountersync=0;
 
   rcp->limit=0;
-  rcp->forcemodes=CHANMODE_DEFAULT;
-  rcp->denymodes=0;
+  rcp->forcemodes=forcemodes;
+  rcp->denymodes=denymodes;
 
   if (CIsAutoLimit(rcp)) {
     rcp->forcemodes |= CHANMODE_LIMIT;