This commit is contained in:
joonicks
2018-03-16 02:45:13 +01:00
parent fb70029b56
commit 6c906e43ee
26 changed files with 575 additions and 201 deletions

View File

@@ -121,6 +121,9 @@ aliastest: alias.c
safepathtest: function.c
$(CROSS_COMPILE)$(CC) $(CFLAGS) -o safepathtest $< $(LPROF) $(LIBS) $(LDSCRIPT) -DTEST
commands:
grep -E '(void do_.*\(COMMAND_ARGS\)|/*---Help:)' *c
#
#
#

View File

@@ -249,6 +249,9 @@ void do_alias(COMMAND_ARGS)
set_mallocdoer(do_alias);
alias->format = Strdup(rest);
to_user(from,"Replaced alias: %s --> %s",cmd,rest);
#ifdef DEBUG
debug("(do_alias) Replaced alias: %s --> %s\n",cmd,rest);
#endif
return;
}
}
@@ -260,6 +263,9 @@ void do_alias(COMMAND_ARGS)
alias->next = aliaslist;
aliaslist = alias;
to_user(from,"Added alias: %s --> %s",cmd,rest);
#ifdef DEBUG
debug("(do_alias) Added alias: %s --> %s\n",cmd,rest);
#endif
}
void do_unalias(COMMAND_ARGS)

View File

