* 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: test:
$(MAKE) -C src test $(MAKE) -C src test
defines:
(gcc -dM -E - < /dev/null) | sort
# #
# packing things up for distribution # packing things up for distribution
# #

View File

@@ -1,5 +1,10 @@
3.1 -- WORK IN PROGRESS (~April, 2018) 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) * Added: Newbie mode warnings about config/userfiles readable by others (exposing passwords)
* Fixed: Issue #25, clients lost when doing reset, no more * Fixed: Issue #25, clients lost when doing reset, no more
* Fixed: compiler warnings and missing defines/conflicting defines with certain options * 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) if (*pp == chan)
{ {
*pp = chan->next; *pp = chan->next;
purge_banlist(chan); purge_linklist((void**)&chan->banlist);
purge_chanusers(chan); purge_chanusers(chan);
delete_vars(chan->setting,CHANSET_SIZE); delete_vars(chan->setting,CHANSET_SIZE);
Free(&chan->name); Free(&chan->name);
@@ -350,20 +350,6 @@ void delete_modemask(Chan *chan, char *mask, int mode)
#endif /* IRCD_EXTENSIONS */ #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) void channel_massmode(const Chan *chan, char *pattern, int filtmode, char mode, char typechar)
{ {
ChanUser *cu; ChanUser *cu;

View File

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

View File

@@ -773,6 +773,7 @@ void debug_core(void)
User *user; User *user;
int i; int i;
debug("; mx_pfmt\t\t\"%s\"\n",mx_pfmt);
debug("; VERSION\t\t\"%s\"\n",VERSION); debug("; VERSION\t\t\"%s\"\n",VERSION);
debug("; SRCDATE\t\t\"%s\"\n",SRCDATE); debug("; SRCDATE\t\t\"%s\"\n",SRCDATE);
debug("; BOTLOGIN\t\t\"%s\"\n",BOTLOGIN); debug("; BOTLOGIN\t\t\"%s\"\n",BOTLOGIN);
@@ -1176,13 +1177,14 @@ void debug_core(void)
memtouch(bigc); memtouch(bigc);
debug(" ; width\t\t%i\n",bigc->width); debug(" ; width\t\t%i\n",bigc->width);
debug(" ; chars\t\t\"%s\"\n",bigc->chars); debug(" ; chars\t\t\"%s\"\n",bigc->chars);
debug(" > data\t\t"mx_pfmt"\n",(mx_ptr)bigc->data); debug(" > data\t\t" mx_pfmt "\n",(mx_ptr)bigc->data);
for(st=bigc->data;st;st=st->next) for(st=bigc->data;st != NULL;st=st->next)
{ {
memtouch(st); memtouch(st);
debug(" ; Strp*\t\t"mx_pfmt" { "mx_pfmt", \"%s\" }\n", debug(" ; Strp*\t\t"mx_pfmt" { "mx_pfmt", \"%s\" }\n",
(mx_ptr)st,(mx_ptr)st->next,st->p); (mx_ptr)st,(mx_ptr)st->next,st->p);
} }
debug(" ; next\t\t" mx_pfmt "\n",(mx_ptr)bigc->next);
} }
#endif /* TOYBOX */ #endif /* TOYBOX */
#ifdef TRIVIA #ifdef TRIVIA
@@ -1403,7 +1405,7 @@ void debug(char *format, ...)
{ {
if (debugfile) 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; dodebug = FALSE;
return; 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) while(sp)
{ {
nxt = sp->next; nxt = sp->next;
Free((char**)&sp); Free((char**)&sp);
sp = nxt; sp = nxt;
} }
*list = NULL;
} }
/* /*

View File

@@ -152,7 +152,6 @@ char *find_nuh(char *);
Ban *make_ban(Ban **, char *, char *, time_t); Ban *make_ban(Ban **, char *, char *, time_t);
void delete_ban(Chan *, char *); void delete_ban(Chan *, char *);
void delete_modemask(Chan *, char *, int); void delete_modemask(Chan *, char *, int);
void purge_banlist(Chan *);
void channel_massmode(const Chan *, char *, int, char, char); void channel_massmode(const Chan *, char *, int, char, char);
void channel_massunban(Chan *, char *, time_t); void channel_massunban(Chan *, char *, time_t);
LS ChanUser *find_chanuser(Chan *, const char *); 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 *make_strp(Strp **, const char *) __attr(CORE_SEG, __regparm(2));
LS Strp *append_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 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 void dupe_strp(Strp *, Strp **) __attr(CORE_SEG, __regparm(2));
LS const int StrlenX(const char *, ...) __attr(CORE_SEG, __regparm(1)); LS const int StrlenX(const char *, ...) __attr(CORE_SEG, __regparm(1));
LS const int Strlen2(const char *, const char *) __attr(CORE_SEG, __regparm(2)); 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 #ifdef DEBUG
debug("(do_clearqueue) purging sendq...\n"); debug("(do_clearqueue) purging sendq...\n");
#endif #endif
purge_strplist(current->sendq); purge_linklist((void**)&current->sendq);
current->sendq = NULL;
} }
#endif /* GENCMD_C */ #endif /* GENCMD_C */

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -269,6 +269,14 @@ void ec_ver(char *from, const char *to)
nobo_strcpy(VERSION); 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 LS const struct
{ {
void (*func)(char *, const char *); void (*func)(char *, const char *);
@@ -287,6 +295,7 @@ LS const struct
{ ec_server, "$server", 7 }, { ec_server, "$server", 7 },
{ ec_up, "$up", 3 }, { ec_up, "$up", 3 },
{ ec_ver, "$ver", 4 }, { ec_ver, "$ver", 4 },
{ ec_guid, "$guid", 5 },
{ NULL, "", 0 }, { NULL, "", 0 },
}; };