added basic ssl support to ircu
[ircu2.10.12-pk.git] / ircd / m_gline.c
index c099a631e9fcea82cbe4ea09d22c0235f0466301..9b6f66164fdcca12c755de0aeec95aac6fbb523c 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
@@ -167,6 +167,10 @@ ms_gline(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
     break;
   }
 
+  /* Is there no mask left? */
+  if (mask[0] == '\0')
+    return need_more_params(sptr, "GLINE");
+
   /* Now, let's figure out if it's a local or global G-line */
   if (action == GLINE_LOCAL_ACTIVATE || action == GLINE_LOCAL_DEACTIVATE ||
       (target[0] == '*' && target[1] == '\0'))
@@ -258,13 +262,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 */
   }
@@ -308,7 +312,7 @@ ms_gline(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
        if (!agline || /* gline creation, has to be the reason */
            /* trial-convert as lifetime, and if it doesn't fully convert,
             * it must be the reason */
-           ((lifetime = strtoul(parv[5], &tmp, 10)) && !*tmp)) {
+           (!(lifetime = strtoul(parv[5], &tmp, 10)) && !*tmp)) {
          lifetime = 0;
          reason = parv[5];
 
@@ -423,7 +427,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 +464,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]);
 
@@ -477,6 +481,10 @@ mo_gline(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
     break;
   }
 
+  /* Is there no mask left? */
+  if (mask[0] == '\0')
+    return need_more_params(sptr, "GLINE");
+
   /* Now let's figure out which is the target server */
   if (!target) /* no target, has to be me... */
     acptr = &me;
@@ -554,7 +562,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 */
     }
@@ -610,12 +618,6 @@ mo_gline(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
       return send_reply(sptr, ERR_NOPRIVILEGES);
   }
 
-  /* If globally disabling a G-line that we do not already have, avoid
-   * creating a temporary one. */
-  if (!agline && action == GLINE_DEACTIVATE) {
-    return gline_forward_deactivation(cptr, sptr, mask, expire, CurrentTime, 0, flags);
-  }
-
   Debug((DEBUG_DEBUG, "I have a global G-line I am acting upon now; "
         "target %s, mask %s, operforce %s, action %s, expire %Tu, "
         "reason: %s; gline %s!  (fields present: %s %s)", target, 
@@ -630,14 +632,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));
 }