Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into doc2
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelortmann committed Jan 30, 2025
2 parents 06e7eba + 028e756 commit 4ac3e2f
Show file tree
Hide file tree
Showing 23 changed files with 71 additions and 49 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ eggdrop
EGGMOD.stamp
mod.xlibs
__pycache__
.clangd
2 changes: 1 addition & 1 deletion doc/sphinx_source/using/core.rst
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ Modules

After the core settings, you should start loading modules. Modules are
loaded by the command "loadmodule <module>". Eggdrop looks for modules
in the directory you specified by the module-path setting in the files
in the directory you specified by the mod-path setting in the files
and directories section.

Please note that for different configurations, different modules are needed.
Expand Down
2 changes: 1 addition & 1 deletion src/cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -2577,7 +2577,7 @@ int stripmodes(char *s)
return res;
}

char *stripmasktype(int x)
const char *stripmasktype(int x)
{
static char s[20];
char *p = s;
Expand Down
4 changes: 2 additions & 2 deletions src/compat/inet_aton.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ int egg_inet_aton(const char *cp, struct in_addr *addr) {
u_long val;
int base, n;
char c;
u_int8_t parts[4];
u_int8_t *pp = parts;
uint8_t parts[4];
uint8_t *pp = parts;
int digit;

c = *cp;
Expand Down
8 changes: 7 additions & 1 deletion src/dcc.c
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,14 @@ static char *get_bot_pass(struct userrec *u) {
if (pass2) {
if (!pass) {
pass = pass2;
if (encrypt_pass)
if (encrypt_pass) {
/* get_user() returns a pointer of struct user_entry
* and set_user()->pass2_set() could free() and realloc it
* so fetch it again with get_user()
*/
set_user(&USERENTRY_PASS, u, pass);
pass = get_user(&USERENTRY_PASS2, u);
}
} else if (strcmp(pass2, pass) && encrypt_pass2)
pass = pass2;
} else if (pass && encrypt_pass2)
Expand Down
3 changes: 2 additions & 1 deletion src/dns.c
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,8 @@ void *thread_dns_ipbyhost(void *arg)
else if (error == EAI_NONAME)
snprintf(dtn->strerror, sizeof dtn->strerror, "dns: thread_dns_ipbyhost(): getaddrinfo(): not known");
else if (error == EAI_SYSTEM) {
snprintf(dtn->strerror, sizeof dtn->strerror, "dns: thread_dns_ipbyhost(): getaddrinfo(): %s: %s", gai_strerror(error), strerror(errno));
/* print raw errno, dont use strerror() in thread and dont use strerror_r() due to GNU / POSIX portability complexity */
snprintf(dtn->strerror, sizeof dtn->strerror, "dns: thread_dns_ipbyhost(): getaddrinfo(): %s: errno %i", gai_strerror(error), errno);
} else
snprintf(dtn->strerror, sizeof dtn->strerror, "dns: thread_dns_ipbyhost(): getaddrinfo(): %s", gai_strerror(error));
close(dtn->fildes[1]);
Expand Down
2 changes: 1 addition & 1 deletion src/flags.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ int logmodes(char *s)
return res;
}

char *masktype(int x)
const char *masktype(int x)
{
static char s[27]; /* Change this if you change the levels */
char *p = s;
Expand Down
2 changes: 1 addition & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,7 @@ static void mainloop(int toplevel)
if (strcmp(p->name, "eggdrop") && strcmp(p->name, "encryption") &&
strcmp(p->name, "encryption2") && strcmp(p->name, "uptime")) {
f++;
debug1("stagnant module %s", p->name);
putlog(LOG_MISC, "*", "stagnant module %s", p->name);
}
}
if (f != 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ int egg_strcatn(char *dst, const char *src, size_t max)
return tmpmax - max;
}

int my_strcpy(char *a, char *b)
int my_strcpy(char *a, const char *b)
{
char *c = b;

Expand Down
4 changes: 2 additions & 2 deletions src/mod/ident.mod/ident.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ static void ident_activity(int idx, char *buf, int len)
putlog(LOG_MISC, "*", "Ident error: %s", strerror(errno));
return;
}
buf2[i - 1] = 0;
buf2[i] = 0;
if (!(pos = strpbrk(buf2, "\r\n"))) {
putlog(LOG_MISC, "*", "Ident error: could not read request.");
return;
}
}
snprintf(pos, (sizeof buf2) - (pos - buf2), " : USERID : UNIX : %s\r\n", botname);
count = strlen(buf2) + 1;
if ((i = write(s, buf2, count)) != count) {
Expand Down
15 changes: 11 additions & 4 deletions src/mod/irc.mod/chan.c
Original file line number Diff line number Diff line change
Expand Up @@ -1258,12 +1258,13 @@ static int gotchghost(char *from, char *msg) {
*/
static int got353(char *from, char *msg)
{
struct capability *current;
char prefixchars[64];
char *nameptr, *chname, *uhost, *nick, *p, *host = NULL;
struct chanset_t *chan = NULL;
int i;

if (find_capability("userhost-in-names")) {
if ((current = find_capability("userhost-in-names")) && current->enabled) {
strlcpy(prefixchars, isupport_get_prefixchars(), sizeof prefixchars);
newsplit(&msg);
newsplit(&msg); /* Get rid of =, @, or * symbol */
Expand Down Expand Up @@ -2240,7 +2241,7 @@ static int gotjoin(char *from, char *channame)
*/
static int gotpart(char *from, char *msg)
{
char *nick, *chname, *key;
char *nick, *chname, uhost[UHOSTLEN], *key;
struct chanset_t *chan;
struct userrec *u;
memberlist *m;
Expand All @@ -2255,9 +2256,14 @@ static int gotpart(char *from, char *msg)
return 0;
}
if (chan && !channel_pending(chan)) {
strlcpy(uhost, from, sizeof uhost);
nick = splitnick(&from);
m = ismember(chan, nick);
u = get_user_from_member(m);
// TODO: check account from rawt account-tags
if (m)
u = get_user_from_member(m);
else
u = get_user_by_host(uhost);
if (!channel_active(chan)) {
/* whoa! */
putlog(LOG_MISC, chan->dname,
Expand All @@ -2276,7 +2282,8 @@ static int gotpart(char *from, char *msg)
if (!chan)
return 0;

killmember(chan, nick);
if (m)
killmember(chan, nick);
if (msg[0])
putlog(LOG_JOIN, chan->dname, "%s (%s) left %s (%s).", nick, from,
chan->dname, msg);
Expand Down
1 change: 1 addition & 0 deletions src/mod/irc.mod/irc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1346,6 +1346,7 @@ static char *irc_close()
rem_builtins(H_dcc, irc_dcc);
rem_builtins(H_msg, C_msg);
rem_builtins(H_raw, irc_raw);
rem_builtins(H_rawt, irc_rawt);
rem_builtins(H_isupport, irc_isupport_binds);
rem_tcl_commands(tclchan_cmds);
rem_help_reference("irc.help");
Expand Down
6 changes: 3 additions & 3 deletions src/mod/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ typedef void (*chanout_butfunc)(int, int, const char *, ...) ATTRIBUTE_FORMAT(pr
#define interp (*(Tcl_Interp **)(global[128]))
#define now (*(time_t*)global[129])
#define findanyidx ((int (*)(int))global[130])
#define findchan ((struct chanset_t *(*)(char *))global[131])
#define findchan ((struct chanset_t *(*)(const char *))global[131])
/* 132 - 135 */
#define cmd_die (global[132])
#define days ((void (*)(time_t,time_t,char *))global[133])
Expand Down Expand Up @@ -374,8 +374,8 @@ typedef void (*chanout_butfunc)(int, int, const char *, ...) ATTRIBUTE_FORMAT(pr
/* 216 - 219 */
#define fcopyfile ((int (*) (FILE *, char *))global[216])
#define copyfilef ((int (*) (char *, FILE *))global[217])
#define rfc_casecmp ((int(*)(char *, char *))(*(Function**)(global[218])))
#define rfc_ncasecmp ((int(*)(char *, char *, int *))(*(Function**)(global[219])))
#define rfc_casecmp ((int(*)(const char *, const char *))(*(Function**)(global[218])))
#define rfc_ncasecmp ((int(*)(const char *, const char *, int *))(*(Function**)(global[219])))
/* 220 - 223 */
#define global_exempts (*(maskrec **)(global[220]))
#define global_invites (*(maskrec **)(global[221]))
Expand Down
3 changes: 1 addition & 2 deletions src/mod/pbkdf2.mod/pbkdf2.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "src/mod/module.h"

#if OPENSSL_VERSION_NUMBER >= 0x1000000fL /* 1.0.0 */
static Function *global = NULL; /* before tclpbkdf2.c */
#include "tclpbkdf2.c"

#define MODULE_NAME "encryption2"
Expand All @@ -21,8 +22,6 @@
/* Salt string length */
#define PBKDF2_SALT_LEN 16 /* DO NOT TOUCH! */

static Function *global = NULL;

/* Cryptographic hash function used. openssl list -digest-algorithms */
static char pbkdf2_method[28] = "SHA256";
/* Enable re-encoding of password if pbkdf2-method and / or pbkdf2-rounds
Expand Down
5 changes: 2 additions & 3 deletions src/mod/python.mod/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,5 @@ distclean: clean
../../../src/compat/inet_aton.h ../../../src/compat/snprintf.h \
../../../src/compat/explicit_bzero.h ../../../src/compat/strlcpy.h \
../../../src/mod/modvals.h ../../../src/tandem.h \
../../../src/mod/irc.mod/irc.h ../../../src/mod/server.mod/server.h \
.././python.mod/python.h .././python.mod/pycmds.c \
.././python.mod/tclpython.c
../../../src/mod/server.mod/server.h .././python.mod/python.h \
.././python.mod/pycmds.c .././python.mod/tclpython.c
33 changes: 13 additions & 20 deletions src/mod/python.mod/python.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,14 @@
#undef days
#include <Python.h>
#include <datetime.h>
#include "src/mod/irc.mod/irc.h"
#include "src/mod/server.mod/server.h"
#include "python.h"

//static PyObject *pymodobj;
static PyObject *pirp, *pglobals;

#undef global
static Function *global = NULL, *irc_funcs = NULL;
static Function *global = NULL;
static PyThreadState *_pythreadsave;
#include "pycmds.c"
#include "tclpython.c"
Expand Down Expand Up @@ -141,33 +140,27 @@ static Function python_table[] = {
char *python_start(Function *global_funcs)
{
char *s;

/* Assign the core function table. After this point you use all normal
* functions defined in src/mod/modules.h
*/
global = global_funcs;

/* Register the module. */
module_register(MODULE_NAME, python_table, 0, 1);

if (!module_depend(MODULE_NAME, "eggdrop", 109, 0)) {
module_undepend(MODULE_NAME);
return "This module requires Eggdrop 1.9.0 or later.";
}
// TODO: Is this dependency necessary? It auto-loads irc.mod, that might be undesired
if (!(irc_funcs = module_depend(MODULE_NAME, "irc", 1, 5))) {
module_undepend(MODULE_NAME);
return "This module requires irc module 1.5 or later.";
if (global_funcs) {
global = global_funcs;

/* Register the module. */
module_register(MODULE_NAME, python_table, 0, 1);
if (!module_depend(MODULE_NAME, "eggdrop", 109, 0)) {
module_undepend(MODULE_NAME);
return "This module requires Eggdrop 1.9.0 or later.";
}
if ((s = init_python()))
return s;
}
// irc.mod depends on server.mod and channels.mod, so those were implicitly loaded

if ((s = init_python()))
return s;

/* Add command table to bind list */
add_builtins(H_dcc, mydcc);
add_tcl_commands(my_tcl_cmds);
add_hook(HOOK_PRE_SELECT, (Function)python_gil_unlock);
add_hook(HOOK_POST_SELECT, (Function)python_gil_lock);

return NULL;
}
2 changes: 1 addition & 1 deletion src/mod/server.mod/isupport.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ static int keycmp(const char *key1, const char *key2, size_t key2len) {
- truncate into allowed range if outside allowed range?
- default value to use if outside allowed range
*/
int isupport_parseint(char *key, char *value, int min, int max, int truncate, int defaultvalue, int *dst)
int isupport_parseint(const char *key, const char *value, int min, int max, int truncate, int defaultvalue, int *dst)
{
long result;
char *tmp;
Expand Down
2 changes: 1 addition & 1 deletion src/modules.c
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,6 @@ int module_register(char *name, Function *funcs, int major, int minor)

const char *module_load(char *name)
{
size_t len;
module_entry *p;
char *e;
Function f;
Expand All @@ -704,6 +703,7 @@ const char *module_load(char *name)
#endif

#ifndef STATIC
size_t len;
char workbuf[PATH_MAX];
# ifdef MOD_USE_SHL
shl_t hand;
Expand Down
6 changes: 3 additions & 3 deletions src/proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ void tell_verbose_status(int);
void tell_settings(int);
int logmodes(char *);
int isowner(char *);
char *masktype(int);
const char *masktype(int);
char *maskname(int);
void reaffirm_owners(void);
void add_hq_user(void);
Expand All @@ -124,7 +124,7 @@ int check_dcc_attrs(struct userrec *, int);
int check_dcc_chanattrs(struct userrec *, char *, int, int);
int check_int_range(char *value, int min, int max);
int stripmodes(char *);
char *stripmasktype(int);
const char *stripmasktype(int);
char *check_validpass(struct userrec *, char *);
void cmd_die(struct userrec *, int, char *);

Expand Down Expand Up @@ -226,7 +226,7 @@ void debug_mem_to_dcc(int);

/* misc.c */
int egg_strcatn(char *, const char *, size_t);
int my_strcpy(char *, char *);
int my_strcpy(char *, const char *);
void putlog(int type, char *chname, const char *format, ...) ATTRIBUTE_FORMAT(printf,3,4);
void check_logsize(void);
void splitc(char *, char *, char);
Expand Down
6 changes: 6 additions & 0 deletions src/tcl.c
Original file line number Diff line number Diff line change
Expand Up @@ -615,10 +615,14 @@ int tclthreadmainloop(int zero)
return (i == -5);
}

struct threaddata *td_main = 0;

struct threaddata *threaddata()
{
static Tcl_ThreadDataKey tdkey;
struct threaddata *td = Tcl_GetThreadData(&tdkey, sizeof(struct threaddata));
if (!(td->mainloopfunc) && td_main) /* python thread */
return td_main;
return td;
}

Expand All @@ -638,6 +642,8 @@ void init_threaddata(int mainthread)
td->blocktime.tv_usec = 0;
td->MAXSOCKS = 0;
increase_socks_max();
if (mainthread)
td_main = td;
}

/* workaround for Tcl that does not support unicode outside BMP (3 byte utf-8 characters) */
Expand Down
6 changes: 6 additions & 0 deletions src/tclhash.c
Original file line number Diff line number Diff line change
Expand Up @@ -1240,13 +1240,19 @@ void check_tcl_die(char *reason)
void check_tcl_log(int lv, char *chan, char *msg)
{
char mask[512];
Tcl_Obj* prev_result;

/* We have to store the old result, as check_tcl_bind may override it */
prev_result = Tcl_GetObjResult(interp);
Tcl_IncrRefCount(prev_result);
egg_snprintf(mask, sizeof mask, "%s %s", chan, msg);
Tcl_SetVar(interp, "_log1", masktype(lv), TCL_GLOBAL_ONLY);
Tcl_SetVar(interp, "_log2", chan, TCL_GLOBAL_ONLY);
Tcl_SetVar(interp, "_log3", msg, TCL_GLOBAL_ONLY);
check_tcl_bind(H_log, mask, 0, " $::_log1 $::_log2 $::_log3",
MATCH_MASK | BIND_STACKABLE);
Tcl_SetObjResult(interp, prev_result);
Tcl_DecrRefCount(prev_result);
}

#ifdef TLS
Expand Down
2 changes: 2 additions & 0 deletions src/userrec.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,8 @@ void clear_masks(maskrec *m)
temp = m->next;
if (m->mask)
nfree(m->mask);
if (m->user)
nfree(m->user);
if (m->desc)
nfree(m->desc);
nfree(m);
Expand Down
3 changes: 2 additions & 1 deletion src/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@
*/

#define EGG_STRINGVER "1.10.0"
#define EGG_NUMVER 1100003
#define EGG_NUMVER 1100005
#define EGG_PATCH "pythonfixes"

0 comments on commit 4ac3e2f

Please sign in to comment.