+ /* Next, try to find the G-line... */
+ if ((flags & GLINE_GLOBAL) || IsMe(acptr)) /* don't bother if it's not me! */
+ agline = gline_find(mask, flags | GLINE_ANY | GLINE_EXACT);
+
+ /* We now have all the pieces to tell us what we've got; let's put
+ * it all together and convert the rest of the arguments.
+ */
+
+ /* Handle the local G-lines first... */
+ if (flags & GLINE_LOCAL) {
+ assert(acptr);
+
+ /* normalize the action, first */
+ if (action == GLINE_LOCAL_ACTIVATE || action == GLINE_MODIFY)
+ action = GLINE_ACTIVATE;
+ else if (action == GLINE_LOCAL_DEACTIVATE)
+ action = GLINE_DEACTIVATE;
+
+ /* If it's not for us, forward */
+ /* UPDATE NOTE: Once all servers are updated to u2.10.12.11, the
+ * format string in this sendcmdto_one() may be updated to omit
+ * <lastmod> for GLINE_ACTIVATE and to omit <expire>, <lastmod>,
+ * and <reason> for GLINE_DEACTIVATE.
+ */
+
+ if (!IsMe(acptr)) {
+ /* check for permissions... */
+ if (!feature_bool(FEAT_CONFIG_OPERCMDS))
+ return send_reply(sptr, ERR_DISABLED, "GLINE");
+ else if (!HasPriv(sptr, PRIV_GLINE))
+ return send_reply(sptr, ERR_NOPRIVILEGES);
+
+ Debug((DEBUG_DEBUG, "I am forwarding a local G-line to a remote "
+ "server; target %s, mask %s, operforce %s, action %c, "
+ "expire %Tu, reason %s", target, mask,
+ flags & GLINE_OPERFORCE ? "YES" : "NO",
+ action == GLINE_ACTIVATE ? '+' : '-', expire, reason));
+
+ sendcmdto_one(sptr, CMD_GLINE, acptr, "%C %s%c%s %Tu %Tu :%s",
+ acptr, flags & GLINE_OPERFORCE ? "!" : "",
+ action == GLINE_ACTIVATE ? '+' : '-', mask,
+ expire - TStime(), TStime(), reason);
+
+ return 0; /* all done */
+ }
+
+ /* check local G-line permissions... */
+ if (!HasPriv(sptr, PRIV_LOCAL_GLINE))
+ return send_reply(sptr, ERR_NOPRIVILEGES);
+
+ /* let's handle activation... */
+ if (action == GLINE_ACTIVATE) {
+ if (agline) /* G-line already exists, so let's ignore it... */
+ return 0;
+
+ /* OK, create the local G-line */
+ Debug((DEBUG_DEBUG, "I am creating a local G-line here; target %s, "
+ "mask %s, operforce %s, action %s, expire %Tu, reason: %s",
+ target, mask, flags & GLINE_OPERFORCE ? "YES" : "NO",
+ action == GLINE_ACTIVATE ? "+" : "-", expire, reason));
+
+ return gline_add(cptr, sptr, mask, reason, expire, 0, 0,
+ flags | GLINE_ACTIVE);
+ } else { /* OK, it's a deactivation/destruction */
+ if (!agline) /* G-line doesn't exist, so let's complain... */
+ return send_reply(sptr, ERR_NOSUCHGLINE, mask);
+
+ /* Let's now destroy the G-line */
+ Debug((DEBUG_DEBUG, "I am destroying a local G-line here; target %s, "
+ "mask %s, operforce %s, action %s", target, mask,
+ flags & GLINE_OPERFORCE ? "YES" : "NO",
+ action == GLINE_ACTIVATE ? "+" : "-"));
+
+ return gline_destroy(cptr, sptr, agline);