keep in sync with OGN upstream (SVN-321)
[ircu2.10.12-pk.git] / ircd / gline.c
index e8c7b29a74729760304bdb86e8a59cadc7f2c70a..243e36e5b6c3f094a3d1861295f6be572d93c560 100644 (file)
@@ -82,11 +82,7 @@ struct Gline* BadChanGlineList = 0;
  * (x || 1) is used to continue in a logical-and series even when !x.
  * (x && 0) is used to continue in a logical-or series even when x.
  */
-#ifdef OLD_OGN_IRCU_COMPAT
-    #define GL_EXPIRED(gl) ((gl)->gl_lifetime <= CurrentTime)
-#else
-    #define GL_EXPIRED(gl) ((gl)->gl_lifetime <= CurrentTime || (gl)->gl_expire <= CurrentTime)
-#endif
+#define GL_EXPIRED(gl) ((gl)->gl_lifetime <= CurrentTime || (gl)->gl_expire <= CurrentTime)
 #define gliter(list, gl, next)                         \
   /* Iterate through the G-lines in the list */                \
   for ((gl) = (list); (gl); (gl) = (next))             \
@@ -363,21 +359,12 @@ gline_propagate(struct Client *cptr, struct Client *sptr, struct Gline *gline)
 
   assert(gline->gl_lastmod);
 
-#ifdef OLD_OGN_IRCU_COMPAT
-  sendcmdto_serv_butone(sptr, CMD_GLINE, cptr, "* %c%s%s%s %Tu %Tu :%s",
-                       GlineIsRemActive(gline) ? '+' : '-', gline->gl_user,
-                       gline->gl_host ? "@" : "",
-                       gline->gl_host ? gline->gl_host : "",
-                       gline->gl_expire - CurrentTime, gline->gl_lastmod,
-                       /*gline->gl_lifetime,*/ gline->gl_reason);
-#else
   sendcmdto_serv_butone(sptr, CMD_GLINE, cptr, "* %c%s%s%s %Tu %Tu %Tu :%s",
                        GlineIsRemActive(gline) ? '+' : '-', gline->gl_user,
                        gline->gl_host ? "@" : "",
                        gline->gl_host ? gline->gl_host : "",
                        gline->gl_expire - CurrentTime, gline->gl_lastmod,
                        gline->gl_lifetime, gline->gl_reason);
-#endif
 
   return 0;
 }
@@ -734,7 +721,7 @@ gline_modify(struct Client *cptr, struct Client *sptr, struct Gline *gline,
             time_t lastmod, time_t lifetime, unsigned int flags)
 {
   char buf[BUFSIZE], *op = "";
-  int pos = 0, disable_gl = 0;
+  int pos = 0, non_auto = 0, disable_gl = 0;
 
   assert(gline);
   assert(!GlineIsLocal(gline));
@@ -774,17 +761,6 @@ gline_modify(struct Client *cptr, struct Client *sptr, struct Gline *gline,
       }
     }
     if(expire <= CurrentTime) disable_gl = 1;