@@ -417,8 +417,9 @@ int make_auth(const char *userhost, const User *user)
*
*/
/*
* Usage: VERIFY <password>
/*---Help:AUTH:<password>
*/
/*---Help:VERIFY:<password>
*/
void do_auth(COMMAND_ARGS)
{

View File

@@ -58,7 +58,7 @@ void check_idlekick(void)
}
}
__attr (CORE_SEG, regparm(2))
__attr(CORE_SEG, __regparm(2))
Chan *find_channel(const char *name, int anychannel)
{
Chan *chan;
@@ -625,7 +625,7 @@ void remove_chanuser(Chan *chan, char *nick)
/*
* Requires CurrentChan to be set properly
*/
__attr(CORE_SEG, __regparm (2) )
__attr(CORE_SEG, __regparm(2))
void make_chanuser(char *nick, char *userhost)
{
ChanUser *new;

View File

@@ -864,7 +864,44 @@ typedef struct
} HookTimer;
//using that struct, calculate when the next time will be
//start by determining what the time is now
thistime = now;
//which second is it
thissecond = thistime % 60;
if (ht->second1 == 0x3FFFFFFF && ht->second2 == 0x3FFFFFFF)
{
// dont add waiting period to get to the proper second
}
//which minute is it
thistime = (thistime - thissecond) / 60;
thisminute = thistime % 60;
if (ht->minute1 == 0x3FFFFFFF && ht->minute2 == 0x3FFFFFFF)
{
// dont add waiting period to get to the proper minute
}
//which hour is it
thistime = (thistime - thisminute) / 60;
thishour = thistime % 24;
if (ht->hour == 0xFFFFFF)
{
// dont add waiting period to get to the proper hour
}
//which weekday is it
thistime = (thistime - thishour) / 60; //thistime is now = day since epoch
if (ht->weekday == 0x7F) // every day
{
// dont add waiting period to get to the correct day
}
#endif /* 0 */
/*
* return -1 on failure
*/

View File

@@ -1,7 +1,7 @@
/*
EnergyMech, IRC bot software
Copyright (c) 1997-2009 proton
Copyright (c) 1997-2018 proton
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -42,19 +42,49 @@ LS const struct
} StructList[] =
{
{ "aME\t", sizeof(aME) }, // for memory allocation debugging
{ "aMEA", sizeof(aMEA) },
#ifdef ALIAS
{ "Alias", sizeof(Alias) },
#endif /* ALIAS */
{ "Auth", sizeof(Auth) },
{ "Ban\t", sizeof(Ban) },
#ifdef BOTNET
{ "BotInfo", sizeof(BotInfo) },
{ "BotNet", sizeof(BotNet) },
#endif
{ "Chan", sizeof(Chan) },
{ "ChanStats", sizeof(ChanStats) },
{ "ChanUser", sizeof(ChanUser) },
{ "Client", sizeof(Client) },
{ "ShortClient", sizeof(ShortClient) },
#ifdef RAWDNS
{ "dnsAuthority", sizeof(dnsAuthority) },
{ "dnsList", sizeof(dnsList) },
{ "dnsQuery", sizeof(dnsQuery) },
#endif
#ifdef SCRIPTING
{ "Hook", sizeof(Hook) },
{ "HookTimer", sizeof(HookTimer) },
#endif
{ "ircLink", sizeof(ircLink) },
{ "IReq", sizeof(IReq) },
{ "KickSay", sizeof(KickSay) },
{ "KillSock", sizeof(KillSock) },
{ "Mech", sizeof(Mech) },
#ifdef BOTNET
{ "NetCfg", sizeof(NetCfg) },
#endif
#ifdef NOTE
{ "Note", sizeof(Note) },
#endif /* NOTE */
#ifdef NOTIFY
{ "nfLog", sizeof(nfLog) },
{ "Notify", sizeof(Notify) },
#endif /* NOTIFY */
{ "OnMsg", sizeof(OnMsg) },
{ "qKick", sizeof(qKick) },
{ "qMode", sizeof(qMode) },
#ifdef SEEN
{ "Seen", sizeof(Seen) },
#endif /* SEEN */
@@ -62,15 +92,20 @@ LS const struct
{ "ServerGroup", sizeof(ServerGroup) },
{ "Setting", sizeof(Setting) },
{ "Shit", sizeof(Shit) },
{ "Spy\t", sizeof(Spy) },
{ "Strp", sizeof(Strp) },
#ifdef TRIVIA
{ "TrivScore", sizeof(TrivScore) },
#endif /* TRIVIA */
{ "UniVar", sizeof(UniVar) },
{ "User", sizeof(User) },
{ "OnMsg", sizeof(OnMsg) },
{ "Spy\t", sizeof(Spy) },
#ifdef WEB
{ "WebDoc", sizeof(WebDoc) },
{ "WebSock", sizeof(WebSock) },
#endif
{ NULL, }};
LS struct
{
void *func;

View File

@@ -367,6 +367,14 @@ enum {
/* check_mass() */
#define INDEX_FLOOD 0
#define INDEX_BAN 1
#define INDEX_DEOP 2
#define INDEX_KICK 3
#define INDEX_NICK 4
#define INDEX_CAPS 5
#define INDEX_MAX 6
#define CHK_CAPS 0
#define CHK_PUB 1
#define CHK_PUBLIC CHK_PUB

View File

@@ -58,7 +58,8 @@ struct
/*
* public access commands
*/
{ 0, "VERIFY", "do_auth", 0 | NOPUB },
{ 0, "AUTH", "do_auth", 0 | NOPUB | CBANG }, // double up on AUTH/VERIFY to better
{ 0, "VERIFY", "do_auth", 0 | NOPUB | CBANG }, // catch login attempts
#ifdef TOYBOX
{ 0, "8BALL", "do_8ball", 0 | CBANG },
#endif /* TOYBOX */

View File

@@ -106,6 +106,9 @@
}
#endif /* DEBUG */
LS int makecrc(const char *);
LS void send_supress(const char *, const char *);
LS void netchanSupress(BotNet *, char *);
LS Chan *find_channel(const char *, int) __attr(CORE_SEG, __regparm (2) );
LS Chan *find_channel_ac(const char *) __attr(CORE_SEG, __regparm (1) );

View File

@@ -42,7 +42,7 @@ void do_hostinfo(COMMAND_ARGS)
struct utsname un;
if (uname(&un) == 0)
to_user(from,"%s %s %s",un.sysname,un.release,un.machine);
to_user_q(from,"%s %s %s",un.sysname,un.release,un.machine);
}
char vmpeak[32];
@@ -128,7 +128,7 @@ void do_meminfo(COMMAND_ARGS)
return;
readline(fd,&parse_proc_status); // readline closes fd
to_user(from,"VM %s (Max %s), RSS %s [ Code %s, Data %s, Libs %s, Stack %s ]",
to_user_q(from,"VM %s (Max %s), RSS %s [ Code %s, Data %s, Libs %s, Stack %s ]",
vmsize,vmpeak,vmrss,vmexe,vmdata,vmlib,vmstk);
}

