Przeglądaj źródła

Merge branch 'cookie-sanity'

* cookie-sanity:
  * Disable cookies on ircu(undernet) and Unreal servers as they do not allow unbanning nonexistant bans.
  * Add 'cookies_disabled' to allow disabling cookies for upgrading/ircu/unreal
Bryan Drewery 16 lat temu
rodzic
commit
c2d55f6880

+ 2 - 0
doc/UPDATES

@@ -52,6 +52,8 @@
 * Hubs no longer include their own timestamp over botnet
 * Only use oident for server connects, not for bot linking.
 * Fix cmd_slowjoin not working on backup bots correctly.
+* Disable cookies on ircu(undernet) and Unreal servers as they do not allow unbanning nonexistant bans.
+
 
 1.2.16.1
 * Fix linux compile errors

+ 1 - 0
src/chanprog.c

@@ -62,6 +62,7 @@ char                    jupenick[NICKLEN] = "";
 char 			botname[NICKLEN + 1] = "";	/* IRC nickname */
 port_t     		my_port = 0;
 bool			reset_chans = 0;
+bool                    cookies_disabled = 0;
 char s2_4[3] = "",s1_6[3] = "",s1_11[3] = "";
 
 /* Remove leading and trailing whitespaces.

+ 1 - 1
src/chanprog.h

@@ -35,6 +35,6 @@ void setup_HQ(int);
 extern struct chanset_t		*chanset;
 extern char			admin[], origbotnick[NICKLEN + 1], origbotname[NICKLEN + 1], jupenick[NICKLEN], botname[NICKLEN + 1];
 extern port_t			my_port;
-extern bool			reset_chans;
+extern bool			reset_chans, cookies_disabled;
 
 #endif /* !_CHANPROG_H */

+ 1 - 1
src/mod/irc.mod/cmdsirc.c

@@ -677,7 +677,7 @@ static void cmd_mmode(int idx, char *par)
     return;
   }
 
-  if (mode[0] == '+' && mode[1] == 'o' && !channel_fastop(chan)) {
+  if (mode[0] == '+' && mode[1] == 'o' && !channel_fastop(chan) && !cookies_disabled) {
     dprintf(idx, STR("Error: This channel is currently set -fastop.\n"));
     dprintf(idx, STR("Mass opping would result in missing op cookies.\n"));
     dprintf(idx, STR("Please chanset the channel +fastop first.\n"));

+ 2 - 2
src/mod/irc.mod/mode.c

@@ -103,7 +103,7 @@ do_op(char *nick, struct chanset_t *chan, bool delay, bool force)
     m->flags |= SENTOP;
   }
 
-  if (channel_fastop(chan) || channel_take(chan)) {
+  if (channel_fastop(chan) || channel_take(chan) || cookies_disabled) {
     add_mode(chan, '+', 'o', nick);
   } else {
     add_cookie(chan, nick);
@@ -1117,7 +1117,7 @@ gotmode(char *from, char *msg)
         if (ops) {
           int n = 0;
           /* Check cookies */
-          if (u && m && u->bot && !channel_fastop(chan) && !channel_take(chan)) {
+          if (u && m && u->bot && !channel_fastop(chan) && !channel_take(chan) && !cookies_disabled) {
             int isbadop = 0;
             bool failure = 0;
 

+ 28 - 0
src/mod/server.mod/servmsg.c

@@ -234,6 +234,32 @@ static int got001(char *from, char *msg)
   return 0;
 }
 
+/* <server> 004 <to> <servername> <version> <user modes> <channel modes> */
+static int
+got004(char *from, char *msg)
+{
+  char *tmp = NULL;
+
+  newsplit(&msg); /* nick */
+  newsplit(&msg); /* server */
+
+  //Cache the results for later parsing if needed (after a restart)
+  //Sending 'VERSION' does not work on all servers, plus this speeds
+  //up a restart by removing the need to wait for the information
+  if (!replaying_cache)
+    dprintf(DP_CACHE, ":%s 004 . . %s", from, msg);
+
+  tmp = newsplit(&msg);
+
+  /* cookies won't work on ircu or Unreal or snircd */
+  if (strstr(tmp, "u2.") || strstr(tmp, "Unreeal") || strstr(tmp, "snircd")) {
+    putlog(LOG_DEBUG, "*", "Disabling cookies as they are not supported on %s", cursrvname);
+    cookies_disabled = true;
+  }
+
+  return 0;
+}
+
 /* <server> 005 <to> <option> <option> <... option> :are supported by this server */
 static int
 got005(char *from, char *msg)
@@ -1099,6 +1125,7 @@ static void disconnect_server(int idx, int dolost)
   serv = -1;
   servidx = -1;
   server_online = 0;
+  cookies_disabled = false;
   floodless = 0;
   botuserhost[0] = 0;
   botuserip[0] = 0; 
@@ -1565,6 +1592,7 @@ static cmd_t my_raw_binds[] =
   {"PONG",	"",	(Function) gotpong,		NULL, LEAF},
   {"WALLOPS",	"",	(Function) gotwall,		NULL, LEAF},
   {"001",	"",	(Function) got001,		NULL, LEAF},
+  {"004",	"",	(Function) got004,		NULL, LEAF},
   {"005",	"",	(Function) got005,		NULL, LEAF},
   {"303",	"",	(Function) got303,		NULL, LEAF},
   {"432",	"",	(Function) got432,		NULL, LEAF},