Treat G-line-related times as network times, rather than local times.
authorMichael Poole <mdpoole@troilus.org>
Sun, 18 Apr 2010 23:15:10 +0000 (23:15 +0000)
committerMichael Poole <mdpoole@troilus.org>
Sun, 18 Apr 2010 23:15:10 +0000 (23:15 +0000)
git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/branches/u2_10_12_branch@1947 c9e4aea6-c8fd-4c43-8297-357d70d61c8c

ChangeLog
ircd/gline.c
ircd/m_gline.c

index 45bdb19d5891283581a7399ff9a735a6da77dc95..c9df153cba754b61353f20ac8bfb6fabd1677a86 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2010-03-28  Michael Poole <mdpoole@troilus.org>
+
+       * ircd/gline.c: Replace CurrentTime with TStime(), and remove the
+       uses of TSoffset, so that all G-line-related times are assumed to
+       be in network time.
+
+       * ircd/m_gline.c: Likewise.
+
 2010-03-08  Michael Poole <mdpoole@troilus.org>
 
        * ircd/m_server.c (enum lh_type): New type.
index dfbf77d2394fdc38e946d9423fa68ba267edb20e..d2b2b9b7b68190a70f876aa31cf68137e8e4b3c5 100644 (file)
@@ -86,11 +86,11 @@ struct Gline* BadChanGlineList = 0;
     /* Figure out the next pointer in list... */       \
     if ((((next) = (gl)->gl_next) || 1) &&             \
        /* Then see if it's expired */                  \
-       (gl)->gl_lifetime <= CurrentTime)               \
+       (gl)->gl_lifetime <= TStime())                  \
       /* Record has expired, so free the G-line */     \
       gline_free((gl));                                        \
     /* See if we need to expire the G-line */          \
-    else if ((((gl)->gl_expire > CurrentTime) ||        \
+    else if ((((gl)->gl_expire > TStime()) ||          \
              (((gl)->gl_flags &= ~GLINE_ACTIVE) && 0) ||       \
              ((gl)->gl_state = GLOCAL_GLOBAL)) && 0)   \
       ; /* empty statement */                          \
@@ -341,7 +341,7 @@ gline_propagate(struct Client *cptr, struct Client *sptr, struct Gline *gline)
                        GlineIsRemActive(gline) ? '+' : '-', gline->gl_user,
                        gline->gl_host ? "@" : "",
                        gline->gl_host ? gline->gl_host : "",
-                       gline->gl_expire - CurrentTime, gline->gl_lastmod,
+                       gline->gl_expire - TStime(), gline->gl_lastmod,
                        gline->gl_lifetime, gline->gl_reason);
 
   return 0;
@@ -499,11 +499,11 @@ gline_add(struct Client *cptr, struct Client *sptr, char *userhost,
    * expiration time for greater than GLINE_MAX_EXPIRE.
    */
   if (!(flags & GLINE_FORCE) &&
-      (expire <= CurrentTime || expire > CurrentTime + GLINE_MAX_EXPIRE)) {
+      (expire <= TStime() || expire > TStime() + GLINE_MAX_EXPIRE)) {
     if (!IsServer(sptr) && MyConnect(sptr))
       send_reply(sptr, ERR_BADEXPIRE, expire);
     return 0;
-  } else if (expire <= CurrentTime) {
+  } else if (expire <= TStime()) {
     /* This expired G-line was forced to be added, so mark it inactive. */
     flags &= ~GLINE_ACTIVE;
   }
@@ -525,7 +525,7 @@ gline_add(struct Client *cptr, struct Client *sptr, char *userhost,
                       (flags & GLINE_BADCHAN) ? "BADCHAN" : "GLINE", user,
                       (flags & (GLINE_BADCHAN|GLINE_REALNAME)) ? "" : "@",
                       (flags & (GLINE_BADCHAN|GLINE_REALNAME)) ? "" : host,
-                      expire + TSoffset, reason);
+                      expire, reason);
 
   /* and log it */
   log_write(LS_GLINE, L_INFO, LOG_NOSNOTICE,
@@ -534,7 +534,7 @@ gline_add(struct Client *cptr, struct Client *sptr, char *userhost,
            flags & GLINE_BADCHAN ? "BADCHAN" : "GLINE", user,
            flags & (GLINE_BADCHAN|GLINE_REALNAME) ? "" : "@",
            flags & (GLINE_BADCHAN|GLINE_REALNAME) ? "" : host,
-           expire + TSoffset, reason);
+           expire, reason);
 
   /* make the gline */
   agline = make_gline(user, host, reason, expire, lastmod, lifetime, flags);
@@ -592,14 +592,14 @@ gline_activate(struct Client *cptr, struct Client *sptr, struct Gline *gline,
                        GlineIsBadChan(gline) ? "BADCHAN" : "GLINE",
                        gline->gl_user, gline->gl_host ? "@" : "",
                        gline->gl_host ? gline->gl_host : "",
-                       gline->gl_expire + TSoffset, gline->gl_reason);
-  
+                       gline->gl_expire, gline->gl_reason);
+
   log_write(LS_GLINE, L_INFO, LOG_NOSNOTICE,
            "%#C activating global %s for %s%s%s, expiring at %Tu: %s", sptr,
            GlineIsBadChan(gline) ? "BADCHAN" : "GLINE", gline->gl_user,
            gline->gl_host ? "@" : "",
            gline->gl_host ? gline->gl_host : "",
-           gline->gl_expire + TSoffset, gline->gl_reason);
+           gline->gl_expire, gline->gl_reason);
 
   if (!(flags & GLINE_LOCAL)) /* don't propagate local changes */
     gline_propagate(cptr, sptr, gline);