View File

@@ -795,6 +795,10 @@ int main(int argc, char **argv, char **envp)
/*
* Code to detect and recover after a RESET
*/
/*
execve( ./energymech, argv = { ./energymech <NULL> <NULL> <NULL> <NULL> }, envp = { MECHRESET=d3 f1881:2:X12 } )
(recover_debug) debug fd recovered
*/
while(*envp)
{
char *p1;
@@ -812,6 +816,9 @@ int main(int argc, char **argv, char **envp)
if (*p2 == 0)
{
mechresetenv = p1;
do_fork = FALSE;
if (*p1 == 'd')
mechresetenv = recover_debug(p1+1);
break;
}
envp++;
@@ -1003,7 +1010,7 @@ int main(int argc, char **argv, char **envp)
if (!mechresetenv)
to_file(1,INFO_RUNNING);
if (!mechresetenv && do_fork)
if (do_fork)
{
close(0);
close(1);

View File

@@ -1,7 +1,7 @@
/*
EnergyMech, IRC bot software
Copyright (c) 1997-2009 proton
Copyright (c) 1997-2018 proton
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -78,6 +78,7 @@ LS const LinkCmd basicProto[] =
{ 'B', 'L', basicLink },
{ 'B', 'Q', basicQuit },
{ 'C', 'O', netchanNeedop },
{ 'C', 'S', netchanSupress }, // experimental command supression
{ 'P', 'A', partyAuth },
#ifdef REDIRECT
{ 'P', 'C', partyCommand },
@@ -97,7 +98,7 @@ LS int deadlinks = FALSE;
*
*/
Mech *get_netbot(void)
Mech *get_netbot(void) //get local bot with the lowes guid to act as local master
{
Mech *netbot,*bot;
int uid;

View File

@@ -1,7 +1,7 @@
/*
EnergyMech, IRC bot software
Copyright (c) 1997-2004 proton
Copyright (c) 1997-2018 proton
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -30,6 +30,36 @@
#include "text.h"
#include "mcmd.h"
int makecrc(const char *args)
{
int crc = 0;
while(*args)
{
crc += ((12345 * *args) % 321) + 4567;
args++;
}
return(crc);
}
void send_supress(const char *command, const char *args)
{
Mech *backup;
int crc;
crc = makecrc(args);
for(backup=botlist;backup;backup=backup->next)
{
if (backup != current)
{
backup->supres_cmd = command;
backup->supres_crc = crc;
}
}
botnet_relay(NULL,"CS%s %i\n",command,crc);
}
ChanUser *find_chanbot(Chan *chan, char *nick)
{
ChanUser *cu;
@@ -141,4 +171,39 @@ void netchanNeedop(BotNet *source, char *rest)
}
}
void netchanSupress(BotNet *source, char *rest)
{
Mech *backup;
const char *cmd;
int crc,i,j;
botnet_relay(source,"CS%s\n",rest);
cmd = chop(&rest);
// convert command to const command
for(i=0;mcmd[i].name;i++)
{
j = Strcasecmp(mcmd[i].name,cmd);
if (j < 0)
continue;
if (j > 0)
return;
cmd = mcmd[i].name;
break;
}
if (mcmd[i].name == NULL)
return;
crc = a2i(rest);
// to all local bots
for(backup=botlist;backup;backup=backup->next)
{
backup->supres_cmd = cmd;
backup->supres_crc = crc;
}
}
#endif /* BOTNET */

View File

@@ -325,15 +325,15 @@ void on_nick(char *from, char *newnick)
if ((maxcount = chan->setting[INT_NCL].int_var) < 2)
continue;
if ((now - cu->nicktime) > NICKFLOODTIME)
if ((now - cu->action_time[INDEX_NICK]) > NICKFLOODTIME)
{
cu->nicktime = now + (NICKFLOODTIME / (maxcount - 1));
cu->nicknum = 1;
cu->action_time[INDEX_NICK] = now + (NICKFLOODTIME / (maxcount - 1));
cu->action_num[INDEX_NICK] = 1;
}
else
{
cu->nicktime += (NICKFLOODTIME / (maxcount - 1));
if (++cu->nicknum >= maxcount)
cu->action_time[INDEX_NICK] += (NICKFLOODTIME / (maxcount - 1));
if (++cu->action_num[INDEX_NICK] >= maxcount)
{
deop_ban(chan,cu,NULL);
send_kick(chan,newnick,KICK_NICKFLOOD);
@@ -342,7 +342,7 @@ void on_nick(char *from, char *newnick)
}
}
void on_msg(char *from, char *to, char *msg)
void on_msg(char *from, char *to, char *rest)
{
#ifdef SCRIPTING
Hook *hook;
@@ -368,7 +368,7 @@ void on_msg(char *from, char *to, char *msg)
*/
#ifdef NOTE
if (notelist && catch_note(from,to,msg))
if (notelist && catch_note(from,to,rest))
return;
#endif /* NOTE */
@@ -378,7 +378,7 @@ void on_msg(char *from, char *to, char *msg)
*/
if (CurrentChan && !CurrentChan->setting[TOG_PUB].int_var)
{
common_public(CurrentChan,from,"<%s> %s",msg);
common_public(CurrentChan,from,"<%s> %s",rest);
return;
}
@@ -398,7 +398,7 @@ void on_msg(char *from, char *to, char *msg)
/*
* remember where the string started
*/
origstart = msg;
origstart = rest;
if (from == CoreUser.name)
{
@@ -412,7 +412,7 @@ void on_msg(char *from, char *to, char *msg)
/*
* check for command bots nick replacing command char
*/
if ((p2 = (uchar*)(command = chop(&msg))) == NULL)
if ((p2 = (uchar*)(command = chop(&rest))) == NULL)
return;
p1 = (uchar*)current->nick;
@@ -421,7 +421,7 @@ void on_msg(char *from, char *to, char *msg)
if (!i || ((p2 > (uchar*)command) && (*p2 == ':' || *p2 == ';' || *p2 == ',') && p2[1] == 0))
{
if ((command = chop(&msg)) == NULL)
if ((command = chop(&rest)) == NULL)
return;
has_cc = TRUE;
}
@@ -449,13 +449,13 @@ recheck_alias:
{
if (!Strcasecmp(alias->alias,command))
{
unchop(command,msg);
unchop(command,rest);
afmt(amem,alias->format,command);
#ifdef DEBUG
debug("(on_msg) [ALIAS] %s --> %s\n",command,amem);
#endif /* DEBUG */
msg = amem;
pt = chop(&msg);
rest = amem;
pt = chop(&rest);
i = Strcasecmp(pt,command);
command = pt;
arec++;
@@ -483,7 +483,7 @@ recheck_alias:
*/
if (hook->flags == HOOK_COMMAND && !Strcasecmp(command,hook->type.command))
{
if (hook->func(from,msg,hook))
if (hook->func(from,rest,hook))
/* if the hook returns non-zero, the input should not be parsed internally */
i = 1;
}
@@ -518,8 +518,34 @@ recheck_alias:
#endif /* DEBUG */
return;
}
CurrentCmd = &mcmd[i];
#ifdef BOTNET
// experimental command supression
if (CurrentCmd->name == current->supres_cmd)
{
int crc;
crc = makecrc(rest);
if (current->supres_crc == crc)
{
// another bot has already executed this command and is trying to supress its execution on other bots
current->supres_cmd = NULL;
current->supres_crc = 0;
#ifdef DEBUG
debug("(on_msg) command \"%s\" from %s was supressed\n",CurrentCmd->name,CurrentNick);
#endif
return;
}
}
//if command should be supressed ...
if (CurrentChan)
{
send_supress(CurrentCmd->name,rest);
}
#endif
/*
* convert the command to uppercase
*/
@@ -566,7 +592,7 @@ recheck_alias:
if (mcmd[i].caxs)
{
/* get channel name; 1: msg, 2: to, 3: active channel */
to = get_channel(to,&msg);
to = get_channel(to,&rest);
if (!ischannel(to))
return;
uaccess = get_authaccess(from,to);
@@ -593,7 +619,7 @@ recheck_alias:
/*
* CARGS check: at least one argument is required
*/
if (mcmd[i].args && !*msg)
if (mcmd[i].args && !*rest)
{
if (uaccess) usage_command(from,command);
return;
@@ -611,7 +637,7 @@ recheck_alias:
redirect.method = R_PRIVMSG;
}
else
if (begin_redirect(from,msg) < 0)
if (begin_redirect(from,rest) < 0)
return;
}
#endif /* REDIRECT */
@@ -619,7 +645,7 @@ recheck_alias:
if (mcmd[i].dcc && dcc_only_command(from))
return;
mcmd[i].func(from,to,msg,acmd[i]);
mcmd[i].func(from,to,rest,acmd[i]);
#ifdef DEBUG
CurrentCmd = NULL;
@@ -637,7 +663,7 @@ recheck_alias:
/*
* un-chop() the message string
*/
unchop(origstart,msg);
unchop(origstart,rest);
if (CurrentChan)
{

View File

@@ -350,6 +350,28 @@ void parse_ping(char *from, char *rest)
to_server("PONG :%s\n",rest);
}
void parse_pong(char *from, char *rest)
{
time_t ot;
char *src;
#ifdef DEBUG
debug("(parse_pong) rest == %s\n",rest);
#endif
if (rest[0] == ':' && rest[1] == 'O' && rest[2] == 'T')
{
ot = 0;
src = &rest[3];
while(attrtab[(uchar)*src] & NUM)
ot = (ot * 10) + (*src++ - '0');
current->ontime = ot;
#ifdef DEBUG
debug("(parse_pong) recovering ontime = %lu (%s)\n",ot,idle2str(now - ot,TRUE));
#endif
}
}
void parse_privmsg(char *from, char *rest)
{
ChanUser *cu;
@@ -1366,6 +1388,7 @@ LS const struct
{ 0x4E49434B, NEEDFROM, on_nick }, /* NICK */
{ 0x4B49434B, NEEDFROM, on_kick }, /* KICK */
{ 0x50494E47, 0, parse_ping }, /* PING */
{ 0x504F4E47, DROPONE, parse_pong }, /* PONG */
{ 0x544F5049, NEEDFROM, parse_topic }, /* TOPIC */
{ 0x4E4F5449, NEEDFROM, parse_notice }, /* NOTICE */
{ 0x51554954, NEEDFROM, parse_quit }, /* QUIT */
@@ -1497,12 +1520,13 @@ void parseline(char *rest)
cmdhash = 0;
}
}
if (!cmdhash)
if (cmdhash == 0)
return;
#endif /* SCRIPTING */
cmdhash = stringhash(command);
//debug("cmdhash = %08X\n",cmdhash);
for(i=0;pFuncs[i].hash;i++)
{
if (cmdhash == pFuncs[i].hash)
@@ -1510,9 +1534,26 @@ void parseline(char *rest)
if ((pFuncs[i].flags & NEEDFROM) && !from)
return;
if (pFuncs[i].flags & DROPONE)
chop(&rest); /* discard bot nick */
chop(&rest); /* discard one argument (usually bot nick) */
pFuncs[i].func(from,rest);
return;
}
}
//debug("unmatched cmdhash %08X\n",cmdhash);
}
/*
(in) {2} :weber.freenode.net PONG weber.freenode.net :OT1521044136
cmdhash = 504F4E47
unmatched cmdhash 504F4E47
(in) {2} :weber.freenode.net 347 jooboy #amdx :End of Channel Invite List
cmdhash = 00333437
unmatched cmdhash 00333437
(in) {2} :weber.freenode.net 349 jooboy #amdx :End of Channel Exception List
cmdhash = 00333439
unmatched cmdhash 00333439
*/

View File

@@ -277,11 +277,11 @@ void update_modes(Chan *chan)
*/
int check_mass(Chan *chan, ChanUser *doer, int type)
{
time_t *when;
int *num,limit;
time_t when;
int num,limit;
/*
* must handle servers ...
* must handle servers ... (netsplits, chanserv, nickserv, ...)
*/
if (!doer)
return(FALSE);
@@ -300,38 +300,37 @@ int check_mass(Chan *chan, ChanUser *doer, int type)
*/
//case CHK_CAPS:
case INT_CKL:
num = &doer->capsnum;
num = INDEX_CAPS;
break;
//case CHK_PUB:
case INT_FL:
num = &doer->floodnum;
num = INDEX_FLOOD;
break;
/*
* three things we dont want channel ops to do
*/
//case CHK_DEOP:
case INT_MDL:
num = &doer->deopnum;
num = INDEX_DEOP;
break;
//case CHK_BAN:
case INT_MBL:
num = &doer->bannum;
num = INDEX_BAN;
break;
default:
/* case CHK_KICK: */
/* case INT_MKL: */
num = &doer->kicknum;
num = INDEX_KICK;
break;
}
when = (time_t*)&num[1];
if ((now - *when) > 10)
if ((now - doer->action_time[num]) > 10)
{
*when = now;
*num = 0;
doer->action_time[num] = now;
doer->action_num[num] = 0;
}
++(*num);
if (*num >= limit && limit)
++(doer->action_num[num]);
if (doer->action_num[num] >= limit && limit)
return(TRUE);
return(FALSE);
}

View File

@@ -1,7 +1,7 @@
/*
EnergyMech, IRC bot software
Copyright (c) 1997-2008 proton
Copyright (c) 1997-2018 proton
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -105,6 +105,7 @@ char *recover_client(char *env)
}
}
close(fd);
killsock(fd);
return(p);
found_user:
@@ -183,6 +184,8 @@ char *recover_debug(char *env)
#endif /* DEBUG */
//execve( ./energymech, argv = { ./energymech <NULL> <NULL> <NULL> <NULL> }, envp = { MECHRESET=d3 f1881:2:X12 f99:4:X12 } )
char *recover_server(char *env)
{
struct sockaddr_in sai;
@@ -268,9 +271,17 @@ char *recover_server(char *env)
debug("(recover_server) {%i} server socket recovered\n",fd);
#endif /* DEBUG */
to_file(fd,"LUSERS\n");
fd = -1;
break;
}
}
// if we recover a guid:socket without a matching bot in config, it got removed or changed guid
// if the guid changed, we cant guess which old<-->new is the matching one so
if (fd != -1)
{
to_file(fd,"QUIT :I'm no longer wanted *cry*\n");
killsock(fd);
}
return(p);
}
@@ -376,22 +387,24 @@ void do_reset(COMMAND_ARGS)
/*
* Save server connections
*/
for(backup=botlist;backup;backup=backup->next)
backup = current;
for(current=botlist;current;current=current->next)
{
if ((backup->connect == CN_ONLINE) && ((MSGLEN - (p - env)) > 25))
if ((current->connect == CN_ONLINE) && ((MSGLEN - (p - env)) > 25))
{
unset_closeonexec(backup->sock);
unset_closeonexec(current->sock);
if (n)
*(p++) = ' ';
#ifdef IRCD_EXTENSIONS
sprintf(p,"f%i:%i:X%i",backup->guid,backup->sock,backup->ircx_flags);
sprintf(p,"f%i:%i:X%i",current->guid,current->sock,current->ircx_flags);
#else /* IRCD_EXTENSIONS */
sprintf(p,"f%i:%i",backup->guid,backup->sock);
sprintf(p,"f%i:%i",current->guid,current->sock);
#endif /* IRCD_EXTENSIONS */
p = STREND(p);
n++;
to_server("PING :OT%lu\n",current->ontime);
}
for(client=backup->clientlist;client;client=client->next)
for(client=current->clientlist;client;client=client->next)
{
#ifdef TELNET
if ((client->flags & (DCC_ACTIVE|DCC_TELNET)) == 0)
@@ -408,15 +421,16 @@ void do_reset(COMMAND_ARGS)
*(p++) = ' ';
#ifdef TELNET
sprintf(p,(client->flags & DCC_TELNET) ? "t%i:%i:%s" : "c%i:%i:%s",
backup->guid,client->sock,client->user->name);
current->guid,current->sock,client->user->name);
#else
sprintf(p,"c%i:%i:%s",backup->guid,client->sock,client->user->name);
sprintf(p,"c%i:%i:%s",current->guid,current->sock,client->user->name);
#endif /* TELNET */
p = STREND(p);
n++;
}
}
}
current = backup;
#ifdef DEBUG
debug("(do_reset) %s [%i]\n",env,(int)(p - env));

