struct Gline *sgline;
if (userhost) {
- if (!(gline = gline_find(userhost, GLINE_ANY))) { /* no such gline */
- send_error_to_client(sptr, ERR_NOSUCHGLINE, userhost);
- return 0;
- }
+ if (!(gline = gline_find(userhost, GLINE_ANY))) /* no such gline */
+ return send_error_to_client(sptr, ERR_NOSUCHGLINE, userhost);
/* send gline information along */
sendto_one(sptr, rpl_str(RPL_GLIST), me.name, sptr->name, gline->gl_user,
if (gline->gl_expire <= TStime())
gline_free(gline);
else
- sendto_one(sptr, rpl_str(RPL_GLIST), me.name, sptr->name, gline->gl_user,
- "@", gline->gl_host, gline->gl_expire,
+ sendto_one(sptr, rpl_str(RPL_GLIST), me.name, sptr->name,
+ gline->gl_user, "@", gline->gl_host, gline->gl_expire,
GlineIsLocal(gline) ? me.name : "*",
GlineIsActive(gline) ? '+' : '-', gline->gl_reason);
}
if (gline->gl_expire <= TStime())
gline_free(gline);
else
- sendto_one(sptr, rpl_str(RPL_GLIST), me.name, sptr->name, gline->gl_user,
- "", "", gline->gl_expire,
+ sendto_one(sptr, rpl_str(RPL_GLIST), me.name, sptr->name,
+ gline->gl_user, "", "", gline->gl_expire,
GlineIsLocal(gline) ? me.name : "*",
GlineIsActive(gline) ? '+' : '-', gline->gl_reason);
}
gline->gl_reason);
}
}
-
-
-#if 0 /* forget about it! */
-struct Gline *make_gline(int is_ipmask, char *host, char *reason,
- char *name, time_t expire)
-{
- struct Gline *agline;
-
-#ifdef BADCHAN
- int gtype = 0;
- if ('#' == *host || '&' == *host || '+' == *host)
- gtype = 1; /* BAD CHANNEL GLINE */
-#endif
-
- agline = (struct Gline*) MyMalloc(sizeof(struct Gline)); /* alloc memory */
- assert(0 != agline);
- DupString(agline->host, host); /* copy vital information */
- DupString(agline->reason, reason);
- DupString(agline->name, name);
- agline->expire = expire;
- agline->gflags = GLINE_ACTIVE; /* gline is active */
- if (is_ipmask)
- SetGlineIsIpMask(agline);
-#ifdef BADCHAN
- if (gtype)
- {
- agline->next = BadChanGlineList; /* link it into the list */
- return (BadChanGlineList = agline);
- }
-#endif
- agline->next = GlobalGlineList; /* link it into the list */
- return (GlobalGlineList = agline);
-}
-
-struct Gline *find_gline(struct Client *cptr, struct Gline **pgline)
-{
- struct Gline* gline = GlobalGlineList;
- struct Gline* prev = 0;
-
- while (gline) {
- /*
- * look through all glines
- */
- if (gline->expire <= TStime()) {
- /*
- * handle expired glines
- */
- free_gline(gline, prev);
- gline = prev ? prev->next : GlobalGlineList;
- if (!gline)
- break; /* gline == NULL means gline == NULL */
- continue;
- }
-
- /* Does gline match? */
- /* Added a check against the user's IP address as well -Kev */
- if ((GlineIsIpMask(gline) ?
- match(gline->host, ircd_ntoa((const char*) &cptr->ip)) :
- match(gline->host, cptr->sockhost)) == 0 &&
- match(gline->name, cptr->user->username) == 0) {
- if (pgline)
- *pgline = prev; /* If they need it, give them the previous gline
- entry (probably for free_gline, below) */
- return gline;
- }
-
- prev = gline;
- gline = gline->next;
- }
-
- return 0; /* found no glines */
-}
-
-void free_gline(struct Gline* gline, struct Gline* prev)
-{
- assert(0 != gline);
- if (prev)
- prev->next = gline->next; /* squeeze agline out */
- else {
-#ifdef BADCHAN
- assert(0 != gline->host);
- if ('#' == *gline->host ||
- '&' == *gline->host ||
- '+' == *gline->host) {
- BadChanGlineList = gline->next;
- }
- else
-#endif
- GlobalGlineList = gline->next;
- }
-
- MyFree(gline->host); /* and free up the memory */
- MyFree(gline->reason);
- MyFree(gline->name);
- MyFree(gline);
-}
-
-void gline_remove_expired(time_t now)
-{
- struct Gline* gline;
- struct Gline* prev = 0;
-
- for (gline = GlobalGlineList; gline; gline = gline->next) {
- if (gline->expire < now) {
- free_gline(gline, prev);
- gline = (prev) ? prev : GlobalGlineList;
- if (!gline)
- break;
- continue;
- }
- prev = gline;
- }
-}
-
-#ifdef BADCHAN
-int bad_channel(const char* name)
-{
- struct Gline* agline = BadChanGlineList;
-
- while (agline)
- {
- if ((agline->gflags & GLINE_ACTIVE) && (agline->expire > TStime()) &&
- !mmatch(agline->host, name)) {
- return 1;
- }
- agline = agline->next;
- }
- return 0;
-}
-
-void bad_channel_remove_expired(time_t now)
-{
- struct Gline* gline;
- struct Gline* prev = 0;
-
- for (gline = BadChanGlineList; gline; gline = gline->next) {
- if (gline->expire < now) {
- free_gline(gline, prev);
- gline = (prev) ? prev : BadChanGlineList;
- if (!gline)
- break;
- continue;
- }
- prev = gline;
- }
-}
-
-#endif
-
-
-void add_gline(struct Client *sptr, int ip_mask, char *host, char *comment,
- char *user, time_t expire, int local)
-{
- struct Client *acptr;
- struct Gline *agline;
- int fd;
- int gtype = 0;
- assert(0 != host);
-
-#ifdef BADCHAN
- if ('#' == *host || '&' == *host || '+' == *host)
- gtype = 1; /* BAD CHANNEL */
-#endif
-
- /* Inform ops */
- sendto_op_mask(SNO_GLINE,
- "%s adding %s%s for %s@%s, expiring at " TIME_T_FMT ": %s", sptr->name,
- local ? "local " : "",
- gtype ? "BADCHAN" : "GLINE", user, host, expire, comment);
-
-#ifdef GPATH
- write_log(GPATH,
- "# " TIME_T_FMT " %s adding %s %s for %s@%s, expiring at " TIME_T_FMT
- ": %s\n", TStime(), sptr->name, local ? "local" : "global",
- gtype ? "BADCHAN" : "GLINE", user, host, expire, comment);
-
- /* this can be inserted into the conf */
- if (!gtype)
- write_log(GPATH, "%c:%s:%s:%s\n", ip_mask ? 'k' : 'K', host, comment,
- user);
-#endif /* GPATH */
-
- agline = make_gline(ip_mask, host, comment, user, expire);
- if (local)
- SetGlineIsLocal(agline);
-
-#ifdef BADCHAN
- if (gtype)
- return;
-#endif
-
- for (fd = HighestFd; fd >= 0; --fd) {
- /*
- * get the users!
- */
- if ((acptr = LocalClientArray[fd])) {
- if (!acptr->user)
- continue;
-#if 0
- /*
- * whee!! :)
- */
- if (!acptr->user || strlen(acptr->sockhost) > HOSTLEN ||
- (acptr->user->username ? strlen(acptr->user->username) : 0) > HOSTLEN)
- continue; /* these tests right out of
- find_kill for safety's sake */
-#endif
-
- if ((GlineIsIpMask(agline) ? match(agline->host, acptr->sock_ip) :
- match(agline->host, acptr->sockhost)) == 0 &&
- (!acptr->user->username ||
- match(agline->name, acptr->user->username) == 0))
- {
-
- /* ok, he was the one that got G-lined */
- sendto_one(acptr, ":%s %d %s :*** %s.", me.name,
- ERR_YOUREBANNEDCREEP, acptr->name, agline->reason);
-
- /* let the ops know about my first kill */
- sendto_op_mask(SNO_GLINE, "G-line active for %s",
- get_client_name(acptr, FALSE));
-
- /* and get rid of him */
- if (sptr != acptr)
- exit_client_msg(sptr->from, acptr, &me, "G-lined (%s)", agline->reason);
- }
- }
- }
-}
-
-#endif /* 0 */
}
}
+#ifndef CONFIG_OPERCMDS
+ if (!(flags & GLINE_LOCAL))
+ return send_error_to_client(sptr, ERR_DISABLED, "GLINE");
+#endif /* CONFIG_OPERCMDS */
+
agline = gline_find(mask, GLINE_ANY | GLINE_EXACT);
if (agline) {
m_gline(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
{
if (parc < 2)
- return gline_list(sptr, 0);
+ return send_error_to_client(sptr, ERR_NOSUCHGLINE, "");
return gline_list(sptr, parv[1]);
}
-
-#if 0
-/*
- * ms_gline - server message handler
- *
- * parv[0] = Send prefix
- *
- * From server:
- *
- * parv[1] = Target: server numeric
- * parv[2] = [+|-]<G-line mask>
- * parv[3] = Expiration offset
- * parv[4] = Comment
- *
- * From client:
- *
- * parv[1] = [+|-]<G-line mask>
- * parv[2] = Expiration offset
- * parv[3] = Comment
- *
- */
-int ms_gline(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
-{
- struct Client* acptr = 0; /* Init. to avoid compiler warning. */
- struct Gline* gline;
- struct Gline* prev;
- char* user;
- char* host;
- int active;
- int ip_mask;
- int gtype = 0;
- time_t expire = 0;
-
- /*
- * Remove expired G-lines
- */
- gline_remove_expired(TStime());
-#ifdef BADCHAN
- /*
- * Remove expired bad channels
- */
- bad_channel_remove_expired(TStime());
-#endif
-
- if (IsServer(cptr)) {
- if (find_conf_byhost(cptr->confs, sptr->name, CONF_UWORLD)) {
- if (parc < 3 || (*parv[2] != '-' && (parc < 5 || *parv[4] == '\0')))
- return need_more_params(sptr, "GLINE");
-
- if (*parv[2] == '-') /* add mode or delete mode? */
- active = 0;
- else
- active = 1;
-
- if (*parv[2] == '+' || *parv[2] == '-')
- parv[2]++; /* step past mode indicator */
-
- /*
- * forward the message appropriately
- */
- if (0 == ircd_strcmp(parv[1], "*")) {
- /*
- * global!
- */
- sendto_serv_butone(cptr,
- active ? "%s " TOK_GLINE " %s +%s %s :%s" : "%s " TOK_GLINE " %s -%s",
- NumServ(sptr), parv[1], parv[2], parv[3], parv[4]);
- }
- else if ((
-#if 1
- /*
- * REMOVE THIS after all servers upgraded to 2.10.01 and
- * Uworld uses a numeric too
- */
- (strlen(parv[1]) != 1 && !(acptr = FindClient(parv[1])))) ||
- (strlen(parv[1]) == 1 &&
-#endif
- !(acptr = FindNServer(parv[1]))))
- return 0; /* no such server/user exists; forget it */
- else
-#if 1
-/*
- * REMOVE THIS after all servers upgraded to 2.10.01 and
- * Uworld uses a numeric too
- */
- if (IsServer(acptr) || !MyConnect(acptr))
-#endif
- {
- /* single destination */
- sendto_one(acptr,
- active ? "%s " TOK_GLINE " %s +%s %s :%s" : "%s " TOK_GLINE " %s -%s",
- NumServ(sptr), parv[1], parv[2], parv[3], parv[4]);
- return 0; /* only the intended destination
- should add this gline */
- }
-
- if (!(host = strchr(parv[2], '@'))) {
- /*
- * convert user@host no @'s; assume username is '*'
- */
- user = "*";
- host = parv[2];
- }
- else {
- user = parv[2];
- *(host++) = '\0'; /* break up string at the '@' */
- }
- ip_mask = check_if_ipmask(host); /* Store this boolean */
-#ifdef BADCHAN
- if ('#' == *host || '&' == *host || '+' == *host)
- gtype = 1; /* BAD CHANNEL GLINE */
-#endif
- for (gline = (gtype) ? BadChanGlineList : GlobalGlineList, prev = 0; gline;
- gline = gline->next)
- {
- if (0 == ircd_strcmp(gline->name, user) &&
- 0 == ircd_strcmp(gline->host, host))
- break;
- prev = gline;
- }
-
- if (!active && gline)
- {
- /*
- * removing the gline, notify opers
- */
- sendto_op_mask(SNO_GLINE, "%s removing %s for %s@%s", parv[0],
- gtype ? "BADCHAN" : "GLINE", gline->name, gline->host);
-
-#ifdef GPATH
- write_log(GPATH, "# " TIME_T_FMT " %s removing %s for %s@%s\n",
- TStime(), parv[0], gtype ? "BADCHAN" : "GLINE", gline->name,
- gline->host);
-#endif /* GPATH */
-
- free_gline(gline, prev); /* remove the gline */
- }
- else if (active)
- { /* must be adding a gline */
- expire = atoi(parv[3]) + TStime(); /* expire time? */
- if (gline && gline->expire < expire)
- { /* new expire time? */
- /* yes, notify the opers */
- sendto_op_mask(SNO_GLINE,
- "%s resetting expiration time on %s for %s@%s to " TIME_T_FMT,
- parv[0], gtype ? "BADCHAN" : "GLINE", gline->name, gline->host,
- expire);
-#ifdef GPATH
- write_log(GPATH, "# " TIME_T_FMT " %s resetting expiration time "
- "on %s for %s@%s to " TIME_T_FMT "\n",
- TStime(), parv[0], gtype ? "BADCHAN" : "GLINE",
- gline->name, gline->host, expire);
-#endif /* GPATH */
-
- gline->expire = expire; /* reset the expire time */
- }
- else if (!gline)
- { /* create gline */
- for (gline = (gtype) ? BadChanGlineList : GlobalGlineList; gline; gline = gline->next)
- if (!mmatch(gline->name, user) &&
- (ip_mask ? GlineIsIpMask(gline) : !GlineIsIpMask(gline)) &&
- !mmatch(gline->host, host))
- return 0; /* found an existing G-line that matches */
-
- /* add the line: */
- add_gline(sptr, ip_mask, host, parv[4], user, expire, 0);
- }
- }
- }
- }
- else if (parc < 2 || *parv[1] == '\0')
- {
- /* Not enough args and a user; list glines */
- for (gline = GlobalGlineList; gline; gline = gline->next)
- sendto_one(cptr, rpl_str(RPL_GLIST), me.name, parv[0],
- gline->name, gline->host, gline->expire, gline->reason,
- GlineIsActive(gline) ? (GlineIsLocal(gline) ? " (local)" : "") :
- " (Inactive)");
- sendto_one(cptr, rpl_str(RPL_ENDOFGLIST), me.name, parv[0]);
- }
- else
- {
- int priv;
-
-#ifdef LOCOP_LGLINE
- priv = IsAnOper(cptr);
-#else
- priv = IsOper(cptr);
-#endif
-
- if (priv)
- { /* non-oper not permitted to change things */
- if (*parv[1] == '-')
- { /* oper wants to deactivate the gline */
- active = 0;
- parv[1]++;
- }
- else if (*parv[1] == '+')
- { /* oper wants to activate inactive gline */
- active = 1;
- parv[1]++;
- }
- else
- active = -1;
-
- if (parc > 2)
- expire = atoi(parv[2]) + TStime(); /* oper wants to reset
- expire TS */
- }
- else
- active = -1;
-
- if (!(host = strchr(parv[1], '@')))
- {
- user = "*"; /* no @'s; assume username is '*' */
- host = parv[1];
- }
- else
- {
- user = parv[1];
- *(host++) = '\0'; /* break up string at the '@' */
- }
- ip_mask = check_if_ipmask(host); /* Store this boolean */
-#ifdef BADCHAN
- if ('#' == *host || '&' == *host || '+' == *host)
-#ifndef LOCAL_BADCHAN
- return 0;
-#else
- gtype = 1; /* BAD CHANNEL */
-#endif
-#endif
-
- for (gline = (gtype) ? BadChanGlineList : GlobalGlineList, prev = 0; gline;
- gline = gline->next)
- {
- if (!mmatch(gline->name, user) &&
- (ip_mask ? GlineIsIpMask(gline) : !GlineIsIpMask(gline)) &&
- !mmatch(gline->host, host))
- break;
- prev = gline;
- }
-
- if (!gline)
- {
-#ifdef OPER_LGLINE
- if (priv && active && expire > CurrentTime)
- {
- /* Add local G-line */
- if (parc < 4 || !strchr(parv[3], ' '))
- return need_more_params(sptr, "GLINE");
-
- add_gline(sptr, ip_mask, host, parv[3], user, expire, 1);
- }
- else
-#endif
- sendto_one(cptr, err_str(ERR_NOSUCHGLINE), me.name, parv[0], user,
- host);
-
- return 0;
- }
-
- if (expire <= gline->expire)
- expire = 0;
-
- if ((active == -1 ||
- (active ? GlineIsActive(gline) : !GlineIsActive(gline))) &&
- expire == 0)
- {
- /* oper wants a list of one gline only */
- sendto_one(cptr, rpl_str(RPL_GLIST), me.name, parv[0], gline->name,
- gline->host, gline->expire, gline->reason,
- GlineIsActive(gline) ? "" : " (Inactive)");
- sendto_one(cptr, rpl_str(RPL_ENDOFGLIST), me.name, parv[0]);
- return 0;
- }
-
- if (active != -1 &&
- (active ? !GlineIsActive(gline) : GlineIsActive(gline)))
- {
- if (active) /* reset activation on gline */
- SetActive(gline);
-#ifdef OPER_LGLINE
- else if (GlineIsLocal(gline))
- {
- /* Remove local G-line */
- sendto_op_mask(SNO_GLINE, "%s removed local %s for %s@%s",
- parv[0], gtype ? "BADCHAN" : "GLINE", gline->name, gline->host);
-#ifdef GPATH
- write_log(GPATH, "# " TIME_T_FMT
- " %s!%s@%s removed local %s for %s@%s\n",
- TStime(), parv[0], cptr->user->username, cptr->user->host,
- gtype ? "BADCHAN" : "GLINE",
- gline->name, gline->host);
-#endif /* GPATH */
- free_gline(gline, prev); /* remove the gline */
- return 0;
- }
-#endif
- else
- ClearActive(gline);
- }
- else
- active = -1; /* for later sendto_ops and logging functions */
-
- if (expire)
- gline->expire = expire; /* reset expiration time */
-
- /* inform the operators what's up */
- if (active != -1)
- { /* changing the activation */
- sendto_op_mask(SNO_GLINE, !expire ? "%s %sactivating %s for %s@%s" :
- "%s %sactivating %s for %s@%s and "
- "resetting expiration time to " TIME_T_FMT,
- parv[0], active ? "re" : "de", gtype ? "BADCHAN" : "GLINE",
- gline->name, gline->host, gline->expire);
-#ifdef GPATH
- write_log(GPATH, !expire ? "# " TIME_T_FMT " %s!%s@%s %sactivating "
- "%s for %s@%s\n" : "# " TIME_T_FMT " %s!%s@%s %sactivating %s "
- "for %s@%s and resetting expiration time to " TIME_T_FMT "\n",
- TStime(), parv[0], cptr->user->username, cptr->user->host,
- active ? "re" : "de", gtype ? "BADCHAN" : "GLINE", gline->name,
- gline->host, gline->expire);
-#endif /* GPATH */
-
- }
- else if (expire)
- { /* changing only the expiration */
- sendto_op_mask(SNO_GLINE,
- "%s resetting expiration time on %s for %s@%s to " TIME_T_FMT,
- parv[0], gtype ? "BADCHAN" : "GLINE", gline->name, gline->host,
- gline->expire);
-#ifdef GPATH
- write_log(GPATH, "# " TIME_T_FMT " %s!%s@%s resetting expiration "
- "time on %s for %s@%s to " TIME_T_FMT "\n", TStime(), parv[0],
- cptr->user->username, cptr->user->host, gtype ? "BADCHAN" : "GLINE",
- gline->name, gline->host, gline->expire);
-#endif /* GPATH */
- }
- }
- return 0;
-}
-
-/*
- * mo_gline - oper message handler
- *
- * parv[0] = Send prefix
- *
- * From server:
- *
- * parv[1] = Target: server numeric
- * parv[2] = [+|-]<G-line mask>
- * parv[3] = Expiration offset
- * parv[4] = Comment
- *
- * From client:
- *
- * parv[1] = [+|-]<G-line mask>
- * parv[2] = Expiration offset
- * parv[3] = Comment
- *
- */
-int mo_gline(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
-{
- struct Client* acptr = 0; /* Init. to avoid compiler warning. */
- struct Gline* gline;
- struct Gline* prev;
- char* user;
- char* host;
- int active;
- int ip_mask;
- int gtype = 0;
- time_t expire = 0;
-
- /*
- * Remove expired G-lines
- */
- gline_remove_expired(TStime());
-#ifdef BADCHAN
- /*
- * Remove expired bad channels
- */
- bad_channel_remove_expired(TStime());
-#endif
-
- if (IsServer(cptr)) {
- if (find_conf_byhost(cptr->confs, sptr->name, CONF_UWORLD)) {
- if (parc < 3 || (*parv[2] != '-' && (parc < 5 || *parv[4] == '\0')))
- return need_more_params(sptr, "GLINE");
-
- if (*parv[2] == '-') /* add mode or delete mode? */
- active = 0;
- else
- active = 1;
-
- if (*parv[2] == '+' || *parv[2] == '-')
- parv[2]++; /* step past mode indicator */
-
- /*
- * forward the message appropriately
- */
- if (0 == ircd_strcmp(parv[1], "*")) {
- /*
- * global!
- */
- sendto_serv_butone(cptr,
- active ? "%s " TOK_GLINE " %s +%s %s :%s" : "%s " TOK_GLINE " %s -%s",
- NumServ(sptr), parv[1], parv[2], parv[3], parv[4]);
- }
- else if ((
-#if 1
- /*
- * REMOVE THIS after all servers upgraded to 2.10.01 and
- * Uworld uses a numeric too
- */
- (strlen(parv[1]) != 1 && !(acptr = FindClient(parv[1])))) ||
- (strlen(parv[1]) == 1 &&
-#endif
- !(acptr = FindNServer(parv[1]))))
- return 0; /* no such server/user exists; forget it */
- else
-#if 1
-/*
- * REMOVE THIS after all servers upgraded to 2.10.01 and
- * Uworld uses a numeric too
- */
- if (IsServer(acptr) || !MyConnect(acptr))
-#endif
- {
- /* single destination */
- sendto_one(acptr,
- active ? "%s " TOK_GLINE " %s +%s %s :%s" : "%s " TOK_GLINE " %s -%s",
- NumServ(sptr), parv[1], parv[2], parv[3], parv[4]);
- return 0; /* only the intended destination
- should add this gline */
- }
-
- if (!(host = strchr(parv[2], '@'))) {
- /*
- * convert user@host no @'s; assume username is '*'
- */
- user = "*";
- host = parv[2];
- }
- else {
- user = parv[2];
- *(host++) = '\0'; /* break up string at the '@' */
- }
- ip_mask = check_if_ipmask(host); /* Store this boolean */
-#ifdef BADCHAN
- if ('#' == *host || '&' == *host || '+' == *host)
- gtype = 1; /* BAD CHANNEL GLINE */
-#endif
- for (gline = (gtype) ? BadChanGlineList : GlobalGlineList, prev = 0; gline;
- gline = gline->next)
- {
- if (0 == ircd_strcmp(gline->name, user) &&
- 0 == ircd_strcmp(gline->host, host))
- break;
- prev = gline;
- }
-
- if (!active && gline)
- {
- /*
- * removing the gline, notify opers
- */
- sendto_op_mask(SNO_GLINE, "%s removing %s for %s@%s", parv[0],
- gtype ? "BADCHAN" : "GLINE", gline->name, gline->host);
-
-#ifdef GPATH
- write_log(GPATH, "# " TIME_T_FMT " %s removing %s for %s@%s\n",
- TStime(), parv[0], gtype ? "BADCHAN" : "GLINE", gline->name,
- gline->host);
-#endif /* GPATH */
-
- free_gline(gline, prev); /* remove the gline */
- }
- else if (active)
- { /* must be adding a gline */
- expire = atoi(parv[3]) + TStime(); /* expire time? */
- if (gline && gline->expire < expire)
- { /* new expire time? */
- /* yes, notify the opers */
- sendto_op_mask(SNO_GLINE,
- "%s resetting expiration time on %s for %s@%s to " TIME_T_FMT,
- parv[0], gtype ? "BADCHAN" : "GLINE", gline->name, gline->host,
- expire);
-#ifdef GPATH
- write_log(GPATH, "# " TIME_T_FMT " %s resetting expiration time "
- "on %s for %s@%s to " TIME_T_FMT "\n",
- TStime(), parv[0], gtype ? "BADCHAN" : "GLINE",
- gline->name, gline->host, expire);
-#endif /* GPATH */
-
- gline->expire = expire; /* reset the expire time */
- }
- else if (!gline)
- { /* create gline */
- for (gline = (gtype) ? BadChanGlineList : GlobalGlineList; gline; gline = gline->next)
- if (!mmatch(gline->name, user) &&
- (ip_mask ? GlineIsIpMask(gline) : !GlineIsIpMask(gline)) &&
- !mmatch(gline->host, host))
- return 0; /* found an existing G-line that matches */
-
- /* add the line: */
- add_gline(sptr, ip_mask, host, parv[4], user, expire, 0);
- }
- }
- }
- }
- else if (parc < 2 || *parv[1] == '\0')
- {
- /* Not enough args and a user; list glines */
- for (gline = GlobalGlineList; gline; gline = gline->next)
- sendto_one(cptr, rpl_str(RPL_GLIST), me.name, parv[0],
- gline->name, gline->host, gline->expire, gline->reason,
- GlineIsActive(gline) ? (GlineIsLocal(gline) ? " (local)" : "") :
- " (Inactive)");
- sendto_one(cptr, rpl_str(RPL_ENDOFGLIST), me.name, parv[0]);
- }
- else
- {
- int priv;
-
-#ifdef LOCOP_LGLINE
- priv = IsAnOper(cptr);
-#else
- priv = IsOper(cptr);
-#endif
-
- if (priv)
- { /* non-oper not permitted to change things */
- if (*parv[1] == '-')
- { /* oper wants to deactivate the gline */
- active = 0;
- parv[1]++;
- }
- else if (*parv[1] == '+')
- { /* oper wants to activate inactive gline */
- active = 1;
- parv[1]++;
- }
- else
- active = -1;
-
- if (parc > 2)
- expire = atoi(parv[2]) + TStime(); /* oper wants to reset
- expire TS */
- }
- else
- active = -1;
-
- if (!(host = strchr(parv[1], '@')))
- {
- user = "*"; /* no @'s; assume username is '*' */
- host = parv[1];
- }
- else
- {
- user = parv[1];
- *(host++) = '\0'; /* break up string at the '@' */
- }
- ip_mask = check_if_ipmask(host); /* Store this boolean */
-#ifdef BADCHAN
- if ('#' == *host || '&' == *host || '+' == *host)
-#ifndef LOCAL_BADCHAN
- return 0;
-#else
- gtype = 1; /* BAD CHANNEL */
-#endif
-#endif
-
- for (gline = (gtype) ? BadChanGlineList : GlobalGlineList, prev = 0; gline;
- gline = gline->next)
- {
- if (!mmatch(gline->name, user) &&
- (ip_mask ? GlineIsIpMask(gline) : !GlineIsIpMask(gline)) &&
- !mmatch(gline->host, host))
- break;
- prev = gline;
- }
-
- if (!gline)
- {
-#ifdef OPER_LGLINE
- if (priv && active && expire > CurrentTime)
- {
- /* Add local G-line */
- if (parc < 4 || !strchr(parv[3], ' '))
- return need_more_params(sptr, "GLINE");
-
- add_gline(sptr, ip_mask, host, parv[3], user, expire, 1);
- }
- else
-#endif
- sendto_one(cptr, err_str(ERR_NOSUCHGLINE), me.name, parv[0], user,
- host);
-
- return 0;
- }
-
- if (expire <= gline->expire)
- expire = 0;
-
- if ((active == -1 ||
- (active ? GlineIsActive(gline) : !GlineIsActive(gline))) &&
- expire == 0)
- {
- /* oper wants a list of one gline only */
- sendto_one(cptr, rpl_str(RPL_GLIST), me.name, parv[0], gline->name,
- gline->host, gline->expire, gline->reason,
- GlineIsActive(gline) ? "" : " (Inactive)");
- sendto_one(cptr, rpl_str(RPL_ENDOFGLIST), me.name, parv[0]);
- return 0;
- }
-
- if (active != -1 &&
- (active ? !GlineIsActive(gline) : GlineIsActive(gline)))
- {
- if (active) /* reset activation on gline */
- SetActive(gline);
-#ifdef OPER_LGLINE
- else if (GlineIsLocal(gline))
- {
- /* Remove local G-line */
- sendto_op_mask(SNO_GLINE, "%s removed local %s for %s@%s",
- parv[0], gtype ? "BADCHAN" : "GLINE", gline->name, gline->host);
-#ifdef GPATH
- write_log(GPATH, "# " TIME_T_FMT
- " %s!%s@%s removed local %s for %s@%s\n",
- TStime(), parv[0], cptr->user->username, cptr->user->host,
- gtype ? "BADCHAN" : "GLINE",
- gline->name, gline->host);
-#endif /* GPATH */
- free_gline(gline, prev); /* remove the gline */
- return 0;
- }
-#endif
- else
- ClearActive(gline);
- }
- else
- active = -1; /* for later sendto_ops and logging functions */
-
- if (expire)
- gline->expire = expire; /* reset expiration time */
-
- /* inform the operators what's up */
- if (active != -1)
- { /* changing the activation */
- sendto_op_mask(SNO_GLINE, !expire ? "%s %sactivating %s for %s@%s" :
- "%s %sactivating %s for %s@%s and "
- "resetting expiration time to " TIME_T_FMT,
- parv[0], active ? "re" : "de", gtype ? "BADCHAN" : "GLINE",
- gline->name, gline->host, gline->expire);
-#ifdef GPATH
- write_log(GPATH, !expire ? "# " TIME_T_FMT " %s!%s@%s %sactivating "
- "%s for %s@%s\n" : "# " TIME_T_FMT " %s!%s@%s %sactivating %s "
- "for %s@%s and resetting expiration time to " TIME_T_FMT "\n",
- TStime(), parv[0], cptr->user->username, cptr->user->host,
- active ? "re" : "de", gtype ? "BADCHAN" : "GLINE", gline->name,
- gline->host, gline->expire);
-#endif /* GPATH */
-
- }
- else if (expire)
- { /* changing only the expiration */
- sendto_op_mask(SNO_GLINE,
- "%s resetting expiration time on %s for %s@%s to " TIME_T_FMT,
- parv[0], gtype ? "BADCHAN" : "GLINE", gline->name, gline->host,
- gline->expire);
-#ifdef GPATH
- write_log(GPATH, "# " TIME_T_FMT " %s!%s@%s resetting expiration "
- "time on %s for %s@%s to " TIME_T_FMT "\n", TStime(), parv[0],
- cptr->user->username, cptr->user->host, gtype ? "BADCHAN" : "GLINE",
- gline->name, gline->host, gline->expire);
-#endif /* GPATH */
- }
- }
- return 0;
-}
-
-
-#if 0
-/*
- * m_gline
- *
- * parv[0] = Send prefix
- *
- * From server:
- *
- * parv[1] = Target: server numeric
- * parv[2] = [+|-]<G-line mask>
- * parv[3] = Expiration offset
- * parv[4] = Comment
- *
- * From client:
- *
- * parv[1] = [+|-]<G-line mask>
- * parv[2] = Expiration offset
- * parv[3] = Comment
- *
- */
-int m_gline(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
-{
- struct Client* acptr = 0; /* Init. to avoid compiler warning. */
- struct Gline* gline;
- struct Gline* prev;
- char* user;
- char* host;
- int active;
- int ip_mask;
- int gtype = 0;
- time_t expire = 0;
-
- /*
- * Remove expired G-lines
- */
- gline_remove_expired(TStime());
-#ifdef BADCHAN
- /*
- * Remove expired bad channels
- */
- bad_channel_remove_expired(TStime());
-#endif
-
- if (IsServer(cptr)) {
- if (find_conf_byhost(cptr->confs, sptr->name, CONF_UWORLD)) {
- if (parc < 3 || (*parv[2] != '-' && (parc < 5 || *parv[4] == '\0')))
- return need_more_params(sptr, "GLINE");
-
- if (*parv[2] == '-') /* add mode or delete mode? */
- active = 0;
- else
- active = 1;
-
- if (*parv[2] == '+' || *parv[2] == '-')
- parv[2]++; /* step past mode indicator */
-
- /*
- * forward the message appropriately
- */
- if (0 == ircd_strcmp(parv[1], "*")) {
- /*
- * global!
- */
- sendto_serv_butone(cptr,
- active ? "%s " TOK_GLINE " %s +%s %s :%s" : "%s " TOK_GLINE " %s -%s",
- NumServ(cptr), parv[1], parv[2], parv[3], parv[4]);
- }
- else if ((
-#if 1
- /*
- * REMOVE THIS after all servers upgraded to 2.10.01 and
- * Uworld uses a numeric too
- */
- (strlen(parv[1]) != 1 && !(acptr = FindClient(parv[1])))) ||
- (strlen(parv[1]) == 1 &&
-#endif
- !(acptr = FindNServer(parv[1]))))
- return 0; /* no such server/user exists; forget it */
- else
-#if 1
-/*
- * REMOVE THIS after all servers upgraded to 2.10.01 and
- * Uworld uses a numeric too
- */
- if (IsServer(acptr) || !MyConnect(acptr))
-#endif
- {
- /* single destination */
- sendto_one(acptr,
- active ? "%s " TOK_GLINE " %s +%s %s :%s" : "%s " TOK_GLINE " %s -%s",
- NumServ(sptr), parv[1], parv[2], parv[3], parv[4]);
- return 0; /* only the intended destination
- should add this gline */
- }
-
- if (!(host = strchr(parv[2], '@'))) {
- /*
- * convert user@host no @'s; assume username is '*'
- */
- user = "*";
- host = parv[2];
- }
- else {
- user = parv[2];
- *(host++) = '\0'; /* break up string at the '@' */
- }
- ip_mask = check_if_ipmask(host); /* Store this boolean */
-#ifdef BADCHAN
- if ('#' == *host || '&' == *host || '+' == *host)
- gtype = 1; /* BAD CHANNEL GLINE */
-#endif
- for (gline = (gtype) ? BadChanGlineList : GlobalGlineList, prev = 0; gline;
- gline = gline->next)
- {
- if (0 == ircd_strcmp(gline->name, user) &&
- 0 == ircd_strcmp(gline->host, host))
- break;
- prev = gline;
- }
-
- if (!active && gline)
- {
- /*
- * removing the gline, notify opers
- */
- sendto_op_mask(SNO_GLINE, "%s removing %s for %s@%s", parv[0],
- gtype ? "BADCHAN" : "GLINE", gline->name, gline->host);
-
-#ifdef GPATH
- write_log(GPATH, "# " TIME_T_FMT " %s removing %s for %s@%s\n",
- TStime(), parv[0], gtype ? "BADCHAN" : "GLINE", gline->name,
- gline->host);
-#endif /* GPATH */
-
- free_gline(gline, prev); /* remove the gline */
- }
- else if (active)
- { /* must be adding a gline */
- expire = atoi(parv[3]) + TStime(); /* expire time? */
- if (gline && gline->expire < expire)
- { /* new expire time? */
- /* yes, notify the opers */
- sendto_op_mask(SNO_GLINE,
- "%s resetting expiration time on %s for %s@%s to " TIME_T_FMT,
- parv[0], gtype ? "BADCHAN" : "GLINE", gline->name, gline->host,
- expire);
-#ifdef GPATH
- write_log(GPATH, "# " TIME_T_FMT " %s resetting expiration time "
- "on %s for %s@%s to " TIME_T_FMT "\n",
- TStime(), parv[0], gtype ? "BADCHAN" : "GLINE",
- gline->name, gline->host, expire);
-#endif /* GPATH */
-
- gline->expire = expire; /* reset the expire time */
- }
- else if (!gline)
- { /* create gline */
- for (gline = (gtype) ? BadChanGlineList : GlobalGlineList; gline; gline = gline->next)
- if (!mmatch(gline->name, user) &&
- (ip_mask ? GlineIsIpMask(gline) : !GlineIsIpMask(gline)) &&
- !mmatch(gline->host, host))
- return 0; /* found an existing G-line that matches */
-
- /* add the line: */
- add_gline(sptr, ip_mask, host, parv[4], user, expire, 0);
- }
- }
- }
- }
- else if (parc < 2 || *parv[1] == '\0')
- {
- /* Not enough args and a user; list glines */
- for (gline = GlobalGlineList; gline; gline = gline->next)
- sendto_one(cptr, rpl_str(RPL_GLIST), me.name, parv[0],
- gline->name, gline->host, gline->expire, gline->reason,
- GlineIsActive(gline) ? (GlineIsLocal(gline) ? " (local)" : "") :
- " (Inactive)");
- sendto_one(cptr, rpl_str(RPL_ENDOFGLIST), me.name, parv[0]);
- }
- else
- {
- int priv;
-
-#ifdef LOCOP_LGLINE
- priv = IsAnOper(cptr);
-#else
- priv = IsOper(cptr);
-#endif
-
- if (priv)
- { /* non-oper not permitted to change things */
- if (*parv[1] == '-')
- { /* oper wants to deactivate the gline */
- active = 0;
- parv[1]++;
- }
- else if (*parv[1] == '+')
- { /* oper wants to activate inactive gline */
- active = 1;
- parv[1]++;
- }
- else
- active = -1;
-
- if (parc > 2)
- expire = atoi(parv[2]) + TStime(); /* oper wants to reset
- expire TS */
- }
- else
- active = -1;
-
- if (!(host = strchr(parv[1], '@')))
- {
- user = "*"; /* no @'s; assume username is '*' */
- host = parv[1];
- }
- else
- {
- user = parv[1];
- *(host++) = '\0'; /* break up string at the '@' */
- }
- ip_mask = check_if_ipmask(host); /* Store this boolean */
-#ifdef BADCHAN
- if ('#' == *host || '&' == *host || '+' == *host)
-#ifndef LOCAL_BADCHAN
- return 0;
-#else
- gtype = 1; /* BAD CHANNEL */
-#endif
-#endif
-
- for (gline = (gtype) ? BadChanGlineList : GlobalGlineList, prev = 0; gline;
- gline = gline->next)
- {
- if (!mmatch(gline->name, user) &&
- (ip_mask ? GlineIsIpMask(gline) : !GlineIsIpMask(gline)) &&
- !mmatch(gline->host, host))
- break;
- prev = gline;
- }
-
- if (!gline)
- {
-#ifdef OPER_LGLINE
- if (priv && active && expire > CurrentTime)
- {
- /* Add local G-line */
- if (parc < 4 || !strchr(parv[3], ' '))
- return need_more_params(sptr, "GLINE");
-
- add_gline(sptr, ip_mask, host, parv[3], user, expire, 1);
- }
- else
-#endif
- sendto_one(cptr, err_str(ERR_NOSUCHGLINE), me.name, parv[0], user,
- host);
-
- return 0;
- }
-
- if (expire <= gline->expire)
- expire = 0;
-
- if ((active == -1 ||
- (active ? GlineIsActive(gline) : !GlineIsActive(gline))) &&
- expire == 0)
- {
- /* oper wants a list of one gline only */
- sendto_one(cptr, rpl_str(RPL_GLIST), me.name, parv[0], gline->name,
- gline->host, gline->expire, gline->reason,
- GlineIsActive(gline) ? "" : " (Inactive)");
- sendto_one(cptr, rpl_str(RPL_ENDOFGLIST), me.name, parv[0]);
- return 0;
- }
-
- if (active != -1 &&
- (active ? !GlineIsActive(gline) : GlineIsActive(gline)))
- {
- if (active) /* reset activation on gline */
- SetActive(gline);
-#ifdef OPER_LGLINE
- else if (GlineIsLocal(gline))
- {
- /* Remove local G-line */
- sendto_op_mask(SNO_GLINE, "%s removed local %s for %s@%s",
- parv[0], gtype ? "BADCHAN" : "GLINE", gline->name, gline->host);
-#ifdef GPATH
- write_log(GPATH, "# " TIME_T_FMT
- " %s!%s@%s removed local %s for %s@%s\n",
- TStime(), parv[0], cptr->user->username, cptr->user->host,
- gtype ? "BADCHAN" : "GLINE",
- gline->name, gline->host);
-#endif /* GPATH */
- free_gline(gline, prev); /* remove the gline */
- return 0;
- }
-#endif
- else
- ClearActive(gline);
- }
- else
- active = -1; /* for later sendto_ops and logging functions */
-
- if (expire)
- gline->expire = expire; /* reset expiration time */
-
- /* inform the operators what's up */
- if (active != -1)
- { /* changing the activation */
- sendto_op_mask(SNO_GLINE, !expire ? "%s %sactivating %s for %s@%s" :
- "%s %sactivating %s for %s@%s and "
- "resetting expiration time to " TIME_T_FMT,
- parv[0], active ? "re" : "de", gtype ? "BADCHAN" : "GLINE",
- gline->name, gline->host, gline->expire);
-#ifdef GPATH
- write_log(GPATH, !expire ? "# " TIME_T_FMT " %s!%s@%s %sactivating "
- "%s for %s@%s\n" : "# " TIME_T_FMT " %s!%s@%s %sactivating %s "
- "for %s@%s and resetting expiration time to " TIME_T_FMT "\n",
- TStime(), parv[0], cptr->user->username, cptr->user->host,
- active ? "re" : "de", gtype ? "BADCHAN" : "GLINE", gline->name,
- gline->host, gline->expire);
-#endif /* GPATH */
-
- }
- else if (expire)
- { /* changing only the expiration */
- sendto_op_mask(SNO_GLINE,
- "%s resetting expiration time on %s for %s@%s to " TIME_T_FMT,
- parv[0], gtype ? "BADCHAN" : "GLINE", gline->name, gline->host,
- gline->expire);
-#ifdef GPATH
- write_log(GPATH, "# " TIME_T_FMT " %s!%s@%s resetting expiration "
- "time on %s for %s@%s to " TIME_T_FMT "\n", TStime(), parv[0],
- cptr->user->username, cptr->user->host, gtype ? "BADCHAN" : "GLINE",
- gline->name, gline->host, gline->expire);
-#endif /* GPATH */
- }
- }
- return 0;
-}
-
-#endif /* 0 */
-
-#endif /* 0 */