this is 0.9.3... Dlines are global... :)

This commit is contained in:
fishwaldo 2002-09-22 13:19:52 +00:00
parent 3597cdd69a
commit 989a883957
2 changed files with 51 additions and 258 deletions

View file

@ -17,6 +17,8 @@ Symbols are:
(F) - you can not deop/admin/voice/halfop a services client regardless of who you are. (F) - you can not deop/admin/voice/halfop a services client regardless of who you are.
(F) - /userhost displays your vhost, not real host.. (F) - /userhost displays your vhost, not real host..
(F) - Timed Glines now possible. /gline ident@host 12 reason (12 is minutes atm, if 0, uses the default from config files) (F) - Timed Glines now possible. /gline ident@host 12 reason (12 is minutes atm, if 0, uses the default from config files)
(F) - Dlines are now network wide.
* NeoIRCd Version 0.9.2 - 17th Sept, 2002 - Fish * NeoIRCd Version 0.9.2 - 17th Sept, 2002 - Fish
(F) - Fixed a problem with servers setting modes (F) - Fixed a problem with servers setting modes
(F) - Fixed a problem with sethost I think (wasn't setting on other servers correctly) (F) - Fixed a problem with sethost I think (wasn't setting on other servers correctly)

View file

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA * USA
* *
* $Id: m_kline.c,v 1.9 2002/09/19 05:41:10 fishwaldo Exp $ * $Id: m_kline.c,v 1.10 2002/09/22 13:19:52 fishwaldo Exp $
*/ */
#include "stdinc.h" #include "stdinc.h"
@ -62,9 +62,9 @@ struct Message kline_msgtab[] = {
struct Message dline_msgtab[] = { struct Message dline_msgtab[] = {
{"DLINE", 0, 0, 2, 0, MFLG_SLOW, 0, {"DLINE", 0, 0, 2, 0, MFLG_SLOW, 0,
{m_unregistered, m_not_oper, m_error, mo_dline}}, {m_unregistered, m_not_oper, mo_dline, mo_dline}},
{"UNDLINE", 0, 0, 2, 0, MFLG_SLOW, 0, {"UNDLINE", 0, 0, 2, 0, MFLG_SLOW, 0,
{m_unregistered, m_not_oper, m_error, mo_undline}}, {m_unregistered, m_not_oper, mo_undline, mo_undline}},
}; };
#ifndef STATIC_MODULES #ifndef STATIC_MODULES
@ -86,7 +86,7 @@ _moddeinit(void)
mod_del_cmd(&dline_msgtab[0]); mod_del_cmd(&dline_msgtab[0]);
mod_del_cmd(&dline_msgtab[1]); mod_del_cmd(&dline_msgtab[1]);
} }
const char *_version = "$Revision: 1.9 $"; const char *_version = "$Revision: 1.10 $";
#endif #endif
/* Local function prototypes */ /* Local function prototypes */
@ -372,8 +372,6 @@ apply_kline(struct Client *source_p, struct ConfItem *aconf,
const char *current_date, time_t cur_time) const char *current_date, time_t cur_time)
{ {
add_conf_by_address(aconf->host, CONF_KILL, aconf->user, aconf); add_conf_by_address(aconf->host, CONF_KILL, aconf->user, aconf);
WriteKlineOrDline(KLINE_TYPE, source_p, aconf->user, aconf->host,
reason, oper_reason, current_date, cur_time);
/* Now, activate kline against current online clients */ /* Now, activate kline against current online clients */
check_klines(); check_klines();
} }
@ -586,13 +584,6 @@ mo_dline(struct Client *client_p, struct Client *source_p,
const char* current_date; const char* current_date;
time_t cur_time; time_t cur_time;
if (!IsOperK(source_p))
{
sendto_one(source_p,":%s NOTICE %s :You need kline = yes;",
me.name, parv[0]);
return;
}
dlhost = parv[1]; dlhost = parv[1];
strlcpy(cidr_form_host, dlhost, HOSTLEN + 1); strlcpy(cidr_form_host, dlhost, HOSTLEN + 1);
cidr_form_host[HOSTLEN] = '\0'; cidr_form_host[HOSTLEN] = '\0';
@ -600,7 +591,7 @@ mo_dline(struct Client *client_p, struct Client *source_p,
if ((t=parse_netmask(dlhost, NULL, &bits)) == HM_HOST) if ((t=parse_netmask(dlhost, NULL, &bits)) == HM_HOST)
{ {
#ifdef IPV6 #ifdef IPV6
sendto_one(source_p, ":%s NOTICE %s :Sorry, please supply an address.", if !IsServices(source_p) sendto_one(source_p, ":%s NOTICE %s :Sorry, please supply an address.",
me.name, parv[0]); me.name, parv[0]);
return; return;
#else #else
@ -612,7 +603,7 @@ mo_dline(struct Client *client_p, struct Client *source_p,
t = HM_IPV4; t = HM_IPV4;
if (IsServer(target_p)) if (IsServer(target_p))
{ {
sendto_one(source_p, if (!IsServices(source_p)) sendto_one(source_p,
":%s NOTICE %s :Can't DLINE a server silly", ":%s NOTICE %s :Can't DLINE a server silly",
me.name, parv[0]); me.name, parv[0]);
return; return;
@ -620,7 +611,7 @@ mo_dline(struct Client *client_p, struct Client *source_p,
if (!MyConnect(target_p)) if (!MyConnect(target_p))
{ {
sendto_one(source_p, if (!IsServices(source_p)) sendto_one(source_p,
":%s NOTICE :%s :Can't DLINE nick on another server", ":%s NOTICE :%s :Can't DLINE nick on another server",
me.name, parv[0]); me.name, parv[0]);
return; return;
@ -628,7 +619,7 @@ mo_dline(struct Client *client_p, struct Client *source_p,
if (IsExemptKline(target_p)) if (IsExemptKline(target_p))
{ {
sendto_one(source_p, if (!IsServices(source_p)) sendto_one(source_p,
":%s NOTICE %s :%s is E-lined",me.name,parv[0], ":%s NOTICE %s :%s is E-lined",me.name,parv[0],
target_p->name); target_p->name);
return; return;
@ -689,7 +680,7 @@ mo_dline(struct Client *client_p, struct Client *source_p,
{ {
if (bits < 8) if (bits < 8)
{ {
sendto_one(source_p, if (!IsServices(source_p)) sendto_one(source_p,
":%s NOTICE %s :For safety, bitmasks less than 8 require conf access.", ":%s NOTICE %s :For safety, bitmasks less than 8 require conf access.",
me.name, parv[0]); me.name, parv[0]);
return; return;
@ -697,7 +688,7 @@ mo_dline(struct Client *client_p, struct Client *source_p,
} }
else else
{ {
if (bits < 24) if ((bits < 24) && !IsServices(source_p))
{ {
sendto_one(source_p, sendto_one(source_p,
":%s NOTICE %s :Dline bitmasks less than 24 are for admins only.", ":%s NOTICE %s :Dline bitmasks less than 24 are for admins only.",
@ -720,14 +711,15 @@ mo_dline(struct Client *client_p, struct Client *source_p,
if((aconf = find_dline_conf(&daddr, t)) != NULL) if((aconf = find_dline_conf(&daddr, t)) != NULL)
{ {
creason = aconf->passwd ? aconf->passwd : "<No Reason>"; creason = aconf->passwd ? aconf->passwd : "<No Reason>";
if (IsConfExemptKline(aconf)) if (IsConfExemptKline(aconf)) {
sendto_one(source_p, if (!IsServices(source_p)) sendto_one(source_p,
":%s NOTICE %s :[%s] is (E)d-lined by [%s] - %s", ":%s NOTICE %s :[%s] is (E)d-lined by [%s] - %s",
me.name, parv[0], dlhost, aconf->host, creason); me.name, parv[0], dlhost, aconf->host, creason);
else } else {
sendto_one(source_p, if (!IsServices(source_p)) sendto_one(source_p,
":%s NOTICE %s :[%s] already D-lined by [%s] - %s", ":%s NOTICE %s :[%s] already D-lined by [%s] - %s",
me.name, parv[0], dlhost, aconf->host, creason); me.name, parv[0], dlhost, aconf->host, creason);
}
return; return;
} }
} }
@ -752,12 +744,12 @@ mo_dline(struct Client *client_p, struct Client *source_p,
DupString(aconf->passwd, dlbuffer); DupString(aconf->passwd, dlbuffer);
add_conf_by_address(aconf->host, CONF_DLINE, NULL, aconf); add_conf_by_address(aconf->host, CONF_DLINE, NULL, aconf);
/*
* Write dline to configuration file
*/
WriteKlineOrDline(DLINE_TYPE, source_p, NULL, dlhost, reason,
oper_reason, current_date, cur_time);
check_klines(); check_klines();
if (!IsServices(source_p)) sendto_one(source_p, ":%s NOTICE %s :[%s] has been dlined", me.name, source_p->name, parv[1]);
sendto_realops_flags(FLAGS_ALL, L_ALL, "*** %s has Dlined %s for %s", source_p->name, parv[1], reason);
sendto_server(client_p, NULL, NULL, NOCAPS, NOCAPS, NOFLAGS, ":%s DLINE %s :%s", source_p->name, parv[1], parv[2] ? parv[2] : "");
} /* m_dline() */ } /* m_dline() */
/* /*
@ -1014,7 +1006,6 @@ already_placed_kline(struct Client *source_p, char *luser, char *lhost)
return 0; return 0;
} }
static int flush_write(struct Client *, FBFILE* , char *, char *);
static int remove_tkline_match(char *,char *); static int remove_tkline_match(char *,char *);
@ -1031,13 +1022,7 @@ static int remove_tkline_match(char *,char *);
static void mo_unkline (struct Client *client_p,struct Client *source_p, static void mo_unkline (struct Client *client_p,struct Client *source_p,
int parc,char *parv[]) int parc,char *parv[])
{ {
FBFILE *in, *out; char *user, *host;
int pairme=0,error_on_write = NO;
char buf[BUFSIZE], buff[BUFSIZE], temppath[BUFSIZE], *user, *host, *p;
const char *filename; /* filename to use for unkline */
mode_t oldumask;
ircsprintf(temppath, "%s.tmp", ConfigFileEntry.klinefile);
if (!IsOperUnkline(source_p)) if (!IsOperUnkline(source_p))
{ {
@ -1085,138 +1070,13 @@ static void mo_unkline (struct Client *client_p,struct Client *source_p,
host); host);
return; return;
} }
filename = get_conf_name(KLINE_TYPE);
if ((in = fbopen(filename, "r")) == 0)
{
sendto_one(source_p, ":%s NOTICE %s :Cannot open %s", me.name, parv[0],
filename);
return;
}
oldumask = umask(0);
if ((out = fbopen(temppath, "w")) == 0)
{
sendto_one(source_p, ":%s NOTICE %s :Cannot open %s", me.name, parv[0],
temppath);
fbclose(in);
umask(oldumask);
return;
}
umask(oldumask);
while (fbgets(buf, sizeof(buf), in))
{
char *found_host, *found_user;
strlcpy(buff, buf, BUFSIZE);
if ((p = strchr(buff,'\n')) != NULL)
*p = '\0';
if ((*buff == '\0') || (*buff == '#'))
{
if(!error_on_write)
flush_write(source_p, out, buf, temppath);
continue;
}
if ((found_user = getfield(buff)) == NULL)
{
if(!error_on_write)
flush_write(source_p, out, buf, temppath);
continue;
}
if ((found_host = getfield(NULL)) == NULL)
{
if(!error_on_write)
flush_write(source_p, out, buf, temppath);
continue;
}
if ((irccmp(host,found_host) == 0) && (irccmp(user,found_user) == 0))
{
pairme++;
}
else
{
if(!error_on_write)
flush_write(source_p, out, buf, temppath);
}
}
fbclose(in);
fbclose(out);
/* The result of the rename should be checked too... oh well */
/* If there was an error on a write above, then its been reported
* and I am not going to trash the original kline /conf file
*/
if(!error_on_write)
{
(void)rename(temppath, filename);
rehash(0);
}
else else
{
sendto_one(source_p,
":%s NOTICE %s :Couldn't write temp kline file, aborted",
me.name,source_p->name);
return;
}
if(!pairme)
{ {
sendto_one(source_p, ":%s NOTICE %s :No K-Line for %s@%s", sendto_one(source_p, ":%s NOTICE %s :No K-Line for %s@%s",
me.name, source_p->name,user,host); me.name, source_p->name,user,host);
return; return;
} }
return;
sendto_one(source_p, ":%s NOTICE %s :K-Line for [%s@%s] is removed",
me.name, source_p->name, user,host);
sendto_realops_flags(FLAGS_ALL, L_ALL,
"%s has removed the K-Line for: [%s@%s]",
get_oper_name(source_p), user, host);
ilog(L_NOTICE, "%s removed K-Line for [%s@%s]",
source_p->name, user, host);
return;
}
/*
* flush_write()
*
* inputs - pointer to client structure of oper requesting unkline
* - out is the file descriptor
* - buf is the buffer to write
* - ntowrite is the expected number of character to be written
* - temppath is the temporary file name to be written
* output - YES for error on write
* - NO for success
* side effects - if successful, the buf is written to output file
* if a write failure happesn, and the file pointed to
* by temppath, if its non NULL, is removed.
*
* The idea here is, to be as robust as possible when writing to the
* kline file.
*
* -Dianora
*/
static int flush_write(struct Client *source_p, FBFILE* out, char *buf,
char *temppath)
{
int error_on_write = (fbputs(buf, out) < 0) ? YES : NO;
if (error_on_write)
{
sendto_one(source_p,":%s NOTICE %s :Unable to write to %s",
me.name, source_p->name, temppath );
fbclose(out);
if(temppath != (char *)NULL)
(void)unlink(temppath);
}
return(error_on_write);
} }
/* static int remove_tkline_match(char *host, char *user) /* static int remove_tkline_match(char *host, char *user)
@ -1268,23 +1128,13 @@ static void
mo_undline (struct Client *client_p, struct Client *source_p, mo_undline (struct Client *client_p, struct Client *source_p,
int parc,char *parv[]) int parc,char *parv[])
{ {
FBFILE* in; struct ConfItem *aconf;
FBFILE* out; char *cidr;
char buf[BUFSIZE], buff[BUFSIZE], temppath[BUFSIZE], *p; int t;
const char *filename,*cidr, *found_cidr; struct irc_inaddr daddr;
int pairme = NO, error_on_write = NO;
mode_t oldumask;
ircsprintf(temppath, "%s.tmp", ConfigFileEntry.dlinefile);
if (!IsOperUnkline(source_p))
{
sendto_one(source_p,":%s NOTICE %s :You need unkline = yes;",me.name,
parv[0]);
return;
}
cidr = parv[1]; cidr = parv[1];
t = 0;
#if 0 #if 0
if ((type=parse_netmask(cidr,&ip_host,&ip_mask)) == HM_HOST) if ((type=parse_netmask(cidr,&ip_host,&ip_mask)) == HM_HOST)
@ -1294,91 +1144,32 @@ mo_undline (struct Client *client_p, struct Client *source_p,
return; return;
} }
#endif #endif
sendto_server(client_p, NULL, NULL, NOCAPS, NOCAPS, NOFLAGS, ":%s UNDLINE %s", source_p->name, cidr);
filename = get_conf_name(DLINE_TYPE); /* TODO : remove dline */
if ((in = fbopen(filename, "r")) == 0) sendto_one(source_p, ":%s NOTICE %s :%d %s", me.name, source_p->name, t, cidr);
{
sendto_one(source_p, ":%s NOTICE %s :Cannot open %s",
me.name,parv[0],filename);
return;
}
oldumask = umask(0); /* ircd is normally too paranoid */ t = parse_netmask(cidr, &daddr, NULL);
if ( (out = fbopen(temppath, "w")) == 0)
{
sendto_one(source_p, ":%s NOTICE %s :Cannot open %s",
me.name,parv[0],temppath);
fbclose(in);
umask(oldumask); /* Restore the old umask */
return;
}
umask(oldumask); /* Restore the old umask */
while(fbgets(buf, sizeof(buf), in)) #ifdef IPV6
{ if (t == HM_IPV6)
strlcpy(buff, buf, BUFSIZE); t = AF_INET6;
if ((p = strchr(buff,'\n')) != NULL)
*p = '\0';
if ((*buff == '\0') || (*buff == '#'))
{
if(!error_on_write)
flush_write(source_p, out, buf, temppath);
continue;
}
if ((found_cidr = getfield(buff)) == NULL)
{
if(!error_on_write)
flush_write(source_p, out, buf, temppath);
continue;
}
if (irccmp(found_cidr,cidr) == 0)
{
pairme++;
}
else
{
if(!error_on_write)
flush_write(source_p, out, buf, temppath);
continue;
}
}
fbclose(in);
fbclose(out);
if (!error_on_write)
{
(void)rename(temppath, filename);
rehash(0);
}
else else
{ #endif
sendto_one(source_p, t = AF_INET;
":%s NOTICE %s :Couldn't write D-line file, aborted",
me.name, parv[0]);
return;
}
if (!pairme) if((aconf = find_dline_conf(&daddr, t)) != NULL) {
{ delete_one_address_conf(aconf->host, aconf);
sendto_one(source_p, ":%s NOTICE %s :No D-Line for %s", me.name, sendto_one(source_p, ":%s NOTICE %s :D-Line for [%s] is removed",
parv[0],cidr); me.name, parv[0], cidr);
return; sendto_realops_flags(FLAGS_ALL, L_ALL, "%s has removed the D-Line for: [%s]",
} get_oper_name(source_p), cidr);
ilog(L_NOTICE, "%s removed D-Line for [%s]", get_oper_name(source_p),
sendto_one(source_p, ":%s NOTICE %s :D-Line for [%s] is removed", cidr);
me.name, parv[0], cidr); } else {
sendto_realops_flags(FLAGS_ALL, L_ALL, "%s has removed the D-Line for: [%s]", sendto_one(source_p, ":%s NOTICE %s :D-Line %s can not be found", me.name, source_p->name, cidr);
get_oper_name(source_p), cidr); }
ilog(L_NOTICE, "%s removed D-Line for [%s]", get_oper_name(source_p),
cidr);
} }