]> 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 0007907f0d96cd8fe9fb042debbd42efd754ad86..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.");