-#ifdef OLD_OGN_IRCU_COMPAT
-    /* Compatibility issue:
-     * The ircu prior to ircu-2.10.12.10 has no lifetime, therefore, we force
-     * the lifetime to be the same as the expiration time here. This allows to
-     * remove glines by setting the expiration-time to a smaller value than CurrentTime.
-     * This has to be removed when the full ircu-2.10.12.10 gline features
-     * want to be used on the whole network.
-     */
-    lifetime = expire;
-    flags |= GLINE_LIFETIME;
-#endif
   } else {
     flags &= ~GLINE_EXPIRE;
     expire = 0;
@@ -802,9 +778,6 @@ gline_modify(struct Client *cptr, struct Client *sptr, struct Gline *gline,
 
   lifetime = IRCD_MAX(lifetime, expire); /* set lifetime to the max */
 
-#ifdef OLD_OGN_IRCU_COMPAT
-  flags |= GLINE_LIFETIME;
-#else
   /* OK, let's see which is greater... */
   if (lifetime > gline->gl_lifetime)
     flags |= GLINE_LIFETIME; /* have to update lifetime */
@@ -812,7 +785,6 @@ gline_modify(struct Client *cptr, struct Client *sptr, struct Gline *gline,
     flags &= ~GLINE_LIFETIME; /* no change to lifetime */
     lifetime = 0;
   }
-#endif
 
   /* Finally, let's see if the reason needs to be updated */
   if ((flags & GLINE_REASON) && reason &&
@@ -900,6 +872,7 @@ gline_modify(struct Client *cptr, struct Client *sptr, struct Gline *gline,
 
   /* Now, handle reason changes... */
   if (flags & GLINE_REASON) {
+    non_auto = non_auto || ircd_strncmp(gline->gl_reason, "AUTO", 4);
     MyFree(gline->gl_reason); /* release old reason */
     DupString(gline->gl_reason, reason); /* store new reason */
     if (pos < BUFSIZE)
@@ -914,7 +887,9 @@ gline_modify(struct Client *cptr, struct Client *sptr, struct Gline *gline,
      * However, we additionally save the exact message in the log, so we have both information
      * in there. But the ops don't need to be bothered twice.
      */
-    sendto_opmask_butone(0, SNO_GLINE, "%s deleting global %s for %s%s%s",
+    non_auto = non_auto || ircd_strncmp(gline->gl_reason, "AUTO", 4);
+    sendto_opmask_butone(0, non_auto ? SNO_GLINE : SNO_AUTO,
+             "%s deleting global %s for %s%s%s",
                       (feature_bool(FEAT_HIS_SNOTICES) || IsServer(sptr)) ?
                       cli_name(sptr) : cli_name((cli_user(sptr))->server),
                       GlineIsBadChan(gline) ? "BADCHAN" : "GLINE",
@@ -926,7 +901,9 @@ gline_modify(struct Client *cptr, struct Client *sptr, struct Gline *gline,
            gline->gl_host ? "@" : "", gline->gl_host ? gline->gl_host : "");
   }
   else {
-    sendto_opmask_butone(0, SNO_GLINE, "%s modifying global %s for %s%s%s:%s",
+    non_auto = non_auto || ircd_strncmp(gline->gl_reason, "AUTO", 4);
+    sendto_opmask_butone(0, non_auto ? SNO_GLINE : SNO_AUTO,
+            "%s modifying global %s for %s%s%s:%s",
                       (feature_bool(FEAT_HIS_SNOTICES) || IsServer(sptr)) ?
                       cli_name(sptr) : cli_name((cli_user(sptr))->server),
                       GlineIsBadChan(gline) ? "BADCHAN" : "GLINE",
@@ -944,16 +921,6 @@ gline_modify(struct Client *cptr, struct Client *sptr, struct Gline *gline,
   /* We'll be simple for this release, but we can update this to change
    * the propagation syntax on future updates
    */
-#ifdef OLD_OGN_IRCU_COMPAT
-  if (action != GLINE_LOCAL_ACTIVATE && action != GLINE_LOCAL_DEACTIVATE)
-    sendcmdto_serv_butone(sptr, CMD_GLINE, cptr,
-                         "* %s%s%s%s%s %Tu %Tu :%s",
-                         flags & GLINE_OPERFORCE ? "!" : "", op,
-                         gline->gl_user, gline->gl_host ? "@" : "",
-                         gline->gl_host ? gline->gl_host : "",
-                         gline->gl_expire, gline->gl_lastmod,
-                         /*gline->gl_lifetime,*/ gline->gl_reason);
-#else
   if (action != GLINE_LOCAL_ACTIVATE && action != GLINE_LOCAL_DEACTIVATE)
     sendcmdto_serv_butone(sptr, CMD_GLINE, cptr,
                          "* %s%s%s%s%s %Tu %Tu %Tu :%s",
@@ -962,7 +929,6 @@ gline_modify(struct Client *cptr, struct Client *sptr, struct Gline *gline,
                          gline->gl_host ? gline->gl_host : "",
                          gline->gl_expire, gline->gl_lastmod,
                          gline->gl_lifetime, gline->gl_reason);
-#endif
 
   /* OK, let's do the G-line... */
   if(disable_gl) return 0;
@@ -1132,24 +1098,6 @@ gline_burst(struct Client *cptr)
   struct Gline *gline;
   struct Gline *sgline;
 
-#ifdef OLD_OGN_IRCU_COMPAT
-  gliter(GlobalGlineList, gline, sgline) {
-    if (!GlineIsLocal(gline) && gline->gl_lastmod)
-      sendcmdto_one(&me, CMD_GLINE, cptr, "* %c%s%s%s %Tu %Tu :%s",
-                   GlineIsRemActive(gline) ? '+' : '-', gline->gl_user,
-                    gline->gl_host ? "@" : "",
-                    gline->gl_host ? gline->gl_host : "",
-                   gline->gl_expire - CurrentTime, gline->gl_lastmod,
-                    /*gline->gl_lifetime,*/ gline->gl_reason);
-  }
-  gliter(BadChanGlineList, gline, sgline) {
-    if (!GlineIsLocal(gline) && gline->gl_lastmod)
-      sendcmdto_one(&me, CMD_GLINE, cptr, "* %c%s %Tu %Tu :%s",
-                   GlineIsRemActive(gline) ? '+' : '-', gline->gl_user,
-                   gline->gl_expire - CurrentTime, gline->gl_lastmod,
-                   /*gline->gl_lifetime,*/ gline->gl_reason);
-  }
-#else
   gliter(GlobalGlineList, gline, sgline) {
     if (!GlineIsLocal(gline) && gline->gl_lastmod)
       sendcmdto_one(&me, CMD_GLINE, cptr, "* %c%s%s%s %Tu %Tu %Tu :%s",
@@ -1159,6 +1107,7 @@ gline_burst(struct Client *cptr)
                    gline->gl_expire - CurrentTime, gline->gl_lastmod,
                     gline->gl_lifetime, gline->gl_reason);
   }
+
   gliter(BadChanGlineList, gline, sgline) {
     if (!GlineIsLocal(gline) && gline->gl_lastmod)
       sendcmdto_one(&me, CMD_GLINE, cptr, "* %c%s %Tu %Tu %Tu :%s",
@@ -1166,7 +1115,6 @@ gline_burst(struct Client *cptr)
                    gline->gl_expire - CurrentTime, gline->gl_lastmod,
                    gline->gl_lifetime, gline->gl_reason);
   }
-#endif
 }
 
 /** Send a G-line to another server.
@@ -1180,21 +1128,12 @@ gline_resend(struct Client *cptr, struct Gline *gline)
   if (GlineIsLocal(gline) || !gline->gl_lastmod)
     return 0;
 
-#ifdef OLD_OGN_IRCU_COMPAT
-  sendcmdto_one(&me, CMD_GLINE, cptr, "* %c%s%s%s %Tu %Tu :%s",
-               GlineIsRemActive(gline) ? '+' : '-', gline->gl_user,
-               gline->gl_host ? "@" : "",
-                gline->gl_host ? gline->gl_host : "",
-               gline->gl_expire - CurrentTime, gline->gl_lastmod,
-               /*gline->gl_lifetime,*/ gline->gl_reason);
-#else
   sendcmdto_one(&me, CMD_GLINE, cptr, "* %c%s%s%s %Tu %Tu %Tu :%s",
                GlineIsRemActive(gline) ? '+' : '-', gline->gl_user,
                gline->gl_host ? "@" : "",
                 gline->gl_host ? gline->gl_host : "",
                gline->gl_expire - CurrentTime, gline->gl_lastmod,
                gline->gl_lifetime, gline->gl_reason);
-#endif
 
   return 0;
 }