*
* $Id$
*/
+#include "config.h"
+
#include "gline.h"
#include "client.h"
#include "ircd.h"
#include "ircd_alloc.h"
+#include "ircd_log.h"
#include "ircd_reply.h"
#include "ircd_string.h"
#include "match.h"
* get the users!
*/
if ((acptr = LocalClientArray[fd])) {
- if (!acptr->user)
+ if (!cli_user(acptr))
continue;
- if (acptr->user->username &&
- match (gline->gl_user, acptr->user->username) != 0)
+ if (cli_user(acptr)->username &&
+ match (gline->gl_user, (cli_user(acptr))->username) != 0)
continue;
if (GlineIsIpMask(gline)) {
- Debug((DEBUG_DEBUG,"IP gline: %08x %08x/%i",cptr->ip.s_addr,gline->ipnum.s_addr,gline->bits));
- if ((acptr->ip.s_addr & NETMASK(gline->bits)) != gline->ipnum.s_addr)
+ Debug((DEBUG_DEBUG,"IP gline: %08x %08x/%i",(cli_ip(cptr)).s_addr,gline->ipnum.s_addr,gline->bits));
+ if (((cli_ip(acptr)).s_addr & NETMASK(gline->bits)) != gline->ipnum.s_addr)
continue;
}
else {
- if (match(gline->gl_host, acptr->sockhost) != 0)
+ if (match(gline->gl_host, cli_sockhost(acptr)) != 0)
continue;
}
/* let the ops know about it */
sendto_opmask_butone(0, SNO_GLINE, "G-line active for %s",
- get_client_name(acptr, FALSE));
+ get_client_name(acptr, TRUE));
/* and get rid of him */
if ((tval = exit_client_msg(cptr, acptr, &me, "G-lined (%s)",
return retval;
}
-static void
-propagate_gline(struct Client *cptr, struct Client *sptr, struct Gline *gline)
+int
+gline_propagate(struct Client *cptr, struct Client *sptr, struct Gline *gline)
{
if (GlineIsLocal(gline) || (IsUser(sptr) && !gline->gl_lastmod))
- return;
+ return 0;
if (gline->gl_lastmod)
sendcmdto_serv_butone(sptr, CMD_GLINE, cptr, "* %c%s%s%s %Tu %Tu :%s",
gline->gl_expire - CurrentTime, gline->gl_lastmod,
gline->gl_reason);
else
- sendcmdto_serv_butone(sptr, CMD_GLINE, cptr, "* %c%s%s%s %Tu :%s",
- GlineIsRemActive(gline) ? '+' : '-', gline->gl_user,
- GlineIsBadChan(gline) ? "" : "@",
+ sendcmdto_serv_butone(sptr, CMD_GLINE, cptr,
+ (GlineIsRemActive(gline) ?
+ "* +%s%s%s %Tu :%s" : "* -%s%s%s"),
+ gline->gl_user, GlineIsBadChan(gline) ? "" : "@",
GlineIsBadChan(gline) ? "" : gline->gl_host,
gline->gl_expire - CurrentTime, gline->gl_reason);
+
+ return 0;
}
int
|| userhost[2] == '#' || userhost[2] == '&' || userhost[2] == '+'
# endif /* OLD_GLINE */
) {
-# ifndef LOCAL_BADCHAN
- if (flags & GLINE_LOCAL)
- return 0;
-# endif
+ if ((flags & GLINE_LOCAL) && !HasPriv(sptr, PRIV_LOCAL_BADCHAN))
+ return send_reply(sptr, ERR_NOPRIVILEGES);
+
flags |= GLINE_BADCHAN;
}
/* Inform ops... */
sendto_opmask_butone(0, SNO_GLINE, "%s adding %s %s for %s, expiring at "
- "%Tu: %s",
- IsServer(sptr) ? sptr->name : sptr->user->server->name,
+ "%Tu: %s", IsServer(sptr) ? cli_name(sptr) :
+ cli_name((cli_user(sptr))->server),
flags & GLINE_LOCAL ? "local" : "global",
flags & GLINE_BADCHAN ? "BADCHAN" : "GLINE", userhost,
expire + TSoffset, reason);
-#ifdef GPATH
/* and log it */
- write_log(GPATH, "# %Tu %C adding %s %s for %s, expiring at %Tu: %s\n",
- TStime(), sptr, flags & GLINE_LOCAL ? "local" : "global",
+ log_write(LS_GLINE, L_INFO, LOG_NOSNOTICE,
+ "%#C adding %s %s for %s, expiring at %Tu: %s", sptr,
+ flags & GLINE_LOCAL ? "local" : "global",
flags & GLINE_BADCHAN ? "BADCHAN" : "GLINE", userhost,
expire + TSoffset, reason);
-#endif /* GPATH */
/* make the gline */
agline = make_gline(userhost, reason, expire, lastmod, flags);
if (!agline) /* if it overlapped, silently return */
return 0;
- propagate_gline(cptr, sptr, agline);
+ gline_propagate(cptr, sptr, agline);
if (GlineIsBadChan(agline))
return 0;
-#ifdef GPATH
- /* this can be inserted into the conf */
- write_log(GPATH, "%c:%s:%s:%s\n", GlineIsIpMask(agline) ? 'k' : 'K',
- GlineHost(agline), GlineReason(agline), GlineUser(agline));
-#endif /* GPATH */
-
return do_gline(cptr, sptr, agline); /* knock off users if necessary */
}
else {
gline->gl_flags |= GLINE_ACTIVE;
- if (gline->gl_lastmod >= lastmod) /* force lastmod to increase */
- gline->gl_lastmod++;
- else
- gline->gl_lastmod = lastmod;
+ if (gline->gl_lastmod) {
+ if (gline->gl_lastmod >= lastmod) /* force lastmod to increase */
+ gline->gl_lastmod++;
+ else
+ gline->gl_lastmod = lastmod;
+ }
}
if ((saveflags & GLINE_ACTMASK) == GLINE_ACTIVE)
/* Inform ops and log it */
sendto_opmask_butone(0, SNO_GLINE, "%s activating global %s for %s%s%s, "
- "expiring at %Tu: %s",
- IsServer(sptr) ? sptr->name : sptr->user->server->name,
+ "expiring at %Tu: %s", IsServer(sptr) ? cli_name(sptr) :
+ cli_name((cli_user(sptr))->server),
GlineIsBadChan(gline) ? "BADCHAN" : "GLINE",
gline->gl_user, GlineIsBadChan(gline) ? "" : "@",
GlineIsBadChan(gline) ? "" : gline->gl_host,
gline->gl_expire + TSoffset, gline->gl_reason);
-#ifdef GPATH
- write_log(GPATH, "# %Tu %C activating global %s for %s%s%s, expiring at "
- "%Tu: %s\n", TStime(), sptr,
- GlineIsBadChan(gline) ? "BADCHAN" : "GLINE",
- gline->gl_user, GlineIsBadChan(gline) ? "" : "@",
+ 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,
+ GlineIsBadChan(gline) ? "" : "@",
GlineIsBadChan(gline) ? "" : gline->gl_host,
gline->gl_expire + TSoffset, gline->gl_reason);
-#endif /* GPATH */
if (!(flags & GLINE_LOCAL)) /* don't propagate local changes */
- propagate_gline(cptr, sptr, gline);
+ gline_propagate(cptr, sptr, gline);
return GlineIsBadChan(gline) ? 0 : do_gline(cptr, sptr, gline);
}
if (GlineIsLocal(gline))
msg = "removing local";
- else if (!gline->gl_lastmod && !(flags & GLINE_LOCAL))
+ else if (!gline->gl_lastmod && !(flags & GLINE_LOCAL)) {
msg = "removing global";
- else {
+ gline->gl_flags &= ~GLINE_ACTIVE; /* propagate a -<mask> */
+ } else {
msg = "deactivating global";
if (flags & GLINE_LOCAL)
else {
gline->gl_flags &= ~GLINE_ACTIVE;
- if (gline->gl_lastmod >= lastmod)
- gline->gl_lastmod++;
- else
- gline->gl_lastmod = lastmod;
+ if (gline->gl_lastmod) {
+ if (gline->gl_lastmod >= lastmod)
+ gline->gl_lastmod++;
+ else
+ gline->gl_lastmod = lastmod;
+ }
}
if ((saveflags & GLINE_ACTMASK) != GLINE_ACTIVE)
/* Inform ops and log it */
sendto_opmask_butone(0, SNO_GLINE, "%s %s %s for %s%s%s, expiring at %Tu: "
- "%s",
- IsServer(sptr) ? sptr->name : sptr->user->server->name,
+ "%s", IsServer(sptr) ? cli_name(sptr) :
+ cli_name((cli_user(sptr))->server),
msg, GlineIsBadChan(gline) ? "BADCHAN" : "GLINE",
gline->gl_user, GlineIsBadChan(gline) ? "" : "@",
GlineIsBadChan(gline) ? "" : gline->gl_host,
gline->gl_expire + TSoffset, gline->gl_reason);
-#ifdef GPATH
- write_log(GPATH, "# %Tu %C %s %s for %s%s%s, expiring at %Tu: %s\n",
- TStime(), sptr, msg, GlineIsBadChan(gline) ? "BADCHAN" : "GLINE",
- gline->gl_user, GlineIsBadChan(gline) ? "" : "@",
+ 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,
+ GlineIsBadChan(gline) ? "" : "@",
GlineIsBadChan(gline) ? "" : gline->gl_host,
gline->gl_expire + TSoffset, gline->gl_reason);
-#endif /* GPATH */
+ if (!(flags & GLINE_LOCAL)) /* don't propagate local changes */
+ gline_propagate(cptr, sptr, gline);
+
+ /* if it's a local gline or a Uworld gline (and not locally deactivated).. */
if (GlineIsLocal(gline) || (!gline->gl_lastmod && !(flags & GLINE_LOCAL)))
- gline_free(gline);
- else if (!(flags & GLINE_LOCAL)) /* don't propagate local changes */
- propagate_gline(cptr, sptr, gline);
+ gline_free(gline); /* get rid of it */
return 0;
}
(flags & GLINE_LASTMOD && !gline->gl_lastmod))
continue;
- if (match(gline->gl_user, cptr->user->username) != 0)
+ if (match(gline->gl_user, (cli_user(cptr))->username) != 0)
continue;
if (GlineIsIpMask(gline)) {
- Debug((DEBUG_DEBUG,"IP gline: %08x %08x/%i",cptr->ip.s_addr,gline->ipnum.s_addr,gline->bits));
- if ((cptr->ip.s_addr & NETMASK(gline->bits)) != gline->ipnum.s_addr)
+ Debug((DEBUG_DEBUG,"IP gline: %08x %08x/%i",(cli_ip(cptr)).s_addr,gline->ipnum.s_addr,gline->bits));
+ if (((cli_ip(cptr)).s_addr & NETMASK(gline->bits)) != gline->ipnum.s_addr)
continue;
}
else {
- if (match(gline->gl_host, cptr->user->host) != 0)
+ if (match(gline->gl_host, (cli_user(cptr))->host) != 0)
continue;
}
return gline;
GlineIsBadChan(gline) ? "" : "@",
GlineIsBadChan(gline) ? "" : gline->gl_host,
gline->gl_expire + TSoffset,
- GlineIsLocal(gline) ? me.name : "*",
+ GlineIsLocal(gline) ? cli_name(&me) : "*",
GlineIsActive(gline) ? '+' : '-', gline->gl_reason);
} else {
for (gline = GlobalGlineList; gline; gline = sgline) {
else
send_reply(sptr, RPL_GLIST, gline->gl_user, "@", gline->gl_host,
gline->gl_expire + TSoffset,
- GlineIsLocal(gline) ? me.name : "*",
+ GlineIsLocal(gline) ? cli_name(&me) : "*",
GlineIsActive(gline) ? '+' : '-', gline->gl_reason);
}
else
send_reply(sptr, RPL_GLIST, gline->gl_user, "", "",
gline->gl_expire + TSoffset,
- GlineIsLocal(gline) ? me.name : "*",
+ GlineIsLocal(gline) ? cli_name(&me) : "*",
GlineIsActive(gline) ? '+' : '-', gline->gl_reason);
}
}