]> jfr.im git - irc/quakenet/newserv.git/commitdiff
trusts/gline etensions should check for -1
authorPaul <redacted>
Sun, 4 Jan 2009 20:19:02 +0000 (20:19 +0000)
committerPaul <redacted>
Sun, 4 Jan 2009 20:19:02 +0000 (20:19 +0000)
--HG--
branch : paul

gline/gline.c
gline/gline_alloc.c
gline/gline_handler.c
trusts2/trusts.c

index 6847c5dff350e11eb491b1d32ebbc4429119df46..f0c19de19bbb6522bef8f2327930ff038617d87e 100644 (file)
@@ -19,6 +19,7 @@
 #include "../lib/base64.h"
 #include "../lib/irc_string.h"
 #include "../lib/splitline.h"
+#include "../core/nsmalloc.h"
 
 #include "gline.h"
 
@@ -27,7 +28,7 @@ gline* glinelist = 0, *glinelistnonnode = 0;
 int glinecount = 0;
 int badchancount = 0;
 int rnglinecount = 0;
-int gl_nodeext = 0;
+int gl_nodeext = -1;
 
 /* 
   <prefix> GL <target> [!][+|-|>|<]<mask> [<expiration>] [<lastmod>]
@@ -38,7 +39,7 @@ int gl_nodeext = 0;
 void _init() {
   gl_nodeext = registernodeext("gline");
 
-  if ( !gl_nodeext ) {
+  if ( gl_nodeext == -1 ) {
     Error("gline", ERR_FATAL, "Could not register a required node extension (gline)");
     return;
   }
@@ -60,8 +61,10 @@ void _fini() {
   }
   glinelist = NULL;
  
-  if (gl_nodeext) 
+  if (gl_nodeext != -1
     releasenodeext(gl_nodeext);
+
+  nsfreeall(POOL_GLINE);
 }
 
 int gline_setnick(nick *np, int duration, char *reason ) {
index a53a90afdaf1c42df0706a54543abfd1a32d0fd1..26d51d9c7c6515e00f2741d17a87ef15e25696c2 100644 (file)
@@ -119,3 +119,5 @@ void removegline( gline *gl) {
   removeglinefromlists(gl);
   freegline(gl);
 }
+
+
index f73e5166fb147d2b99209c2acecfabcbe1a751b1..732f0379c5b0c75a5c05b14da59dbe4c69119334 100644 (file)
@@ -39,6 +39,9 @@ int handleglinemsg(void* source, int cargc, char** cargv) {
 
   /* valid GL tokens have X params */
   switch ( cargc ) {
+    case 2:
+      /* local modification which we reject later */
+      break;
     case 5:
       /* 1.3.x GL Token */
       break;
@@ -95,7 +98,7 @@ int handleglinemsg(void* source, int cargc, char** cargv) {
       break;
     case '>':
     case '<':
-      Error("gline", ERR_WARNING, "Received local modification from %s.", sender);
+      Error("gline", ERR_WARNING, "Received local modification from %s - do they realise we're a service?", sender);
       return CMD_ERROR;
   } 
 
@@ -208,7 +211,28 @@ int handleglinemsg(void* source, int cargc, char** cargv) {
     }
   } else {
     /* modification - only snircd 1.4.x */
-    Error("gline", ERR_WARNING, "Not Implemented");
+    if ((agline = gline_find(mask))) {
+      expires = abs_expire(atoi(cargv[2]));
+      lastmod = atoi(cargv[3]);
+      lifetime = atoi(cargv[4]);
+      reason = cargv[5];
+
+      if ( lastmod > agline->lastmod ) {
+        agline->lastmod = lastmod;
+        agline->expires = expires;
+        agline->lifetime = lifetime;
+        agline->creator = creator;
+        freesstring(agline->reason);
+        agline->reason = getsstring(reason, 255);
+      } else {
+        Error("debuggline", ERR_WARNING, "received a gline modification with a lower lastmod");
+        /* @@@TODO resend our gline ? */
+      }
+      return CMD_OK;
+    } else {
+      Error("gline", ERR_WARNING, "Received modification for gline that does not exist for mask %s", mask);
+      return CMD_ERROR;
+    }
   }
 
   Error("debuggline", ERR_WARNING, "Creator %s", creator->content);
index bb9b1dd9d6ad1ec7aed7c595eba1fe53e4c46fc3..4a20efbe76693e35b47dd572888e0f95f263b17e 100644 (file)
@@ -4,9 +4,9 @@
 #include <stdarg.h>
 #include "../core/nsmalloc.h"
 
-int tgh_ext;
-int tgb_ext;
-int tgn_ext;
+int tgh_ext = -1;
+int tgb_ext = -1;
+int tgn_ext = -1;
 
 unsigned long trusts_lasttrustgroupid;
 unsigned long trusts_lasttrusthostid;
@@ -21,19 +21,19 @@ void _init(void) {
   trusts_hash_init();
 
   tgh_ext = registernodeext("trusthost");
-  if ( !tgh_ext ) {
+  if ( tgh_ext == -1 ) {
     Error("trusts", ERR_FATAL, "Could not register a required node extension (trusthost)");
     return;
   }
 
   tgb_ext = registernodeext("trustblock");
-  if ( !tgb_ext ) {
+  if ( tgb_ext == -1 ) {
     Error("trusts", ERR_FATAL, "Could not register a required node extension (trustblock)");
     return;
   }
 
   tgn_ext = registernickext("trustnick");
-  if ( !tgn_ext ) {
+  if ( tgn_ext == -1 ) {
     Error("trusts", ERR_FATAL, "Could not register a required nick extension (trustnick)");
     return;
   }
@@ -86,11 +86,11 @@ void _fini(void) {
     }
   } PATRICIA_WALK_CLEAR_END;
 
-  if (tgh_ext)
+  if (tgh_ext != -1)
     releasenodeext(tgh_ext);
-  if (tgb_ext)
+  if (tgb_ext != -1)
     releasenodeext(tgb_ext);
-  if (tgn_ext)
+  if (tgn_ext != -1)
     releasenodeext(tgn_ext);
 
   /* @@@ CLOSE DB */