diff --git a/Makefile.in b/Makefile.in index 4f36c9afd..0db1827c1 100644 --- a/Makefile.in +++ b/Makefile.in @@ -89,12 +89,6 @@ XCFLAGS=@PTHREAD_CFLAGS@ @TRE_CFLAGS@ @PCRE2_CFLAGS@ @CARES_CFLAGS@ @CFLAGS@ # you are not defining CMDLINE_CONFIG IRCDMODE = 711 -# [CHANGEME] -# IRCDDIR must be the same as DPATH in include/config.h -# -IRCDDIR=@IRCDDIR@ - - URL=@URL@ # [CHANGEME] @@ -129,7 +123,7 @@ all: build MAKEARGS = 'CFLAGS=${CFLAGS}' 'CC=${CC}' 'IRCDLIBS=${IRCDLIBS}' \ 'LDFLAGS=${LDFLAGS}' 'IRCDMODE=${IRCDMODE}' \ 'RES=${RES}' 'BINDIR=${BINDIR}' 'INSTALL=${INSTALL}' \ - 'INCLUDEDIR=${INCLUDEDIR}' 'IRCDDIR=${IRCDDIR}' \ + 'INCLUDEDIR=${INCLUDEDIR}' \ 'RM=${RM}' 'CP=${CP}' 'TOUCH=${TOUCH}' \ 'SHELL=${SHELL}' 'STRTOUL=${STRTOUL}' \ 'CRYPTOLIB=${CRYPTOLIB}' \ diff --git a/include/h.h b/include/h.h index 4735a47fa..3ea2c5985 100644 --- a/include/h.h +++ b/include/h.h @@ -563,6 +563,7 @@ extern int count_oper_sessions(char *); extern char *unreal_mktemp(const char *dir, const char *suffix); extern char *unreal_getpathname(char *filepath, char *path); extern char *unreal_getfilename(char *path); +extern char *unreal_getmodfilename(char *path); extern char *unreal_mkcache(const char *url); extern int has_cached_version(const char *url); extern int unreal_copyfile(const char *src, const char *dest); diff --git a/include/setup.h.in b/include/setup.h.in index 655fc8d04..d6d1c2605 100644 --- a/include/setup.h.in +++ b/include/setup.h.in @@ -20,9 +20,6 @@ /* Define to 1 if using `alloca.c'. */ #undef C_ALLOCA -/* Define the location of permanent data files */ -#undef DATADIR - /* The default permissions for configuration files. Set to 0 to prevent unrealircd from calling chmod() on the files. */ #undef DEFAULT_PERMISSIONS diff --git a/src/Makefile b/src/Makefile index ae48699c0..0aeb02565 100644 --- a/src/Makefile +++ b/src/Makefile @@ -36,7 +36,7 @@ SRC=$(OBJS:%.o=%.c) MAKEARGS = 'CFLAGS=${CFLAGS}' 'CC=${CC}' 'IRCDLIBS=${IRCDLIBS}' \ 'LDFLAGS=${LDFLAGS}' 'IRCDMODE=${IRCDMODE}' \ 'BINDIR=${BINDIR}' 'INSTALL=${INSTALL}' \ - 'INCLUDEDIR=${INCLUDEDIR}' 'IRCDDIR=${IRCDDIR}' \ + 'INCLUDEDIR=${INCLUDEDIR}' \ 'MANDIR=${MANDIR}' 'RM=${RM}' 'CP=${CP}' 'TOUCH=${TOUCH}' \ 'RES=${RES}' 'SHELL=${SHELL}' 'STRTOUL=${STRTOUL}' \ 'CRYPTOLIB=${CRYPTOLIB}' \ @@ -130,19 +130,6 @@ s_svs.o: s_svs.c $(INCLUDES) events.o: events.c $(INCLUDES) $(CC) $(CFLAGS) -c events.c -#install: all -# -if [ ! -d ${IRCDDIR} -a ! -f ${IRCDDIR} ] ; then \ -# mkdir ${IRCDDIR}; \ -# fi -# ../bsdinstall -m ${IRCDMODE} ircd ${BINDIR} -# ../bsdinstall -m 700 chkconf ${BINDIR} -# $(CP) ../doc/example.conf ${IRCDDIR} -# $(TOUCH) ${IRCDDIR}/ircd.motd -# $(RM) -f ${IRCDDIR}/ircd.m4 -# $(TOUCH) ${IRCDDIR}/ircd.m4 -# chmod +x buildm4 -# ./buildm4 ${IRCDDIR} - clean: $(RM) -f *.o *.so *~ core ircd version.c; \ cd modules; make clean diff --git a/src/ircd.c b/src/ircd.c index 17ccd3529..83f474278 100644 --- a/src/ircd.c +++ b/src/ircd.c @@ -1352,7 +1352,7 @@ int InitwIRCD(int argc, char *argv[]) do_version_check(); #if !defined(CHROOTDIR) && !defined(_WIN32) - if (chdir(CONFDIR)) { + if (chdir(PERMDATADIR)) { # ifndef _WIN32 perror("chdir"); fprintf(stderr, "ERROR: Unable to change to directory '%s'\n", CONFDIR); diff --git a/src/modules.c b/src/modules.c index 258387c8a..9b0810b97 100644 --- a/src/modules.c +++ b/src/modules.c @@ -348,7 +348,7 @@ _ */ if (!strstr(path, MODULE_SUFFIX)) strlcat(path, MODULE_SUFFIX, sizeof(path)); - tmppath = unreal_mktemp(TMPDIR, unreal_getfilename(path)); + tmppath = unreal_mktemp(TMPDIR, unreal_getmodfilename(path)); if (!tmppath) return "Unable to create temporary file!"; diff --git a/src/support.c b/src/support.c index bccc38d64..7d7c1c781 100644 --- a/src/support.c +++ b/src/support.c @@ -1630,6 +1630,53 @@ char *unreal_getfilename(char *path) return end; } +/* Returns the special module tmp name for a given path + * The original string is not modified + */ +char *unreal_getmodfilename(char *path) +{ + static char ret[512]; + char buf[512]; + char *p; + char *name = NULL; + char *directory = NULL; + + if (BadPtr(path)) + return path; + + strlcpy(buf, path, sizeof(buf)); + + /* Backtrack... */ + for (p = buf + strlen(buf); p >= buf; p--) + { + if ((*p == '/') || (*p == '\\')) + { + name = p+1; + *p = '\0'; + directory = buf; /* fallback */ + for (; p >= buf; p--) + { + if ((*p == '/') || (*p == '\\')) + { + directory = p + 1; + break; + } + } + break; + } + } + + if (!name) + name = buf; + + if (!directory || !strcmp(directory, "modules")) + snprintf(ret, sizeof(ret), "%s", name); + else + snprintf(ret, sizeof(ret), "%s.%s", directory, name); + + return ret; +} + /* Returns a consistent filename for the cache/ directory. * Returned value will be like: cache/ */ diff --git a/unrealircd.in b/unrealircd.in index bce9130fa..7f85546b9 100644 --- a/unrealircd.in +++ b/unrealircd.in @@ -88,7 +88,7 @@ elif [ "$1" = "gencloak" ] ; then elif [ "$1" = "upgrade-conf" ] ; then @BINDIR@/unrealircd -U elif [ "$1" = "backtrace" ] ; then - cd @IRCDDIR@ + cd @PERMDATADIR@ modpath="@MODULESDIR@" @@ -133,13 +133,13 @@ elif [ "$1" = "backtrace" ] ; then # (ugly) scripting to recreate the tmp/*.so links to the modules *.so files... echo 'info sharedlibrary'|gdb @BINDIR@/unrealircd $corefile 2>/dev/null|\ grep No|grep tmp/|awk '{ print $2 }'|\ - awk -F '.' "{ system(\"ln -s ../$modpath/\" \$2 \".so \" \$0) }" + awk -F '.' "{ system(\"[ -f $modpath/\" \$2 \"/\" \$3 \".so ] && ln -s $modpath/\" \$2 \"/\" \$3 \".so \" \$0 \" || ln -s $modpath/\" \$2 \".so \" \$0) }" echo "" echo "=================== START HERE ======================" echo "BACKTRACE:" -cat >gdb.commands << __EOF__ +cat >@TMPDIR@/gdb.commands << __EOF__ bt echo \n frame @@ -150,8 +150,8 @@ bt 3 full quit __EOF__ - gdb -batch -x gdb.commands @BINDIR@/unrealircd $corefile - rm -f gdb.commands + gdb -batch -x @TMPDIR@/gdb.commands @BINDIR@/unrealircd $corefile + rm -f @TMPDIR@/gdb.commands echo "GCC: `gcc -v 2>&1|tail -n 1`" echo "UNAME: `uname -a`" echo "UNREAL: `$0 version`"