* Added: $guid to esay variables

* Added: New bigsay font: spider, use with .bigsay -spider cowabunga!
 * Fixed: Error in printing pointers would make lots of debug output go missing
 * Changed: Debug output (./energymech -d -o <file>) now appends instead of truncating
 * Fixed: Botnet auth messages now propagate correctly throughout the botnet
This commit is contained in:
joonicks
2018-04-22 02:34:04 +02:00
parent 808269bb68
commit 0e6f3c4b73
15 changed files with 312 additions and 68 deletions

View File

@@ -100,6 +100,9 @@ mega-install:
test:
$(MAKE) -C src test
defines:
(gcc -dM -E - < /dev/null) | sort
#
# packing things up for distribution
#

View File

@@ -1,5 +1,10 @@
3.1 -- WORK IN PROGRESS (~April, 2018)
* Added: $guid to esay variables
* Added: New bigsay font: spider, use with .bigsay -spider cowabunga!
* Fixed: Error in printing pointers would make lots of debug output go missing
* Changed: Debug output (./energymech -d -o <file>) now appends instead of truncating
* Fixed: Botnet auth messages now propagate correctly throughout the botnet
* Added: Newbie mode warnings about config/userfiles readable by others (exposing passwords)
* Fixed: Issue #25, clients lost when doing reset, no more
* Fixed: compiler warnings and missing defines/conflicting defines with certain options

208
spider.bigchars Normal file
View File

@@ -0,0 +1,208 @@
fontname energymech-capitals-spider-height5-v3
spacewidth 4
charheight 5
kerning 1
chars !
|
|
|
o
chars .
o
chars |
|
|
|
|
|
chars :
o
o
chars aA
,-.
/ \
|___|
| |
| |
chars bB
,--.
| )
|--{
| \
|___/
chars cC
,--.
/
|
|
\___/
chars dD
,-.
| \
| |
| |
|___/
chars eE
,---
|
|--
|
|___,
chars fF
,---
|
|--
|
|
chars gG
,--.
/
| _
| |
\___/
chars hH
, ,
| |
|___|
| |
| |
chars iI
,
|
|
|
|
chars jJ
,
|
|
, |
\___/
chars kK
, ,
| /
|-{
| \
| \
chars lL
,
|
|
|
|___,
chars mM
,~. ,~.
| | |
| | |
| | |
| | |
chars nN
, ,
|\ |
| \ |
| \|
| |
chars oO
,-~-.
| |
| |
| |
\___/
chars pP
,--.
| )
|--'
|
|
chars rR
,--.
| )
|--'
| \
| \
chars sS
,-~
(
'-.
)
'--'
chars tT
~-+-~
|
|
|
+
chars uU
, ,
| |
| |
| |
\___/
chars vV
, ,
| |
' '
\ /
V
chars wW
, , ,
| | |
| | |
' | '
\/ \/
chars xX
. ,
\ /
X
/ \
/ \
chars yY
. ,
\ /
Y
|
|
chars zZ
-~~,
/
/
/
/___,

View File

