2 * IRC - Internet Relay Chat, ircd/opercmds.c (formerly ircd/s_serv.c)
3 * Copyright (C) 1990 Jarkko Oikarinen and
4 * University of Oulu, Computing Center
6 * See file AUTHORS in IRC package for additional names of
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 1, or (at your option)
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
51 #include "sprintf_irc.h"
66 * parv[0] = sender prefix
67 * parv[1] = server name
69 * parv[parc-1] = comment
71 int m_squit(aClient *cptr, aClient *sptr, int parc, char *parv[])
73 Reg1 aConfItem *aconf;
76 char *comment = (parc > ((!IsServer(cptr)) ? 2 : 3) &&
77 !BadPtr(parv[parc - 1])) ? parv[parc - 1] : cptr->name;
79 if (!IsPrivileged(sptr))
81 sendto_one(sptr, err_str(ERR_NOPRIVILEGES), me.name, parv[0]);
85 if (parc > (IsServer(cptr) ? 2 : 1))
89 * To accomodate host masking, a squit for a masked server
90 * name is expanded if the incoming mask is the same as
91 * the server name for that link to the name of link.
93 if ((*server == '*') && IsServer(cptr) && (aconf = cptr->serv->nline) &&
94 !strCasediff(server, my_name_for_link(me.name, aconf)))
102 * The following allows wild cards in SQUIT. Only usefull
103 * when the command is issued by an oper.
105 for (acptr = client; (acptr = next_client(acptr, server));
107 if (IsServer(acptr) || IsMe(acptr))
117 server = cptr->sockhost;
125 * Look for a matching server that is closer,
126 * that way we won't accidently squit two close
127 * servers like davis.* and davis-r.* when typing
131 for (acptr2 = acptr->serv->up; acptr2 != &me;
132 acptr2 = acptr2->serv->up)
133 if (!match(server, acptr2->name))
138 /* If atoi(parv[2]) == 0 we must indeed squit !
139 * It wil be our neighbour.
141 if (acptr && IsServer(cptr) &&
142 atoi(parv[2]) && atoi(parv[2]) != acptr->serv->timestamp)
144 Debug((DEBUG_NOTICE, "Ignoring SQUIT with wrong timestamp"));
150 sendto_one(cptr, err_str(ERR_NEEDMOREPARAMS), me.name, parv[0], "SQUIT");
154 * This is actually protocol error. But, well, closing
155 * the link is very proper answer to that...
157 server = cptr->sockhost;
166 sendto_one(sptr, err_str(ERR_NOSUCHSERVER), me.name, parv[0], server);
169 if (IsLocOp(sptr) && !MyConnect(acptr))
171 sendto_one(sptr, err_str(ERR_NOPRIVILEGES), me.name, parv[0]);
175 return exit_client(cptr, acptr, sptr, comment);
181 * Report N/C-configuration lines from this server. This could
182 * report other configuration lines too, but converting the
183 * status back to "char" is a bit akward--not worth the code
186 * Note: The info is reported in the order the server uses
187 * it--not reversed as in ircd.conf!
190 static unsigned int report_array[17][3] = {
191 {CONF_CONNECT_SERVER, RPL_STATSCLINE, 'C'},
192 {CONF_NOCONNECT_SERVER, RPL_STATSNLINE, 'N'},
193 {CONF_CLIENT, RPL_STATSILINE, 'I'},
194 {CONF_KILL, RPL_STATSKLINE, 'K'},
195 {CONF_IPKILL, RPL_STATSKLINE, 'k'},
196 {CONF_LEAF, RPL_STATSLLINE, 'L'},
197 {CONF_OPERATOR, RPL_STATSOLINE, 'O'},
198 {CONF_HUB, RPL_STATSHLINE, 'H'},
199 {CONF_LOCOP, RPL_STATSOLINE, 'o'},
200 {CONF_CRULEALL, RPL_STATSDLINE, 'D'},
201 {CONF_CRULEAUTO, RPL_STATSDLINE, 'd'},
202 {CONF_UWORLD, RPL_STATSULINE, 'U'},
203 {CONF_TLINES, RPL_STATSTLINE, 'T'},
204 {CONF_LISTEN_PORT, RPL_STATSPLINE, 'P'},
208 static void report_configured_links(aClient *sptr, int mask)
210 static char null[] = "<NULL>";
213 unsigned short int port;
214 char c, *host, *pass, *name;
216 for (tmp = conf; tmp; tmp = tmp->next)
217 if ((tmp->status & mask))
219 for (p = &report_array[0][0]; *p; p += 3)
220 if (*p == tmp->status)
225 host = BadPtr(tmp->host) ? null : tmp->host;
226 pass = BadPtr(tmp->passwd) ? null : tmp->passwd;
227 name = BadPtr(tmp->name) ? null : tmp->name;
230 * On K line the passwd contents can be
231 * displayed on STATS reply. -Vesa
233 /* Special-case 'k' or 'K' lines as appropriate... -Kev */
234 if ((tmp->status & CONF_KLINE))
235 sendto_one(sptr, rpl_str(p[1]), me.name,
236 sptr->name, c, host, pass, name, port, get_conf_class(tmp));
237 /* connect rules are classless */
238 else if ((tmp->status & CONF_CRULE))
239 sendto_one(sptr, rpl_str(p[1]), me.name, sptr->name, c, host, name);
240 else if ((tmp->status & CONF_TLINES))
241 sendto_one(sptr, rpl_str(p[1]), me.name, sptr->name, c, host, pass);
242 else if ((tmp->status & CONF_LISTEN_PORT))
243 sendto_one(sptr, rpl_str(p[1]), me.name, sptr->name, c, port,
244 tmp->clients, tmp->status);
245 else if ((tmp->status & CONF_UWORLD))
246 sendto_one(sptr, rpl_str(p[1]),
247 me.name, sptr->name, c, host, pass, name, port,
248 get_conf_class(tmp));
250 sendto_one(sptr, rpl_str(p[1]), me.name, sptr->name, c, host, name,
251 port, get_conf_class(tmp));
259 * parv[0] = sender prefix
260 * parv[1] = statistics selector (defaults to Message frequency)
261 * parv[2] = target server (current server defaulted, if omitted)
262 * And 'stats l' and 'stats' L:
263 * parv[3] = server mask ("*" defaulted, if omitted)
265 * parv[3] = port mask (returns p-lines when its port is matched by this)
266 * Or for stats k,K,i and I:
267 * parv[3] = [user@]host.name (returns which K/I-lines match this)
268 * or [user@]host.mask (returns which K/I-lines are mmatched by this)
269 * (defaults to old reply if ommitted, when local or Oper)
270 * A remote mask (something containing wildcards) is only
271 * allowed for IRC Operators.
273 * parv[3] = time param
274 * parv[4] = time param
275 * (see report_memleak_stats() in runmalloc.c for details)
277 * This function is getting really ugly. -Ghostwolf
279 int m_stats(aClient *cptr, aClient *sptr, int parc, char *parv[])
281 static char Sformat[] = ":%s %d %s Connection SendQ SendM SendKBytes "
282 "RcveM RcveKBytes :Open since";
283 static char Lformat[] = ":%s %d %s %s %u %u %u %u %u :" TIME_T_FMT;
286 aGline *agline, *a2gline;
288 char stat = parc > 1 ? parv[1][0] : '\0';
291 /* m_stats is so obnoxiously full of special cases that the different
292 * hunt_server() possiblites were becoming very messy. It now uses a
293 * switch() so as to be easier to read and update as params change.
298 /* open to all, standard # of params */
302 if (hunt_server(0, cptr, sptr, ":%s STATS %s :%s", 2, parc, parv)
308 /* open to all, varying # of params */
318 if (hunt_server(0, cptr, sptr, ":%s STATS %s %s :%s", 2, parc, parv)
324 if (hunt_server(0, cptr, sptr, ":%s STATS %s :%s", 2, parc, parv)
331 /* oper only, varying # of params */
338 if (hunt_server(1, cptr, sptr, ":%s STATS %s %s :%s", 2, parc, parv)
344 if (hunt_server(1, cptr, sptr, ":%s STATS %s %s %s :%s", 2, parc,
345 parv) != HUNTED_ISME)
348 else if (hunt_server(1, cptr, sptr, ":%s STATS %s :%s", 2, parc, parv)
354 /* oper only, standard # of params */
357 if (hunt_server(1, cptr, sptr, ":%s STATS %s :%s", 2, parc, parv)
369 int doall = 0, wilds = 0;
371 if (parc > 3 && *parv[3])
375 wilds = (*name == '*' || *name == '?');
376 for (p = name + 1; *p; ++p)
377 if ((*p == '*' || *p == '?') && p[-1] != '\\')
386 * Send info about connections which match, or all if the
387 * mask matches me.name. Only restrictions are on those who
388 * are invisible not being visible to 'foreigners' who use
389 * a wild card based search to list it.
391 sendto_one(sptr, Sformat, me.name, RPL_STATSLINKINFO, parv[0]);
392 for (i = 0; i <= highest_fd; i++)
394 if (!(acptr = loc_clients[i]))
396 /* Don't return clients when this is a request for `all' */
397 if (doall && IsUser(acptr))
399 /* Don't show invisible people to unauthorized people when using
400 * wildcards -- Is this still needed now /stats is oper only ? */
401 if (IsInvisible(acptr) && (doall || wilds) &&
402 !(MyConnect(sptr) && IsOper(sptr)) &&
403 !IsAnOper(acptr) && (acptr != sptr))
405 /* Only show the ones that match the given mask - if any */
406 if (!doall && wilds && match(name, acptr->name))
408 /* Skip all that do not match the specific query */
409 if (!(doall || wilds) && strCasediff(name, acptr->name))
411 sendto_one(sptr, Lformat, me.name, RPL_STATSLINKINFO, parv[0],
413 get_client_name(acptr, TRUE) : get_client_name(acptr, FALSE),
414 (int)DBufLength(&acptr->sendQ), (int)acptr->sendM,
415 (int)acptr->sendK, (int)acptr->receiveM, (int)acptr->receiveK,
416 time(NULL) - acptr->firsttime);
422 report_configured_links(sptr,
423 CONF_CONNECT_SERVER | CONF_NOCONNECT_SERVER);
428 for (agline = gline, a2gline = NULL; agline; agline = agline->next)
430 if (agline->expire <= TStime())
431 { /* handle expired glines */
432 free_gline(agline, a2gline);
433 agline = a2gline ? a2gline : gline; /* make sure to splice
436 break; /* last gline; break out of loop */
437 continue; /* continue! */
439 sendto_one(sptr, rpl_str(RPL_STATSGLINE), me.name,
440 sptr->name, 'G', agline->name, agline->host,
441 agline->expire, agline->reason);
447 report_configured_links(sptr, CONF_HUB | CONF_LEAF);
452 case 'k': /* display CONF_IPKILL as well
456 char *user, *host, *p;
457 int conf_status = (stat == 'k' || stat == 'K') ? CONF_KLINE : CONF_CLIENT;
458 if ((MyUser(sptr) || IsOper(sptr)) && parc < 4)
460 report_configured_links(sptr, conf_status);
463 if (parc < 4 || *parv[3] == '\0')
465 sendto_one(sptr, err_str(ERR_NEEDMOREPARAMS), me.name, parv[0],
466 (conf_status & CONF_KLINE) ? "STATS K" : "STATS I");
470 for (p = parv[3]; *p; p++)
478 if (*p == '?' || *p == '*')
484 if (!(MyConnect(sptr) || IsOper(sptr)))
492 if (conf_status == CONF_CLIENT)
494 user = NULL; /* Not used, but to avoid compiler warning. */
500 if ((host = strchr(parv[3], '@')))
511 for (aconf = conf; aconf; aconf = aconf->next)
513 if ((aconf->status & conf_status))
515 if (conf_status == CONF_KLINE)
517 if ((!wilds && ((user || aconf->host[1]) &&
518 !match(aconf->host, host) &&
519 (!user || !match(aconf->name, user)))) ||
520 (wilds && !mmatch(host, aconf->host) &&
521 (!user || !mmatch(user, aconf->name))))
523 sendto_one(sptr, rpl_str(RPL_STATSKLINE), me.name,
524 sptr->name, 'K', aconf->host, aconf->passwd, aconf->name,
525 aconf->port, get_conf_class(aconf));
530 else if (conf_status == CONF_CLIENT)
532 if ((!wilds && (!match(aconf->host, host) ||
533 !match(aconf->name, host))) ||
534 (wilds && (!mmatch(host, aconf->host) ||
535 !mmatch(host, aconf->name))))
537 sendto_one(sptr, rpl_str(RPL_STATSILINE), me.name,
538 sptr->name, 'I', aconf->host, aconf->name,
539 aconf->port, get_conf_class(aconf));
550 sendto_one(sptr, rpl_str(RPL_STATMEMTOT),
551 me.name, parv[0], get_mem_size(), get_alloc_cnt());
554 report_memleak_stats(sptr, parc, parv);
556 #if !defined(MEMSIZESTATS) && !defined(MEMLEAKSTATS)
557 sendto_one(sptr, ":%s NOTICE %s :stats M : Memory allocation monitoring "
558 "is not enabled on this server", me.name, parv[0]);
562 for (mptr = msgtab; mptr->cmd; mptr++)
564 sendto_one(sptr, rpl_str(RPL_STATSCOMMANDS),
565 me.name, parv[0], mptr->cmd, mptr->count, mptr->bytes);
569 report_configured_links(sptr, CONF_OPS);
576 if ((MyUser(sptr) || IsOper(sptr)) && parc < 4)
578 report_configured_links(sptr, CONF_LISTEN_PORT);
581 if (!(MyConnect(sptr) || IsOper(sptr)))
583 for (aconf = conf; aconf; aconf = aconf->next)
584 if (aconf->status == CONF_LISTEN_PORT)
586 if (parc >= 4 && *parv[3] != '\0')
588 sprintf_irc(port, "%u", aconf->port);
589 if (match(parv[3], port))
592 sendto_one(sptr, rpl_str(RPL_STATSPLINE), me.name, sptr->name, 'P',
593 aconf->port, aconf->clients, aconf->status);
602 send_usage(sptr, parv[0]);
606 report_configured_links(sptr, CONF_CRULEALL);
609 report_configured_links(sptr, CONF_CRULE);
612 tstats(sptr, parv[0]);
615 report_configured_links(sptr, CONF_TLINES);
618 report_configured_links(sptr, CONF_UWORLD);
622 register time_t nowr;
624 nowr = now - me.since;
625 sendto_one(sptr, rpl_str(RPL_STATSUPTIME), me.name, parv[0],
626 nowr / 86400, (nowr / 3600) % 24, (nowr / 60) % 60, nowr % 60);
627 sendto_one(sptr, rpl_str(RPL_STATSCONN), me.name, parv[0],
628 max_connection_count, max_client_count);
638 send_listinfo(sptr, parv[0]);
643 report_classes(sptr);
647 count_memory(sptr, parv[0]);
653 sendto_one(sptr, rpl_str(RPL_ENDOFSTATS), me.name, parv[0], stat);
658 * m_connect - Added by Jto 11 Feb 1989
660 * parv[0] = sender prefix
661 * parv[1] = servername
662 * parv[2] = port number
663 * parv[3] = remote server
665 int m_connect(aClient *cptr, aClient *sptr, int parc, char *parv[])
668 unsigned short int port, tmpport;
669 aConfItem *aconf, *cconf;
672 if (!IsPrivileged(sptr))
674 sendto_one(sptr, err_str(ERR_NOPRIVILEGES), me.name, parv[0]);
678 if (IsLocOp(sptr) && parc > 3) /* Only allow LocOps to make */
679 return 0; /* local CONNECTS --SRB */
681 if (parc > 3 && MyUser(sptr))
683 aClient *acptr2, *acptr3;
684 if (!(acptr3 = find_match_server(parv[3])))
686 sendto_one(sptr, err_str(ERR_NOSUCHSERVER), me.name, parv[0], parv[3]);
690 /* Look for closest matching server */
691 for (acptr2 = acptr3; acptr2 != &me; acptr2 = acptr2->serv->up)
692 if (!match(parv[3], acptr2->name))
695 parv[3] = acptr3->name;
698 if (hunt_server(1, cptr, sptr, ":%s CONNECT %s %s :%s", 3, parc, parv) !=
702 if (parc < 2 || *parv[1] == '\0')
704 sendto_one(sptr, err_str(ERR_NEEDMOREPARAMS), me.name, parv[0], "CONNECT");
708 if ((acptr = FindServer(parv[1])))
710 if (MyUser(sptr) || Protocol(cptr) < 10)
711 sendto_one(sptr, ":%s NOTICE %s :Connect: Server %s %s %s.",
712 me.name, parv[0], parv[1], "already exists from", acptr->from->name);
714 sendto_one(sptr, "%s NOTICE %s%s :Connect: Server %s %s %s.",
715 NumServ(&me), NumNick(sptr), parv[1], "already exists from",
720 for (aconf = conf; aconf; aconf = aconf->next)
721 if (aconf->status == CONF_CONNECT_SERVER &&
722 match(parv[1], aconf->name) == 0)
724 /* Checked first servernames, then try hostnames. */
726 for (aconf = conf; aconf; aconf = aconf->next)
727 if (aconf->status == CONF_CONNECT_SERVER &&
728 (match(parv[1], aconf->host) == 0 ||
729 match(parv[1], strchr(aconf->host, '@') + 1) == 0))
734 if (MyUser(sptr) || Protocol(cptr) < 10)
736 ":%s NOTICE %s :Connect: Host %s not listed in ircd.conf",
737 me.name, parv[0], parv[1]);
740 "%s NOTICE %s%s :Connect: Host %s not listed in ircd.conf",
741 NumServ(&me), NumNick(sptr), parv[1]);
745 * Get port number from user, if given. If not specified,
746 * use the default from configuration structure. If missing
747 * from there, then use the precompiled default.
749 tmpport = port = aconf->port;
750 if (parc > 2 && !BadPtr(parv[2]))
752 if ((port = atoi(parv[2])) == 0)
754 if (MyUser(sptr) || Protocol(cptr) < 10)
756 ":%s NOTICE %s :Connect: Invalid port number", me.name, parv[0]);
758 sendto_one(sptr, "%s NOTICE %s%s :Connect: Invalid port number",
759 NumServ(&me), NumNick(sptr));
763 else if (port == 0 && (port = PORTNUM) == 0)
765 if (MyUser(sptr) || Protocol(cptr) < 10)
766 sendto_one(sptr, ":%s NOTICE %s :Connect: missing port number",
769 sendto_one(sptr, "%s NOTICE %s%s :Connect: missing port number",
770 NumServ(&me), NumNick(sptr));
775 * Evaluate connection rules... If no rules found, allow the
776 * connect. Otherwise stop with the first true rule (ie: rules
777 * are ored together. Oper connects are effected only by D
778 * lines (CRULEALL) not d lines (CRULEAUTO).
780 for (cconf = conf; cconf; cconf = cconf->next)
781 if ((cconf->status == CONF_CRULEALL) &&
782 (match(cconf->host, aconf->name) == 0))
783 if (crule_eval(cconf->passwd))
785 if (MyUser(sptr) || Protocol(cptr) < 10)
786 sendto_one(sptr, ":%s NOTICE %s :Connect: Disallowed by rule: %s",
787 me.name, parv[0], cconf->name);
789 sendto_one(sptr, "%s NOTICE %s%s :Connect: Disallowed by rule: %s",
790 NumServ(&me), NumNick(sptr), cconf->name);
795 * Notify all operators about remote connect requests
799 sendto_ops_butone(NULL, &me, ":%s WALLOPS :Remote CONNECT %s %s from %s",
800 me.name, parv[1], parv[2] ? parv[2] : "", get_client_name(sptr, FALSE));
801 #if defined(USE_SYSLOG) && defined(SYSLOG_CONNECT)
803 "CONNECT From %s : %s %d", parv[0], parv[1], parv[2] ? parv[2] : "");
807 switch (retval = connect_server(aconf, sptr, NULL))
810 if (MyUser(sptr) || Protocol(cptr) < 10)
812 ":%s NOTICE %s :*** Connecting to %s[%s].",
813 me.name, parv[0], aconf->host, aconf->name);
816 "%s NOTICE %s%s :*** Connecting to %s[%s].",
817 NumServ(&me), NumNick(sptr), aconf->host, aconf->name);
820 /* Comments already sent */
823 if (MyUser(sptr) || Protocol(cptr) < 10)
824 sendto_one(sptr, ":%s NOTICE %s :*** Host %s is unknown.",
825 me.name, parv[0], aconf->host);
827 sendto_one(sptr, "%s NOTICE %s%s :*** Host %s is unknown.",
828 NumServ(&me), NumNick(sptr), aconf->host);
831 if (MyUser(sptr) || Protocol(cptr) < 10)
833 ":%s NOTICE %s :*** Connection to %s failed: %s",
834 me.name, parv[0], aconf->host, strerror(retval));
837 "%s NOTICE %s%s :*** Connection to %s failed: %s",
838 NumServ(&me), NumNick(sptr), aconf->host, strerror(retval));
840 aconf->port = tmpport;
847 * Writes to all +w users currently online
849 * parv[0] = sender prefix
850 * parv[1] = message text
852 int m_wallops(aClient *cptr, aClient *sptr, int parc, char *parv[])
856 message = parc > 1 ? parv[1] : NULL;
860 sendto_one(sptr, err_str(ERR_NEEDMOREPARAMS), me.name, parv[0], "WALLOPS");
864 if (!IsServer(sptr) && MyConnect(sptr) && !IsAnOper(sptr))
866 sendto_one(sptr, err_str(ERR_NOPRIVILEGES), me.name, parv[0]);
869 sendto_ops_butone(IsServer(cptr) ? cptr : NULL, sptr,
870 ":%s WALLOPS :%s", parv[0], message);
877 * parv[0] = sender prefix
878 * parv[1] = servername
880 int m_time(aClient *cptr, aClient *sptr, int parc, char *parv[])
882 if (hunt_server(0, cptr, sptr, ":%s TIME :%s", 1, parc, parv) == HUNTED_ISME)
883 sendto_one(sptr, rpl_str(RPL_TIME), me.name,
884 parv[0], me.name, TStime(), TSoffset, date((long)0));
891 * parv[0] = sender prefix
893 * parv[2] = servername (Only used when sptr is an Oper).
895 int m_settime(aClient *cptr, aClient *sptr, int parc, char *parv[])
899 static char tbuf[11];
902 if (!IsPrivileged(sptr))
907 sendto_one(sptr, err_str(ERR_NEEDMOREPARAMS), me.name, parv[0], "SETTIME");
911 if (parc == 2 && MyUser(sptr))
912 parv[parc++] = me.name;
917 if (t < 779557906 || dt < -9000000)
919 sendto_one(sptr, ":%s NOTICE %s :SETTIME: Bad value", me.name, parv[0]);
923 if (IsServer(sptr)) /* send to unlagged servers */
925 #ifdef RELIABLE_CLOCK
926 sprintf_irc(tbuf, TIME_T_FMT, TStime());
929 for (lp = me.serv->down; lp; lp = lp->next)
930 if (cptr != lp->value.cptr && DBufLength(&lp->value.cptr->sendQ) < 8000)
931 sendto_one(lp->value.cptr, ":%s SETTIME %s", parv[0], parv[1]);
935 sprintf_irc(tbuf, TIME_T_FMT, TStime());
937 if (hunt_server(1, cptr, sptr, ":%s SETTIME %s %s", 2, parc, parv) !=
942 #ifdef RELIABLE_CLOCK
943 if ((dt > 600) || (dt < -600))
944 sendto_serv_butone((aClient *)NULL,
945 ":%s WALLOPS :Bad SETTIME from %s: " TIME_T_FMT, me.name, sptr->name,
949 if (MyUser(sptr) || Protocol(cptr) < 10)
950 sendto_one(sptr, ":%s NOTICE %s :clock is not set %ld seconds %s : "
951 "RELIABLE_CLOCK is defined", me.name, parv[0],
952 (dt < 0) ? -dt : dt, (dt < 0) ? "forwards" : "backwards");
954 sendto_one(sptr, "%s NOTICE %s%s :clock is not set %ld seconds %s : "
955 "RELIABLE_CLOCK is defined", NumServ(&me), NumNick(sptr),
956 (dt < 0) ? -dt : dt, (dt < 0) ? "forwards" : "backwards");
959 sendto_ops("SETTIME from %s, clock is set %ld seconds %s",
960 get_client_name(sptr, FALSE), (dt < 0) ? -dt : dt,
961 (dt < 0) ? "forwards" : "backwards");
965 if (MyUser(sptr) || Protocol(cptr) < 10)
966 sendto_one(sptr, ":%s NOTICE %s :clock is set %ld seconds %s", me.name,
967 parv[0], (dt < 0) ? -dt : dt, (dt < 0) ? "forwards" : "backwards");
969 sendto_one(sptr, "%s NOTICE %s%s :clock is set %ld seconds %s",
970 NumServ(&me), NumNick(sptr),
971 (dt < 0) ? -dt : dt, (dt < 0) ? "forwards" : "backwards");
977 static char *militime(char *sec, char *usec)
980 static char timebuf[18];
982 gettimeofday(&tv, NULL);
984 #if defined(__sun__) || defined(__bsdi__) || (__GLIBC__ >= 2) || defined(__NetBSD__)
985 sprintf(timebuf, "%ld",
986 (tv.tv_sec - atoi(sec)) * 1000 + (tv.tv_usec - atoi(usec)) / 1000);
988 sprintf_irc(timebuf, "%d",
989 (tv.tv_sec - atoi(sec)) * 1000 + (tv.tv_usec - atoi(usec)) / 1000);
992 #if defined(__sun__) || defined(__bsdi__) || (__GLIBC__ >= 2) || defined(__NetBSD__)
993 sprintf(timebuf, "%ld %ld", tv.tv_sec, tv.tv_usec);
995 sprintf_irc(timebuf, "%d %d", tv.tv_sec, tv.tv_usec);
1003 * parv[0] = sender (sptr->name thus)
1004 * if sender is a person: (traveling towards start server)
1005 * parv[1] = pinged server[mask]
1006 * parv[2] = start server (current target)
1007 * parv[3] = optional remark
1008 * if sender is a server: (traveling towards pinged server)
1009 * parv[1] = pinged server (current target)
1010 * parv[2] = original sender (person)
1011 * parv[3] = start time in s
1012 * parv[4] = start time in us
1013 * parv[5] = the optional remark
1015 int m_rping(aClient *cptr, aClient *sptr, int parc, char *parv[])
1019 if (!IsPrivileged(sptr))
1022 if (parc < (IsAnOper(sptr) ? (MyConnect(sptr) ? 2 : 3) : 6))
1024 sendto_one(sptr, err_str(ERR_NEEDMOREPARAMS), me.name, parv[0], "RPING");
1030 parv[parc++] = me.name;
1031 else if (!(acptr = find_match_server(parv[2])))
1038 parv[2] = acptr->name;
1040 parv[parc++] = "<No client start time>";
1045 if (hunt_server(1, cptr, sptr, ":%s RPING %s %s :%s", 2, parc, parv) !=
1048 if (!(acptr = find_match_server(parv[1])) || !IsServer(acptr))
1050 sendto_one(sptr, err_str(ERR_NOSUCHSERVER), me.name, parv[0], parv[1]);
1053 if (Protocol(acptr->from) < 10)
1054 sendto_one(acptr, ":%s RPING %s %s %s :%s",
1055 me.name, acptr->name, sptr->name, militime(NULL, NULL), parv[3]);
1057 sendto_one(acptr, ":%s RPING %s %s %s :%s",
1058 me.name, NumServ(acptr), sptr->name, militime(NULL, NULL), parv[3]);
1062 if (hunt_server(1, cptr, sptr, ":%s RPING %s %s %s %s :%s", 1, parc, parv)
1065 sendto_one(cptr, ":%s RPONG %s %s %s %s :%s", me.name, parv[0],
1066 parv[2], parv[3], parv[4], parv[5]);
1072 * m_rpong -- by Run too :)
1074 * parv[0] = sender prefix
1075 * parv[1] = from pinged server: start server; from start server: sender
1076 * parv[2] = from pinged server: sender; from start server: pinged server
1077 * parv[3] = pingtime in ms
1078 * parv[4] = client info (for instance start time)
1080 int m_rpong(aClient *UNUSED(cptr), aClient *sptr, int parc, char *parv[])
1084 if (!IsServer(sptr))
1089 sendto_one(sptr, err_str(ERR_NEEDMOREPARAMS), me.name, parv[0], "RPING");
1093 if (!(acptr = FindClient(parv[1])))
1098 if (IsServer(acptr) && parc > 5)
1100 sendto_one(acptr, ":%s RPONG %s %s %s %s :%s",
1101 parv[0], parv[1], parv[2], parv[3], parv[4], parv[5]);
1108 parv[2] = sptr->name;
1110 parv[3] = militime(parv[3], parv[4]);
1112 if (!(acptr = FindUser(parv[1])))
1113 return 0; /* No bouncing between servers ! */
1116 sendto_one(acptr, ":%s RPONG %s %s %s :%s",
1117 parv[0], parv[1], parv[2], parv[3], parv[4]);
1121 #if defined(OPER_REHASH) || defined(LOCOP_REHASH)
1125 int m_rehash(aClient *cptr, aClient *sptr, int parc, char *parv[])
1127 #ifndef LOCOP_REHASH
1128 if (!MyUser(sptr) || !IsOper(sptr))
1131 if (!MyUser(sptr) || !IsAnOper(sptr))
1133 if (!MyUser(sptr) || !IsLocOp(sptr))
1137 sendto_one(sptr, err_str(ERR_NOPRIVILEGES), me.name, parv[0]);
1140 sendto_one(sptr, rpl_str(RPL_REHASHING), me.name, parv[0], configfile);
1141 sendto_ops("%s is rehashing Server config file", parv[0]);
1143 syslog(LOG_INFO, "REHASH From %s\n", get_client_name(sptr, FALSE));
1145 return rehash(cptr, (parc > 1) ? ((*parv[1] == 'q') ? 2 : 0) : 0);
1149 #if defined(OPER_RESTART) || defined(LOCOP_RESTART)
1153 int m_restart(aClient *UNUSED(cptr), aClient *sptr, int UNUSED(parc),
1156 #ifndef LOCOP_RESTART
1157 if (!MyUser(sptr) || !IsOper(sptr))
1160 if (!MyUser(sptr) || !IsAnOper(sptr))
1162 if (!MyUser(sptr) || !IsLocOp(sptr))
1166 sendto_one(sptr, err_str(ERR_NOPRIVILEGES), me.name, parv[0]);
1170 syslog(LOG_WARNING, "Server RESTART by %s\n", get_client_name(sptr, FALSE));
1180 * parv[0] = sender prefix
1181 * parv[1] = nick or servername
1182 * parv[2] = 'target' servername
1184 int m_trace(aClient *cptr, aClient *sptr, int parc, char *parv[])
1187 Reg2 aClient *acptr;
1190 int doall, link_s[MAXCONNECTIONS], link_u[MAXCONNECTIONS];
1191 int cnt = 0, wilds, dow;
1193 if (parc < 2 || BadPtr(parv[1]))
1195 /* just "TRACE" without parameters. Must be from local client */
1201 else if (parc < 3 || BadPtr(parv[2]))
1203 /* No target specified. Make one before propagating. */
1206 if ((acptr = find_match_server(parv[1])) ||
1207 ((acptr = FindClient(parv[1])) && !MyUser(acptr)))
1210 parv[2] = acptr->user->server->name;
1212 parv[2] = acptr->name;
1215 if ((i = hunt_server(IsServer(acptr), cptr, sptr,
1216 ":%s TRACE %s :%s", 2, parc, parv)) == HUNTED_NOSUCH)
1224 /* Got "TRACE <tname> :<target>" */
1226 if (MyUser(sptr) || Protocol(cptr) < 10)
1227 acptr = find_match_server(parv[2]);
1229 acptr = FindNServer(parv[2]);
1230 if ((i = hunt_server(0, cptr, sptr,
1231 ":%s TRACE %s :%s", 2, parc, parv)) == HUNTED_NOSUCH)
1236 if (i == HUNTED_PASS)
1239 acptr = next_client(client, tname);
1241 acptr = acptr->from;
1242 sendto_one(sptr, rpl_str(RPL_TRACELINK), me.name, parv[0],
1244 version, debugmode, tname, acptr ? acptr->from->name : "<No_match>");
1246 version, debugmode, tname, acptr ? acptr->from->name : "<No_match>",
1247 (acptr && acptr->from->serv) ? acptr->from->serv->timestamp : 0);
1248 #endif /* GODMODE */
1252 doall = (parv[1] && (parc > 1)) ? !match(tname, me.name) : TRUE;
1253 wilds = !parv[1] || strchr(tname, '*') || strchr(tname, '?');
1254 dow = wilds || doall;
1256 /* Don't give (long) remote listings to lusers */
1257 if (dow && !MyConnect(sptr) && !IsAnOper(sptr))
1260 for (i = 0; i < MAXCONNECTIONS; i++)
1261 link_s[i] = 0, link_u[i] = 0;
1265 for (acptr = client; acptr; acptr = acptr->next)
1267 link_u[acptr->from->fd]++;
1268 else if (IsServer(acptr))
1269 link_s[acptr->from->fd]++;
1272 /* report all direct connections */
1274 for (i = 0; i <= highest_fd; i++)
1277 unsigned int conClass;
1279 if (!(acptr = loc_clients[i])) /* Local Connection? */
1281 if (IsInvisible(acptr) && dow && !(MyConnect(sptr) && IsOper(sptr)) &&
1282 !IsAnOper(acptr) && (acptr != sptr))
1284 if (!doall && wilds && match(tname, acptr->name))
1286 if (!dow && strCasediff(tname, acptr->name))
1288 name = get_client_name(acptr, FALSE);
1289 conClass = get_client_class(acptr);
1291 switch (acptr->status)
1293 case STAT_CONNECTING:
1294 sendto_one(sptr, rpl_str(RPL_TRACECONNECTING),
1295 me.name, parv[0], conClass, name);
1298 case STAT_HANDSHAKE:
1299 sendto_one(sptr, rpl_str(RPL_TRACEHANDSHAKE),
1300 me.name, parv[0], conClass, name);
1306 case STAT_UNKNOWN_USER:
1307 case STAT_UNKNOWN_SERVER:
1308 sendto_one(sptr, rpl_str(RPL_TRACEUNKNOWN),
1309 me.name, parv[0], conClass, name);
1313 /* Only opers see users if there is a wildcard
1314 but anyone can see all the opers. */
1315 if ((IsAnOper(sptr) && (MyUser(sptr) ||
1316 !(dow && IsInvisible(acptr)))) || !dow || IsAnOper(acptr))
1318 if (IsAnOper(acptr))
1319 sendto_one(sptr, rpl_str(RPL_TRACEOPERATOR),
1320 me.name, parv[0], conClass, name, now - acptr->lasttime);
1322 sendto_one(sptr, rpl_str(RPL_TRACEUSER),
1323 me.name, parv[0], conClass, name, now - acptr->lasttime);
1328 * Connection is a server
1330 * Serv <class> <nS> <nC> <name> <ConnBy> <last> <age>
1332 * class Class the server is in
1333 * nS Number of servers reached via this link
1334 * nC Number of clients reached via this link
1335 * name Name of the server linked
1336 * ConnBy Who established this link
1337 * last Seconds since we got something from this link
1338 * age Seconds this link has been alive
1340 * Additional comments etc...... -Cym-<cym@acrux.net>
1344 if (acptr->serv->user)
1345 sendto_one(sptr, rpl_str(RPL_TRACESERVER),
1346 me.name, parv[0], conClass, link_s[i],
1347 link_u[i], name, acptr->serv->by,
1348 acptr->serv->user->username,
1349 acptr->serv->user->host,
1350 now - acptr->lasttime, now - acptr->serv->timestamp);
1352 sendto_one(sptr, rpl_str(RPL_TRACESERVER),
1353 me.name, parv[0], conClass, link_s[i],
1354 link_u[i], name, *(acptr->serv->by) ?
1355 acptr->serv->by : "*", "*", me.name,
1356 now - acptr->lasttime, now - acptr->serv->timestamp);
1360 sendto_one(sptr, rpl_str(RPL_TRACELOG),
1361 me.name, parv[0], LOGFILE, acptr->port);
1365 sendto_one(sptr, rpl_str(RPL_TRACEPING), me.name,
1366 parv[0], name, (acptr->acpt) ? acptr->acpt->name : "<null>");
1368 default: /* We actually shouldn't come here, -msa */
1369 sendto_one(sptr, rpl_str(RPL_TRACENEWTYPE), me.name, parv[0], name);
1375 * Add these lines to summarize the above which can get rather long
1376 * and messy when done remotely - Avalon
1378 if (!IsAnOper(sptr) || !cnt)
1381 /* let the user have some idea that its at the end of the trace */
1382 sendto_one(sptr, rpl_str(RPL_TRACESERVER),
1383 me.name, parv[0], 0, link_s[me.fd],
1384 link_u[me.fd], "<No_match>", *(me.serv->by) ?
1385 me.serv->by : "*", "*", me.name, 0, 0);
1388 for (cltmp = FirstClass(); doall && cltmp; cltmp = NextClass(cltmp))
1389 if (Links(cltmp) > 0)
1390 sendto_one(sptr, rpl_str(RPL_TRACECLASS), me.name,
1391 parv[0], ConClass(cltmp), Links(cltmp));
1396 * m_close - added by Darren Reed Jul 13 1992.
1398 int m_close(aClient *cptr, aClient *sptr, int UNUSED(parc), char *parv[])
1400 Reg1 aClient *acptr;
1406 sendto_one(sptr, err_str(ERR_NOPRIVILEGES), me.name, parv[0]);
1410 for (i = highest_fd; i; i--)
1412 if (!(acptr = loc_clients[i]))
1414 if (!IsUnknown(acptr) && !IsConnecting(acptr) && !IsHandshake(acptr))
1416 sendto_one(sptr, rpl_str(RPL_CLOSING), me.name, parv[0],
1417 get_client_name(acptr, TRUE), acptr->status);
1418 exit_client(cptr, acptr, &me, "Oper Closing");
1421 sendto_one(sptr, rpl_str(RPL_CLOSEEND), me.name, parv[0], closed);
1425 #if defined(OPER_DIE) || defined(LOCOP_DIE)
1429 int m_die(aClient *UNUSED(cptr), aClient *sptr, int UNUSED(parc), char *parv[])
1431 Reg1 aClient *acptr;
1435 if (!MyUser(sptr) || !IsOper(sptr))
1438 if (!MyUser(sptr) || !IsAnOper(sptr))
1440 if (!MyUser(sptr) || !IsLocOp(sptr))
1444 sendto_one(sptr, err_str(ERR_NOPRIVILEGES), me.name, parv[0]);
1448 for (i = 0; i <= highest_fd; i++)
1450 if (!(acptr = loc_clients[i]))
1453 sendto_one(acptr, ":%s NOTICE %s :Server Terminating. %s",
1454 me.name, acptr->name, get_client_name(sptr, TRUE));
1455 else if (IsServer(acptr))
1456 sendto_one(acptr, ":%s ERROR :Terminated by %s",
1457 me.name, get_client_name(sptr, TRUE));
1468 static void add_gline(aClient *sptr, int ip_mask, char *host, char *comment,
1469 char *user, time_t expire, int local)
1477 gtype=1; /* BAD CHANNEL */
1480 sendto_op_mask(SNO_GLINE,
1481 "%s adding %s%s for %s@%s, expiring at " TIME_T_FMT ": %s", sptr->name,
1482 local ? "local " : "",
1483 gtype ? "BADCHAN":"GLINE", user, host, expire, comment);
1487 "# " TIME_T_FMT " %s adding %s %s for %s@%s, expiring at " TIME_T_FMT
1488 ": %s\n", TStime(), sptr->name, local ? "local" : "global",
1489 gtype ? "BADCHAN" : "GLINE", user, host, expire, comment);
1491 /* this can be inserted into the conf */
1493 write_log(GPATH, "%c:%s:%s:%s\n", ip_mask ? 'k' : 'K', host, comment,
1497 agline = make_gline(ip_mask, host, comment, user, expire);
1499 SetGlineIsLocal(agline);
1505 for (fd = highest_fd; fd >= 0; --fd) /* get the users! */
1506 if ((acptr = loc_clients[fd]) && !IsMe(acptr))
1509 if (!acptr->user || strlen(acptr->sockhost) > (size_t)HOSTLEN ||
1510 (acptr->user->username ? strlen(acptr->user->username) : 0) >
1512 continue; /* these tests right out of
1513 find_kill for safety's sake */
1515 if ((GlineIsIpMask(agline) ?
1516 match(agline->host, inetntoa(acptr->ip)) :
1517 match(agline->host, acptr->sockhost)) == 0 &&
1518 (!acptr->user->username ||
1519 match(agline->name, acptr->user->username) == 0))
1522 /* ok, he was the one that got G-lined */
1523 sendto_one(acptr, ":%s %d %s :*** %s.", me.name,
1524 ERR_YOUREBANNEDCREEP, acptr->name, agline->reason);
1526 /* let the ops know about my first kill */
1527 sendto_op_mask(SNO_GLINE, "G-line active for %s",
1528 get_client_name(acptr, FALSE));
1530 /* and get rid of him */
1532 exit_client(sptr->from, acptr, &me, "G-lined");
1540 * parv[0] = Send prefix
1544 * parv[1] = Target: server numeric
1545 * parv[2] = [+|-]<G-line mask>
1546 * parv[3] = Expiration offset
1551 * parv[1] = [+|-]<G-line mask>
1552 * parv[2] = Expiration offset
1556 int m_gline(aClient *cptr, aClient *sptr, int parc, char *parv[])
1558 aClient *acptr = NULL; /* Init. to avoid compiler warning. */
1560 aGline *agline, *a2gline;
1562 int active, ip_mask,gtype = 0;
1565 /* Remove expired G-lines */
1566 for (agline = gline, a2gline = NULL; agline; agline = agline->next)
1568 if (agline->expire <= TStime())
1570 free_gline(agline, a2gline);
1571 agline = a2gline ? a2gline : gline;
1580 /* Remove expired bad channels */
1581 for (agline = badchan, a2gline = NULL; agline; agline = agline->next)
1583 if (agline->expire <= TStime())
1585 free_gline(agline, a2gline);
1586 agline = a2gline ? a2gline : badchan;
1598 if (find_conf_host(cptr->confs, sptr->name, CONF_UWORLD))
1600 if (parc < 3 || (*parv[2] != '-' && (parc < 5 || *parv[4] == '\0')))
1602 sendto_one(sptr, err_str(ERR_NEEDMOREPARAMS), me.name, parv[0],
1607 if (*parv[2] == '-') /* add mode or delete mode? */
1612 if (*parv[2] == '+' || *parv[2] == '-')
1613 parv[2]++; /* step past mode indicator */
1615 /* forward the message appropriately */
1616 if (!strCasediff(parv[1], "*")) /* global! */
1617 sendto_serv_butone(cptr, active ? ":%s GLINE %s +%s %s :%s" :
1618 ":%s GLINE %s -%s", parv[0], parv[1], parv[2], parv[3], parv[4]);
1622 * REMOVE THIS after all servers upgraded to 2.10.01 and
1623 * Uworld uses a numeric too
1625 (strlen(parv[1]) != 1 && !(acptr = FindClient(parv[1])))) ||
1626 (strlen(parv[1]) == 1 &&
1628 !(acptr = FindNServer(parv[1]))))
1629 return 0; /* no such server/user exists; forget it */
1633 * REMOVE THIS after all servers upgraded to 2.10.01 and
1634 * Uworld uses a numeric too
1636 if (IsServer(acptr) || !MyConnect(acptr))
1639 sendto_one(acptr, active ? ":%s GLINE %s +%s %s :%s" :
1640 ":%s GLINE %s -%s", parv[0], parv[1], parv[2], parv[3], parv[4]); /* single destination */
1641 return 0; /* only the intended destination
1642 should add this gline */
1645 if (!(host = strchr(parv[2], '@')))
1646 { /* convert user@host */
1647 user = "*"; /* no @'s; assume username is '*' */
1653 *(host++) = '\0'; /* break up string at the '@' */
1655 ip_mask = check_if_ipmask(host); /* Store this boolean */
1657 if(*host == '#') gtype=1; /* BAD CHANNEL GLINE */
1660 for (agline = (gtype)?badchan:gline, a2gline = NULL; agline;
1661 agline = agline->next)
1663 if (!strCasediff(agline->name, user)
1664 && !strCasediff(agline->host, host))
1669 if (!active && agline)
1670 { /* removing the gline */
1672 sendto_op_mask(SNO_GLINE, "%s removing %s for %s@%s", parv[0],
1673 gtype?"BADCHAN":"GLINE",agline->name, agline->host);
1676 write_log(GPATH, "# " TIME_T_FMT " %s removing %s for %s@%s\n",
1677 TStime(), parv[0], gtype?"BADCHAN":"GLINE",agline->name,
1681 free_gline(agline, a2gline); /* remove the gline */
1684 { /* must be adding a gline */
1685 expire = atoi(parv[3]) + TStime(); /* expire time? */
1686 if (agline && agline->expire < expire)
1687 { /* new expire time? */
1688 /* yes, notify the opers */
1689 sendto_op_mask(SNO_GLINE,
1690 "%s resetting expiration time on %s for %s@%s to " TIME_T_FMT,
1691 parv[0], gtype?"BADCHAN":"GLINE",agline->name, agline->host,
1695 write_log(GPATH, "# " TIME_T_FMT " %s resetting expiration time "
1696 "on %s for %s@%s to " TIME_T_FMT "\n",
1697 TStime(), parv[0], gtype?"BADCHAN":"GLINE",
1698 agline->name, agline->host, expire);
1701 agline->expire = expire; /* reset the expire time */
1704 { /* create gline */
1705 for (agline = gtype?badchan:gline; agline; agline = agline->next)
1706 if (!mmatch(agline->name, user) &&
1707 (ip_mask ? GlineIsIpMask(agline) : !GlineIsIpMask(agline)) &&
1708 !mmatch(agline->host, host))
1709 return 0; /* found an existing G-line that matches */
1712 add_gline(sptr, ip_mask, host, parv[4], user, expire, 0);
1717 else if (parc < 2 || *parv[1] == '\0')
1719 /* Not enough args and a user; list glines */
1720 for (agline = gline; agline; agline = agline->next)
1721 sendto_one(cptr, rpl_str(RPL_GLIST), me.name, parv[0],
1722 agline->name, agline->host, agline->expire, agline->reason,
1723 GlineIsActive(agline) ? (GlineIsLocal(agline) ? " (local)" : "") :
1725 sendto_one(cptr, rpl_str(RPL_ENDOFGLIST), me.name, parv[0]);
1732 priv = IsAnOper(cptr);
1734 priv = IsOper(cptr);
1738 { /* non-oper not permitted to change things */
1739 if (*parv[1] == '-')
1740 { /* oper wants to deactivate the gline */
1744 else if (*parv[1] == '+')
1745 { /* oper wants to activate inactive gline */
1753 expire = atoi(parv[2]) + TStime(); /* oper wants to reset
1759 if (!(host = strchr(parv[1], '@')))
1761 user = "*"; /* no @'s; assume username is '*' */
1767 *(host++) = '\0'; /* break up string at the '@' */
1769 ip_mask = check_if_ipmask(host); /* Store this boolean */
1772 #ifndef WT_LOCAL_BADCHAN
1775 gtype=1; /* BAD CHANNEL */
1779 for (agline = gtype?badchan:gline, a2gline = NULL; agline;
1780 agline = agline->next)
1782 if (!mmatch(agline->name, user) &&
1783 (ip_mask ? GlineIsIpMask(agline) : !GlineIsIpMask(agline)) &&
1784 !mmatch(agline->host, host))
1792 if (priv && active && expire > now)
1794 /* Add local G-line */
1795 if (parc < 4 || !strchr(parv[3], ' '))
1797 sendto_one(sptr, err_str(ERR_NEEDMOREPARAMS),
1798 me.name, parv[0], "GLINE");
1801 add_gline(sptr, ip_mask, host, parv[3], user, expire, 1);
1805 sendto_one(cptr, err_str(ERR_NOSUCHGLINE), me.name, parv[0], user,
1811 if (expire <= agline->expire)
1814 if ((active == -1 ||
1815 (active ? GlineIsActive(agline) : !GlineIsActive(agline))) &&
1818 /* oper wants a list of one gline only */
1819 sendto_one(cptr, rpl_str(RPL_GLIST), me.name, parv[0], agline->name,
1820 agline->host, agline->expire, agline->reason,
1821 GlineIsActive(agline) ? "" : " (Inactive)");
1822 sendto_one(cptr, rpl_str(RPL_ENDOFGLIST), me.name, parv[0]);
1827 (active ? !GlineIsActive(agline) : GlineIsActive(agline)))
1829 if (active) /* reset activation on gline */
1832 else if (GlineIsLocal(agline))
1834 /* Remove local G-line */
1835 sendto_op_mask(SNO_GLINE, "%s removed local %s for %s@%s",
1836 parv[0], gtype?"BADCHAN":"GLINE",agline->name, agline->host);
1838 write_log(GPATH, "# " TIME_T_FMT
1839 " %s!%s@%s removed local %s for %s@%s\n",
1840 TStime(), parv[0], cptr->user->username, cptr->user->host,
1841 gtype?"BADCHAN":"GLINE",
1842 agline->name, agline->host);
1844 free_gline(agline, a2gline); /* remove the gline */
1849 ClearActive(agline);
1852 active = -1; /* for later sendto_ops and logging functions */
1855 agline->expire = expire; /* reset expiration time */
1857 /* inform the operators what's up */
1859 { /* changing the activation */
1860 sendto_op_mask(SNO_GLINE, !expire ? "%s %sactivating %s for %s@%s" :
1861 "%s %sactivating %s for %s@%s and "
1862 "resetting expiration time to " TIME_T_FMT,
1863 parv[0], active ? "re" : "de", gtype?"BADCHAN":"GLINE",agline->name,
1864 agline->host, agline->expire);
1866 write_log(GPATH, !expire ? "# " TIME_T_FMT " %s!%s@%s %sactivating "
1867 "%s for %s@%s\n" : "# " TIME_T_FMT " %s!%s@%s %sactivating %s "
1868 "for %s@%s and resetting expiration time to " TIME_T_FMT "\n",
1869 TStime(), parv[0], cptr->user->username, cptr->user->host,
1870 active ? "re" : "de", gtype?"BADCHAN":"GLINE",agline->name,
1871 agline->host, agline->expire);
1876 { /* changing only the expiration */
1877 sendto_op_mask(SNO_GLINE,
1878 "%s resetting expiration time on %s for %s@%s to " TIME_T_FMT,
1879 parv[0], gtype?"BADCHAN":"GLINE",agline->name, agline->host,
1882 write_log(GPATH, "# " TIME_T_FMT " %s!%s@%s resetting expiration "
1883 "time on %s for %s@%s to " TIME_T_FMT "\n", TStime(), parv[0],
1884 cptr->user->username, cptr->user->host,gtype?"BADCHAN":"GLINE",
1885 agline->name, agline->host, agline->expire);