View File

@@ -1,7 +1,7 @@
/*
EnergyMech, IRC bot software
Parts Copyright (c) 1997-2009 proton
Parts Copyright (c) 1997-2018 proton
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -320,20 +320,8 @@ typedef struct ChanUser
int flags;
/* distance between &_num -> &_time is used in check_mass */
int floodnum;
time_t floodtime;
int bannum;
time_t bantime;
int deopnum;
time_t deoptime;
int kicknum;
time_t kicktime;
int nicknum;
time_t nicktime;
int capsnum;
time_t capstime;
uint8_t action_num[INDEX_MAX];
time_t action_time[INDEX_MAX];
time_t idletime;
#ifdef CHANBAN
@@ -514,6 +502,11 @@ typedef struct Mech
int server; /* ident of my current server */
int nextserver;
#ifdef BOTNET
const char *supres_cmd;
int supres_crc;
#endif
/*
* Line buffer for non-essential stuff
*/
@@ -549,7 +542,6 @@ typedef struct Mech
#endif /* NOTIFY */
Spy *spylist;
int spy;
#ifdef NOTIFY
@@ -659,7 +651,7 @@ typedef struct BotNet
/*
* do not touch the above vars!
* they are copied partially in net.c
* they are copied partially in that order in net.c
*/
int guid; /* remote bot guid */
@@ -793,7 +785,7 @@ typedef struct OnMsg
redir:1,
lbuf:1,
cbang:1,
acchan:1;
acchan:1; // -- 20 bits
char *cmdarg;
} OnMsg;
@@ -810,7 +802,7 @@ typedef struct dnsAuthority
} dnsAuthority;
typedef struct dnsList
{
{
struct dnsList *next;
time_t when;
struct in_addr ip;

View File

@@ -1,7 +1,7 @@
/*
EnergyMech, IRC bot software
Parts Copyright (c) 1997-2009 proton
Parts Copyright (c) 1997-2018 proton
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -294,9 +294,24 @@ int read_userlist(char *filename)
User *olduserlist;
User *newuserlist;
int in;
#ifdef DEBUG
int r;
#endif
if (!filename)
return(FALSE);
if (*filename == '<') // read only userfile
filename++;
#ifdef DEBUG
if ((r = is_safepath(filename,FILE_MUST_EXIST)) != FILE_IS_SAFE)
{
debug("(write_userlist) %s: unsafe filename (%i)...\n",filename,r);
return(FALSE);
}
#else
if (is_safepath(filename,FILE_MUST_EXIST) != FILE_IS_SAFE)
return(FALSE);
#endif
if ((in = open(filename,O_RDONLY)) < 0)
return(FALSE);
@@ -345,7 +360,7 @@ int write_userlist(char *filename)
char *p,flags[7];
int i,f;
#ifdef DEBUG
int dodeb;
int dodeb,r;
#endif /* DEBUG */
if (!filename)
@@ -354,6 +369,27 @@ int write_userlist(char *filename)
if (!current->ul_save)
return(TRUE);
if (*filename == '<') // we dont write to read only userfiles
#ifdef DEBUG
{
debug("(write_userlist) %s: writing to read only userfile is prohibited...\n",filename);
return(FALSE);
}
#else
return(FALSE);
#endif
#ifdef DEBUG
if ((r = is_safepath(filename,FILE_MAY_EXIST)) != FILE_IS_SAFE)
{
debug("(write_userlist) %s: unsafe filename (%i)...\n",filename,r);
return(FALSE);
}
#else
if (is_safepath(filename,FILE_MAY_EXIST) != FILE_IS_SAFE)
return(FALSE);
#endif
if ((f = open(filename,O_WRONLY|O_CREAT|O_TRUNC,NEWFILEMODE)) < 0)
return(FALSE);