@@ -97,7 +97,7 @@ void remove_chan(Chan *chan)
if (*pp == chan)
{
*pp = chan->next;
purge_banlist(chan);
purge_linklist((void**)&chan->banlist);
purge_chanusers(chan);
delete_vars(chan->setting,CHANSET_SIZE);
Free(&chan->name);
@@ -350,20 +350,6 @@ void delete_modemask(Chan *chan, char *mask, int mode)
#endif /* IRCD_EXTENSIONS */
void purge_banlist(Chan *chan)
{
Ban *ban,*next;
ban = chan->banlist;
while(ban)
{
next = ban->next;
Free((char**)&ban);
ban = next;
}
chan->banlist = NULL;
}
void channel_massmode(const Chan *chan, char *pattern, int filtmode, char mode, char typechar)
{
ChanUser *cu;

View File

@@ -427,15 +427,25 @@
*/
#ifdef PTSIZE_32BIT
#if defined(__GNUC__)
#define mx_ptr void*
#define mx_pfmt "%p"
#else
#define mx_ptr unsigned int
#define mx_pfmt "%.8x"
#endif
#endif
#ifdef PTSIZE_64BIT
#if defined(__GNUC__)
#define mx_ptr void*
#define mx_pfmt "%p"
#else
#define mx_ptr long long
#define mx_pfmt "%.16Lx"
#endif
#endif

View File

@@ -773,6 +773,7 @@ void debug_core(void)
User *user;
int i;
debug("; mx_pfmt\t\t\"%s\"\n",mx_pfmt);
debug("; VERSION\t\t\"%s\"\n",VERSION);
debug("; SRCDATE\t\t\"%s\"\n",SRCDATE);
debug("; BOTLOGIN\t\t\"%s\"\n",BOTLOGIN);
@@ -1176,13 +1177,14 @@ void debug_core(void)
memtouch(bigc);
debug(" ; width\t\t%i\n",bigc->width);
debug(" ; chars\t\t\"%s\"\n",bigc->chars);
debug(" > data\t\t"mx_pfmt"\n",(mx_ptr)bigc->data);
for(st=bigc->data;st;st=st->next)
debug(" > data\t\t" mx_pfmt "\n",(mx_ptr)bigc->data);
for(st=bigc->data;st != NULL;st=st->next)
{
memtouch(st);
debug(" ; Strp*\t\t"mx_pfmt" { "mx_pfmt", \"%s\" }\n",
(mx_ptr)st,(mx_ptr)st->next,st->p);
}
debug(" ; next\t\t" mx_pfmt "\n",(mx_ptr)bigc->next);
}
#endif /* TOYBOX */
#ifdef TRIVIA
@@ -1403,7 +1405,7 @@ void debug(char *format, ...)
{
if (debugfile)
{
if ((debug_fd = open(debugfile,O_CREAT|O_TRUNC|O_WRONLY,SECUREFILEMODE)) < 0)
if ((debug_fd = open(debugfile,O_CREAT|O_APPEND|O_WRONLY,SECUREFILEMODE)) < 0)
{
dodebug = FALSE;
return;

View File

@@ -194,18 +194,20 @@ Strp *prepend_strp(Strp **pp, const char *string)
}
/*
* Free() a chain of Strp's
* Free() a whole linked list of any suitable type (Strp, Banlist)
*/
void purge_strplist(Strp *sp)
void purge_linklist(void **list)
{
Strp *nxt;
Strp *sp,*nxt;
sp = *list;
while(sp)
{
nxt = sp->next;
Free((char**)&sp);
sp = nxt;
}
*list = NULL;
}
/*

View File

@@ -152,7 +152,6 @@ char *find_nuh(char *);
Ban *make_ban(Ban **, char *, char *, time_t);
void delete_ban(Chan *, char *);
void delete_modemask(Chan *, char *, int);
void purge_banlist(Chan *);
void channel_massmode(const Chan *, char *, int, char, char);
void channel_massunban(Chan *, char *, time_t);
LS ChanUser *find_chanuser(Chan *, const char *);
@@ -280,7 +279,7 @@ LS void Free(char **) __attr(CORE_SEG, __regparm(1));
LS Strp *make_strp(Strp **, const char *) __attr(CORE_SEG, __regparm(2));
LS Strp *append_strp(Strp **, const char *) __attr(CORE_SEG, __regparm(2));
LS Strp *prepend_strp(Strp **, const char *) __attr(CORE_SEG, __regparm(2));
LS void purge_strplist(Strp *) __attr(CORE_SEG, __regparm(1));
LS void purge_linklist(void **) __attr(CORE_SEG, __regparm(1));
LS void dupe_strp(Strp *, Strp **) __attr(CORE_SEG, __regparm(2));
LS const int StrlenX(const char *, ...) __attr(CORE_SEG, __regparm(1));
LS const int Strlen2(const char *, const char *) __attr(CORE_SEG, __regparm(2));

View File

@@ -689,8 +689,7 @@ void do_clearqueue(COMMAND_ARGS)
#ifdef DEBUG
debug("(do_clearqueue) purging sendq...\n");
#endif
purge_strplist(current->sendq);
current->sendq = NULL;
purge_linklist((void**)&current->sendq);
}
#endif /* GENCMD_C */

View File

@@ -452,10 +452,6 @@ void sig_segv(int crap, siginfo_t *si, void *uap)
time(&now);
respawn++;
if (respawn > 10)
mechexit(1,exit);
#ifdef DEBUG
debug("(sigsegv) trying to access "mx_pfmt"\n",(mx_ptr)si->si_addr);
#ifdef __x86_64__
@@ -475,6 +471,10 @@ void sig_segv(int crap, siginfo_t *si, void *uap)
}
#endif /* DEBUG */
respawn++;
if (respawn > 10)
mechexit(1,exit);
do_exec = TRUE;
sig_suicide(TEXT_SIGSEGV /* comma */ UP_CALL(UPTIME_SIGSEGV));
/* NOT REACHED */
@@ -1171,6 +1171,7 @@ int main(int argc, char **argv, char **envp)
{
mirror_userlist();
}
#ifdef SEEN
read_seenlist();
#endif /* SEEN */
@@ -1227,8 +1228,12 @@ int main(int argc, char **argv, char **envp)
s.sa_flags = SA_SIGINFO;
sigemptyset(&s.sa_mask);
s.sa_sigaction = sig_segv;
sigaction(SIGSEGV, &s, NULL);
//signal(SIGSEGV,sig_segv);
if (sigaction(SIGSEGV, &s, NULL) < 0)
{
#ifdef DEBUG
debug("(main) binding SIGSEGV handler failed: %s\n",strerror(errno));
#endif
}
#ifdef DEBUG
signal(SIGILL,sig_ill);
signal(SIGABRT,sig_abrt);
@@ -1245,5 +1250,8 @@ int main(int argc, char **argv, char **envp)
_exit(0);
}
startup = FALSE;
#ifdef DEBUG
debug("(main) entering doit()...\n");
#endif
doit();
}