@@ -660,14 +660,14 @@ gline_deactivate(struct Client *cptr, struct Client *sptr, struct Gline *gline,
                       msg, GlineIsBadChan(gline) ? "BADCHAN" : "GLINE",
                       gline->gl_user, gline->gl_host ? "@" : "",
                        gline->gl_host ? gline->gl_host : "",
-                      gline->gl_expire + TSoffset, gline->gl_reason);
+                      gline->gl_expire, gline->gl_reason);
 
   log_write(LS_GLINE, L_INFO, LOG_NOSNOTICE,
            "%#C %s %s for %s%s%s, expiring at %Tu: %s", sptr, msg,
            GlineIsBadChan(gline) ? "BADCHAN" : "GLINE", gline->gl_user,
            gline->gl_host ? "@" : "",
            gline->gl_host ? gline->gl_host : "",
-           gline->gl_expire + TSoffset, gline->gl_reason);
+           gline->gl_expire, gline->gl_reason);
 
   if (!(flags & GLINE_LOCAL)) /* don't propagate local changes */
     gline_propagate(cptr, sptr, gline);
@@ -727,7 +727,7 @@ gline_modify(struct Client *cptr, struct Client *sptr, struct Gline *gline,
   /* first, check out the expiration time... */
   if ((flags & GLINE_EXPIRE) && expire) {
     if (!(flags & GLINE_FORCE) &&
-       (expire <= CurrentTime || expire > CurrentTime + GLINE_MAX_EXPIRE)) {
+       (expire <= TStime() || expire > TStime() + GLINE_MAX_EXPIRE)) {
       if (!IsServer(sptr) && MyConnect(sptr)) /* bad expiration time */
        send_reply(sptr, ERR_BADEXPIRE, expire);
       return 0;
@@ -768,7 +768,7 @@ gline_modify(struct Client *cptr, struct Client *sptr, struct Gline *gline,
       (action == GLINE_LOCAL_DEACTIVATE &&
        (gline->gl_state == GLOCAL_DEACTIVATED)) ||
       /* can't activate an expired G-line */
-      IRCD_MAX(gline->gl_expire, expire) <= CurrentTime)
+      IRCD_MAX(gline->gl_expire, expire) <= TStime())
     action = GLINE_MODIFY; /* no activity state modifications */
 
   Debug((DEBUG_DEBUG,  "About to perform changes; flags 0x%04x, action %s",
@@ -873,7 +873,7 @@ gline_modify(struct Client *cptr, struct Client *sptr, struct Gline *gline,
                          flags & GLINE_OPERFORCE ? "!" : "", op,
                          gline->gl_user, gline->gl_host ? "@" : "",
                          gline->gl_host ? gline->gl_host : "",
-                         gline->gl_expire - CurrentTime, gline->gl_lastmod,
+                         gline->gl_expire - TStime(), gline->gl_lastmod,
                          gline->gl_lifetime, gline->gl_reason);
 
   /* OK, let's do the G-line... */
@@ -1049,7 +1049,7 @@ gline_burst(struct Client *cptr)
                    GlineIsRemActive(gline) ? '+' : '-', gline->gl_user,
                     gline->gl_host ? "@" : "",
                     gline->gl_host ? gline->gl_host : "",
-                   gline->gl_expire - CurrentTime, gline->gl_lastmod,
+                   gline->gl_expire - TStime(), gline->gl_lastmod,
                     gline->gl_lifetime, gline->gl_reason);
   }
 
@@ -1057,7 +1057,7 @@ gline_burst(struct Client *cptr)
     if (!GlineIsLocal(gline) && gline->gl_lastmod)
       sendcmdto_one(&me, CMD_GLINE, cptr, "* %c%s %Tu %Tu %Tu :%s",
                    GlineIsRemActive(gline) ? '+' : '-', gline->gl_user,
-                   gline->gl_expire - CurrentTime, gline->gl_lastmod,
+                   gline->gl_expire - TStime(), gline->gl_lastmod,
                    gline->gl_lifetime, gline->gl_reason);
   }
 }
