Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance load module #1624

Merged
merged 2 commits into from
Jul 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions eggdrop-basic.conf
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,8 @@ set ssl-capath "/etc/ssl/"
## Eggdrop, things change.

## This path specifies the path were Eggdrop should look for its modules.
## If you run the bot from the compilation directory, you will want to set
## this to "". If you use 'make install' (like all good kiddies do ;), this
## is a fine default. Otherwise, use your head :)
## If you use 'make install' (like all good kiddies do ;), this is a fine
## default. Otherwise, use your head :)
set mod-path "modules/"

#### CHANNELS MODULE ####
Expand Down
5 changes: 2 additions & 3 deletions eggdrop.conf
Original file line number Diff line number Diff line change
Expand Up @@ -605,9 +605,8 @@ die "Please make sure you edit your config file completely."
# Eggdrop, things change.

# This path specifies the path were Eggdrop should look for its modules.
# If you run the bot from the compilation directory, you will want to set
# this to "". If you use 'make install' (like all good kiddies do ;), this
# is a fine default. Otherwise, use your head :)
# If you use 'make install' (like all good kiddies do ;), this is a fine
# default. Otherwise, use your head :)
set mod-path "modules/"


Expand Down
13 changes: 9 additions & 4 deletions src/modules.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

#include <errno.h>
#include <signal.h>
#include "main.h"
#include "modules.h"
Expand Down Expand Up @@ -698,6 +699,7 @@ 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 @@ -706,7 +708,7 @@ const char *module_load(char *name)
#endif

#ifndef STATIC
char workbuf[1024];
char workbuf[PATH_MAX];
# ifdef MOD_USE_SHL
shl_t hand;
# endif
Expand All @@ -732,11 +734,14 @@ const char *module_load(char *name)

#ifndef STATIC
if (moddir[0] != '/') {
if (getcwd(workbuf, 1024) == NULL)
if (getcwd(workbuf, sizeof workbuf) == NULL) {
debug1("modules: getcwd(): %s\n", strerror(errno));
return MOD_BADCWD;
sprintf(&(workbuf[strlen(workbuf)]), "/%s%s." EGG_MOD_EXT, moddir, name);
}
len = strlen(workbuf);
snprintf(workbuf + len, (sizeof workbuf) - len, "/%s%s." EGG_MOD_EXT, moddir, name);
} else {
sprintf(workbuf, "%s%s." EGG_MOD_EXT, moddir, name);
snprintf(workbuf, sizeof workbuf, "%s%s." EGG_MOD_EXT, moddir, name);
}

# ifdef MOD_USE_SHL
Expand Down