View File

@@ -64,32 +64,35 @@ LS struct
*/
typedef struct LinkCmd
{
char c1;
char c2;
char cmd[2];
void (*func)(BotNet *, char *);
int relay;
} LinkCmd;
#define RELAY_YES 1
#define RELAY_NO 0
LS const LinkCmd basicProto[] =
{
{ 'B', 'A', basicAuth },
{ 'B', 'B', basicBanner },
{ 'B', 'K', basicAuthOK },
{ 'B', 'L', basicLink },
{ 'B', 'Q', basicQuit },
{ 'C', 'O', netchanNeedop },
{ "BA", basicAuth, RELAY_NO },
{ "BB", basicBanner, RELAY_NO },
{ "BK", basicAuthOK, RELAY_NO },
{ "BL", basicLink, RELAY_NO },
{ "BQ", basicQuit, RELAY_NO },
{ "CO", netchanNeedop, RELAY_YES },
#ifdef SUPPRESS
{ 'C', 'S', netchanSuppress }, // experimental command supression
{ "CS", netchanSuppress, RELAY_YES }, // experimental command supression
#endif /* SUPPRESS */
{ 'P', 'A', partyAuth },
{ "PA", partyAuth, RELAY_YES },
#ifdef REDIRECT
{ 'P', 'C', partyCommand },
{ "PC", partyCommand, RELAY_NO },
#endif /* REDIRECT */
{ 'P', 'M', partyMessage },
{ 'U', 'T', ushareTick },
{ 'U', 'U', ushareUser },
{ 'U', 'D', ushareDelete },
{ 0, 0, NULL },
{ "PM", partyMessage, RELAY_NO },
{ "UT", ushareTick, RELAY_NO },
{ "UU", ushareUser, RELAY_NO },
{ "UD", ushareDelete, RELAY_YES },
{ "\0\0", NULL, RELAY_NO },
};
LS int deadlinks = FALSE;
@@ -844,8 +847,6 @@ void netchanNeedop(BotNet *source, char *rest)
if (errno || guid < 1 || !channel)
return;
botnet_relay(source,"CO%i %s\n",guid,channel);
for(bn=botnetlist;bn;bn=bn->next)
{
if (bn->status != BN_LINKED)
@@ -866,8 +867,6 @@ void netchanSuppress(BotNet *source, char *rest)
const char *cmd;
int crc,i,j;
botnet_relay(source,"CS%s\n",rest);
cmd = chop(&rest);
// convert command to const command
@@ -1339,8 +1338,6 @@ void ushareDelete(BotNet *bn, char *rest)
}
}
}
unchop(orig,rest);
botnet_relay(bn,"UD%s\n",orig);
}
/*
@@ -1383,8 +1380,10 @@ not_a_botnet_connection:
for(i=0;basicProto[i].func;i++)
{
if (basicProto[i].c1 == rest[0] && basicProto[i].c2 == rest[1])
if (basicProto[i].cmd[0] == rest[0] && basicProto[i].cmd[1] == rest[1])
{
if (basicProto[i].relay == RELAY_YES)
botnet_relay(bn,"%s\n",rest);
basicProto[i].func(bn,rest+2);
return;
}

View File

@@ -111,7 +111,7 @@ void parse_join(char *from, char *rest)
current->lastchanban = 0;
#endif /* CHANBAN */
to_server("WHO %s\nMODE %s\nMODE %s b\n",rest,rest,rest);
purge_banlist(chan);
purge_linklist((void**)&chan->banlist);
purge_chanusers(chan);
#ifdef STATS