@@ -1077,7 +1077,7 @@ gline_resend(struct Client *cptr, struct Gline *gline)
                GlineIsRemActive(gline) ? '+' : '-', gline->gl_user,
                gline->gl_host ? "@" : "",
                 gline->gl_host ? gline->gl_host : "",
-               gline->gl_expire - CurrentTime, gline->gl_lastmod,
+               gline->gl_expire - TStime(), gline->gl_lastmod,
                gline->gl_lifetime, gline->gl_reason);
 
   return 0;
@@ -1104,8 +1104,8 @@ gline_list(struct Client *sptr, char *userhost)
     send_reply(sptr, RPL_GLIST, gline->gl_user,
                gline->gl_host ? "@" : "",
                gline->gl_host ? gline->gl_host : "",
-              gline->gl_expire + TSoffset, gline->gl_lastmod,
-              gline->gl_lifetime + TSoffset,
+              gline->gl_expire, gline->gl_lastmod,
+              gline->gl_lifetime,
               GlineIsLocal(gline) ? cli_name(&me) : "*",
               gline->gl_state == GLOCAL_ACTIVATED ? ">" :
               (gline->gl_state == GLOCAL_DEACTIVATED ? "<" : ""),
@@ -1115,8 +1115,8 @@ gline_list(struct Client *sptr, char *userhost)
       send_reply(sptr, RPL_GLIST, gline->gl_user,
                 gline->gl_host ? "@" : "",
                 gline->gl_host ? gline->gl_host : "",
-                gline->gl_expire + TSoffset, gline->gl_lastmod,
-                gline->gl_lifetime + TSoffset,
+                gline->gl_expire, gline->gl_lastmod,
+                gline->gl_lifetime,
                 GlineIsLocal(gline) ? cli_name(&me) : "*",
                 gline->gl_state == GLOCAL_ACTIVATED ? ">" :
                 (gline->gl_state == GLOCAL_DEACTIVATED ? "<" : ""),
@@ -1125,8 +1125,8 @@ gline_list(struct Client *sptr, char *userhost)
 
     gliter(BadChanGlineList, gline, sgline) {
       send_reply(sptr, RPL_GLIST, gline->gl_user, "", "",
-                gline->gl_expire + TSoffset, gline->gl_lastmod,
-                gline->gl_lifetime + TSoffset,
+                gline->gl_expire, gline->gl_lastmod,
+                gline->gl_lifetime,
                 GlineIsLocal(gline) ? cli_name(&me) : "*",
                 gline->gl_state == GLOCAL_ACTIVATED ? ">" :
                 (gline->gl_state == GLOCAL_DEACTIVATED ? "<" : ""),
@@ -1154,8 +1154,8 @@ gline_stats(struct Client *sptr, const struct StatDesc *sd,
     send_reply(sptr, RPL_STATSGLINE, 'G', gline->gl_user,
               gline->gl_host ? "@" : "",
               gline->gl_host ? gline->gl_host : "",
-              gline->gl_expire + TSoffset, gline->gl_lastmod,
-              gline->gl_lifetime + TSoffset,
+              gline->gl_expire, gline->gl_lastmod,
+              gline->gl_lifetime,
               gline->gl_state == GLOCAL_ACTIVATED ? ">" :
               (gline->gl_state == GLOCAL_DEACTIVATED ? "<" : ""),
               GlineIsRemActive(gline) ? '+' : '-',
index 506696a47c7efec90aa71302845364ecec9b9afe..18bc31d46fb5a7d98ab55ef1c90697c1c0472e0f 100644 (file)
  * but you can't have everything in a macro ;)
  */
 #define abs_expire(exp)                                                        \
-  ((exp) >= CurrentTime - PASTWATCH ? (exp) : (exp) + CurrentTime)
+  ((exp) >= TStime() - PASTWATCH ? (exp) : (exp) + TStime())
 
 /*
  * ms_gline - server message handler
@@ -258,13 +258,13 @@ ms_gline(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
           "target %s, mask %s, operforce %s, action %c, expire %Tu, "
           "lastmod %Tu, reason: %s", target, mask,
           flags & GLINE_OPERFORCE ? "YES" : "NO",
-          action == GLINE_ACTIVATE ? '+' :  '-', expire, CurrentTime,
+          action == GLINE_ACTIVATE ? '+' :  '-', expire, TStime(),
           reason));
 
     sendcmdto_one(sptr, CMD_GLINE, acptr, "%C %s%c%s %Tu %Tu :%s",
                  acptr, flags & GLINE_OPERFORCE ? "!" : "",
                  action == GLINE_ACTIVATE ? '+' : '-', mask,
-                 expire - CurrentTime, CurrentTime, reason);
+                 expire - TStime(), TStime(), reason);
 
     return 0; /* all done */
   }
@@ -423,7 +423,7 @@ mo_gline(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
       return need_more_params(sptr, "GLINE");
 
     target = parv[2]; /* get the target... */
-    expire = strtol(parv[3], &end, 10) + CurrentTime; /* and the expiration */
+    expire = strtol(parv[3], &end, 10) + TStime(); /* and the expiration */
     if (*end != '\0')
       return send_reply(sptr, SND_EXPLICIT | ERR_BADEXPIRE, "%s :Bad expire time", parv[3]);
 
@@ -460,7 +460,7 @@ mo_gline(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
     if (parc > 3) {
       /* get expiration and target */
       reason = parv[parc - 1];
-      expire = strtol(parv[parc - 2], &end, 10) + CurrentTime;
+      expire = strtol(parv[parc - 2], &end, 10) + TStime();
       if (*end != '\0')
         return send_reply(sptr, SND_EXPLICIT | ERR_BADEXPIRE, "%s :Bad expire time", parv[parc - 2]);
 
@@ -554,7 +554,7 @@ mo_gline(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
       sendcmdto_one(sptr, CMD_GLINE, acptr, "%C %s%c%s %Tu %Tu :%s",
                    acptr, flags & GLINE_OPERFORCE ? "!" : "",
                    action == GLINE_ACTIVATE ? '+' : '-', mask,
-                   expire - CurrentTime, CurrentTime, reason);
+                   expire - TStime(), TStime(), reason);
 
       return 0; /* all done */
     }
@@ -624,14 +624,14 @@ mo_gline(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
 
   if (agline) /* modifying an existing G-line */
     return gline_modify(cptr, sptr, agline, action, reason, expire,
-                       CurrentTime, 0, flags);
+                       TStime(), 0, flags);
 
   assert(action != GLINE_LOCAL_ACTIVATE);
   assert(action != GLINE_LOCAL_DEACTIVATE);
   assert(action != GLINE_MODIFY);
 
   /* create a new G-line */
-  return gline_add(cptr, sptr, mask, reason, expire, CurrentTime, 0,
+  return gline_add(cptr, sptr, mask, reason, expire, TStime(), 0,
                   flags | ((action == GLINE_ACTIVATE) ? GLINE_ACTIVE : 0));
 }