View File

@@ -406,8 +406,7 @@ void urlcapture(const char *rest)
{
if (n <= 0)
{
purge_strplist(sp->next);
sp->next = NULL;
purge_linklist((void**)&sp->next);
return;
}
n--;

View File

@@ -90,14 +90,11 @@ int read_bigcharset_callback(char *rest)
if (!stringcasecmp(opt,"chars") && charheight)
{
charlines = charheight;
opt = chop(&rest);
set_mallocdoer(read_bigcharset_callback);
newchar = (BigC*)Calloc(sizeof(BigC) + strlen(opt));
/* Calloc sets to zero
newchar->width = 0;
newchar->data = NULL;
*/
newchar->next = fontlist;
fontlist = newchar;
stringcpy(newchar->chars,opt);
@@ -141,7 +138,6 @@ int read_bigcharset_callback(char *rest)
*n = asc2int(rest);
if (errno) *n = 0;
}
return(FALSE);
}
@@ -163,6 +159,7 @@ int read_bigcharset(char *fname)
orig_spacewidth = spacewidth;
orig_kerning = kerning;
fontlist = NULL;
charlines = 0;
spacewidth = 0;
charheight = 0;
@@ -173,12 +170,15 @@ int read_bigcharset(char *fname)
/*
* free the old font if there is one
*/
#ifdef DEBUG
debug("(read_bigcharset) purge old charset, if there is one. orig = %p\n",orig_fontlist);
#endif
while(orig_fontlist)
{
bigc = orig_fontlist;
orig_fontlist = bigc->next;
if (bigc->data)
purge_strplist(bigc->data);
purge_linklist((void**)&bigc->data);
Free((char**)&bigc);
}
@@ -708,6 +708,7 @@ void read_triviascore(void)
void do_bigsay(COMMAND_ARGS)
{
#define OEND (output + MSGLEN - 1)
/*
* on_msg checks CARGS + CAXS
*/
@@ -717,19 +718,33 @@ void do_bigsay(COMMAND_ARGS)
char *pt,*tail,*temp,*temp2;
int i,x;
#ifdef DEBUG
debug("(do_bigsay) rest = \"%s\"\n",rest);
#endif /* DEBUG */
if (fontname && *rest != '-')
goto reuse_font;
stringcpy(output,BIGSAY_DEFAULTFONT);
if (rest[0] == '-')
{
temp = chop(&rest);
if (temp[1] == '-')
; // allow .bigsay -- -dash-
else
if (STRCHR(temp,'/') == NULL) // no filesystem perversions...
{
stringcat(stringcpy(output,temp+1),".bigchars"); // temp+1 = skip initial '-'
}
}
#ifdef DEBUG
debug("(do_bigsay) fontfile %s, text = \"%s\"\n",output,rest);
#endif /* DEBUG */
if (read_bigcharset(output) < 0)
{
to_user(from,ERR_FILEOPEN,output);
return;
}
#define OEND (output + MSGLEN - 1)
reuse_font:
for(i=0;i<charheight;i++)
{
*output = 0;

View File

@@ -269,6 +269,14 @@ void ec_ver(char *from, const char *to)
nobo_strcpy(VERSION);
}
void ec_guid(char *from, const char *to)
{
char tmp[32];
sprintf(tmp,"%i",current->guid);
nobo_strcpy(tmp);
}
LS const struct
{
void (*func)(char *, const char *);
@@ -287,6 +295,7 @@ LS const struct
{ ec_server, "$server", 7 },
{ ec_up, "$up", 3 },
{ ec_ver, "$ver", 4 },
{ ec_guid, "$guid", 5 },
{ NULL, "", 0 },
};