* First, set other fd limits based on values from user
*/
+typedef enum {
+ IRCD_PATH_PREFIX,
+ IRCD_PATH_MODULES,
+ IRCD_PATH_AUTOLOAD_MODULES,
+ IRCD_PATH_ETC,
+ IRCD_PATH_LOG,
+ IRCD_PATH_USERHELP,
+ IRCD_PATH_OPERHELP,
+ IRCD_PATH_IRCD_EXEC,
+ IRCD_PATH_IRCD_CONF,
+ IRCD_PATH_IRCD_MOTD,
+ IRCD_PATH_IRCD_LOG,
+ IRCD_PATH_IRCD_PID,
+ IRCD_PATH_IRCD_OMOTD,
+ IRCD_PATH_BANDB,
+ IRCD_PATH_BIN,
+ IRCD_PATH_LIBEXEC,
+ IRCD_PATH_COUNT
+} ircd_path_t;
+
+extern const char *ircd_paths[IRCD_PATH_COUNT];
#define MAXCONNECTIONS 65535 /* default max connections if getrlimit doesn't work */
/* class {} default values */
#endif
if(authd_path == NULL)
{
- snprintf(fullpath, sizeof(fullpath), "%s/authd%s", PKGLIBEXECDIR, suffix);
+ snprintf(fullpath, sizeof(fullpath), "%s%cauthd%s", ircd_paths[IRCD_PATH_LIBEXEC], RB_PATH_SEPARATOR, suffix);
if(access(fullpath, X_OK) == -1)
{
- snprintf(fullpath, sizeof(fullpath), "%s/libexec/charybdis/authd%s",
- ConfigFileEntry.dpath, suffix);
+ snprintf(fullpath, sizeof(fullpath), "%s%cbin%cauthd%s",
+ ConfigFileEntry.dpath, RB_PATH_SEPARATOR, RB_PATH_SEPARATOR, suffix);
if(access(fullpath, X_OK) == -1)
{
ilog(L_MAIN,
- "Unable to execute authd in %s or %s/libexec/charybdis",
- PKGLIBEXECDIR, ConfigFileEntry.dpath);
+ "Unable to execute authd in %s or %s/bin",
+ ircd_paths[IRCD_PATH_LIBEXEC], ConfigFileEntry.dpath);
sendto_realops_snomask(SNO_GENERAL, L_ALL,
- "Unable to execute authd in %s or %s/libexec/charybdis",
- PKGLIBEXECDIR, ConfigFileEntry.dpath);
+ "Unable to execute authd in %s or %s/bin",
+ ircd_paths[IRCD_PATH_LIBEXEC], ConfigFileEntry.dpath);
return 1;
}
const char *suffix = "";
#endif
- rb_setenv("BANDB_DBPATH", PKGLOCALSTATEDIR "/ban.db", 1);
+ rb_setenv("BANDB_DBPATH", ircd_paths[IRCD_PATH_BANDB], 1);
if(bandb_path == NULL)
{
- snprintf(fullpath, sizeof(fullpath), "%s/bandb%s", PKGLIBEXECDIR, suffix);
+ snprintf(fullpath, sizeof(fullpath), "%s%cbandb%s", ircd_paths[IRCD_PATH_LIBEXEC], RB_PATH_SEPARATOR, suffix);
if(access(fullpath, X_OK) == -1)
{
- snprintf(fullpath, sizeof(fullpath), "%s/bin/bandb%s",
- ConfigFileEntry.dpath, suffix);
+ snprintf(fullpath, sizeof(fullpath), "%s%cbin%cbandb%s",
+ ConfigFileEntry.dpath, RB_PATH_SEPARATOR, RB_PATH_SEPARATOR, suffix);
if(access(fullpath, X_OK) == -1)
{
ilog(L_MAIN,
"Unable to execute bandb%s in %s or %s/bin",
- suffix, PKGLIBEXECDIR, ConfigFileEntry.dpath);
+ suffix, ircd_paths[IRCD_PATH_LIBEXEC], ConfigFileEntry.dpath);
return 0;
}
}
user_motd_changed[0] = '\0';
- user_motd = cache_file(MPATH, "ircd.motd", 0);
- oper_motd = cache_file(OPATH, "opers.motd", 0);
+ user_motd = cache_file(ircd_paths[IRCD_PATH_IRCD_MOTD], "ircd.motd", 0);
+ oper_motd = cache_file(ircd_paths[IRCD_PATH_IRCD_OMOTD], "opers.motd", 0);
memset(&links_cache_list, 0, sizeof(links_cache_list));
help_dict_oper = rb_dictionary_create("oper help", strcasecmp);
free_cachefile(cacheptr);
}
- helpfile_dir = opendir(HPATH);
+ helpfile_dir = opendir(ircd_paths[IRCD_PATH_OPERHELP]);
if(helpfile_dir == NULL)
return;
{
if(ldirent->d_name[0] == '.')
continue;
- snprintf(filename, sizeof(filename), "%s/%s", HPATH, ldirent->d_name);
+ snprintf(filename, sizeof(filename), "%s%c%s", ircd_paths[IRCD_PATH_OPERHELP], RB_PATH_SEPARATOR, ldirent->d_name);
cacheptr = cache_file(filename, ldirent->d_name, HELP_OPER);
rb_dictionary_add(help_dict_oper, cacheptr->name, cacheptr);
}
closedir(helpfile_dir);
- helpfile_dir = opendir(UHPATH);
+ helpfile_dir = opendir(ircd_path[IRCD_PATH_USERHELP]);
if(helpfile_dir == NULL)
return;
{
if(ldirent->d_name[0] == '.')
continue;
- snprintf(filename, sizeof(filename), "%s/%s", UHPATH, ldirent->d_name);
+ snprintf(filename, sizeof(filename), "%s%c%s", ircd_paths[IRCD_PATH_USERHELP], RB_PATH_SEPARATOR, ldirent->d_name);
#if defined(S_ISLNK) && defined(HAVE_LSTAT)
if(lstat(filename, &sb) < 0)
struct stat sb;
struct tm *local_tm;
- if(stat(MPATH, &sb) == 0)
+ if(stat(ircd_paths[IRCD_PATH_IRCD_MOTD], &sb) == 0)
{
local_tm = localtime(&sb.st_mtime);
}
}
free_cachefile(user_motd);
- user_motd = cache_file(MPATH, "ircd.motd", 0);
+ user_motd = cache_file(ircd_paths[IRCD_PATH_IRCD_MOTD], "ircd.motd", 0);
}
rb_dlink_list local_oper_list; /* our opers, duplicated in lclient_list */
rb_dlink_list oper_list; /* network opers */
-const char *logFileName = LPATH;
-const char *pidFileName = PPATH;
-
char **myargv;
bool dorehash = false;
bool dorehashbans = false;
int split_servers;
int eob_count;
+const char *ircd_paths[IRCD_PATH_COUNT] = {
+ [IRCD_PATH_PREFIX] = DPATH,
+ [IRCD_PATH_MODULES] = MODPATH,
+ [IRCD_PATH_AUTOLOAD_MODULES] = AUTOMODPATH,
+ [IRCD_PATH_ETC] = ETCPATH,
+ [IRCD_PATH_LOG] = LOGPATH,
+ [IRCD_PATH_USERHELP] = UHPATH,
+ [IRCD_PATH_OPERHELP] = HPATH,
+ [IRCD_PATH_IRCD_EXEC] = SPATH,
+ [IRCD_PATH_IRCD_CONF] = CPATH,
+ [IRCD_PATH_IRCD_MOTD] = MPATH,
+ [IRCD_PATH_IRCD_LOG] = LPATH,
+ [IRCD_PATH_IRCD_PID] = PPATH,
+ [IRCD_PATH_IRCD_OMOTD] = OPATH,
+ [IRCD_PATH_BANDB] = DBPATH,
+ [IRCD_PATH_BIN] = BINPATH,
+ [IRCD_PATH_LIBEXEC] = PKGLIBEXECDIR,
+};
+
+const char *logFileName = LPATH;
+const char *pidFileName = PPATH;
+
void
ircd_shutdown(const char *reason)
{
init_sys();
- ConfigFileEntry.dpath = DPATH;
- ConfigFileEntry.configfile = CPATH; /* Server configuration file */
+ ConfigFileEntry.dpath = ircd_paths[IRCD_PATH_PREFIX];
+ ConfigFileEntry.configfile = ircd_paths[IRCD_PATH_IRCD_CONF]; /* Server configuration file */
ConfigFileEntry.connect_timeout = 30; /* Default to 30 */
umask(077); /* better safe than sorry --SRB */
if (tmp_fbfile_in == NULL)
{
- /* if its not found in PREFIX, look in ETCPATH */
+ /* if its not found in PREFIX, look in IRCD_PATH_ETC */
char fnamebuf[BUFSIZE];
- snprintf(fnamebuf, sizeof(fnamebuf), "%s/%s", ETCPATH, c);
+ snprintf(fnamebuf, sizeof(fnamebuf), "%s%c%s", IRCD_PATH_ETC, RB_PATH_SEPARATOR, c);
tmp_fbfile_in = fopen(fnamebuf, "r");
/* wasnt found there either.. error. */
mod_add_cmd(&modrestart_msgtab);
/* Add the default paths we look in to the module system --nenolod */
- mod_add_path(MODPATH);
- mod_add_path(AUTOMODPATH);
+ mod_add_path(ircd_paths[IRCD_PATH_MODULES]);
+ mod_add_path(ircd_paths[IRCD_PATH_AUTOLOAD_MODULES]);
}
/* mod_find_path()
max_mods = MODS_INCREMENT;
- system_module_dir = opendir(AUTOMODPATH);
+ system_module_dir = opendir(ircd_paths[IRCD_PATH_AUTOLOAD_MODULES]);
if(system_module_dir == NULL)
{
- ilog(L_MAIN, "Could not load modules from %s: %s", AUTOMODPATH, strerror(errno));
+ ilog(L_MAIN, "Could not load modules from %s: %s", ircd_paths[IRCD_PATH_AUTOLOAD_MODULES], strerror(errno));
return;
}
len = strlen(ldirent->d_name);
if(len > module_ext_len && !strcasecmp(ldirent->d_name + (len - module_ext_len), LT_MODULE_EXT))
{
- (void) snprintf(module_fq_name, sizeof(module_fq_name), "%s/%s", AUTOMODPATH, ldirent->d_name);
+ (void) snprintf(module_fq_name, sizeof(module_fq_name), "%s%c%s", ircd_paths[IRCD_PATH_AUTOLOAD_MODULES], RB_PATH_SEPARATOR, ldirent->d_name);
(void) load_a_module(module_fq_name, warn, MAPI_ORIGIN_CORE, 0);
}
for (i = 0; core_module_table[i]; i++)
{
- snprintf(module_name, sizeof(module_name), "%s/%s%s", MODPATH,
+ snprintf(module_name, sizeof(module_name), "%s%c%s%s", ircd_paths[IRCD_PATH_MODULES], RB_PATH_SEPARATOR,
core_module_table[i], LT_MODULE_EXT);
if(load_a_module(module_name, warn, MAPI_ORIGIN_CORE, 1) == -1)
close(i);
unlink(pidFileName);
- execv(SPATH, (void *)myargv);
+ execv(ircd_paths[IRCD_PATH_IRCD_EXEC], (void *)myargv);
/* use this if execv of SPATH fails */
- snprintf(path, sizeof(path), "%s/bin/ircd", ConfigFileEntry.dpath);
+ snprintf(path, sizeof(path), "%s%cbin%circd", ConfigFileEntry.dpath, RB_PATH_SEPARATOR, RB_PATH_SEPARATOR);
execv(path, (void *)myargv);
exit(-1);
if(ssld_path == NULL)
{
- snprintf(fullpath, sizeof(fullpath), "%s/ssld%s", PKGLIBEXECDIR, suffix);
+ snprintf(fullpath, sizeof(fullpath), "%s%cssld%s", ircd_paths[IRCD_PATH_LIBEXEC], RB_PATH_SEPARATOR, suffix);
if(access(fullpath, X_OK) == -1)
{
- snprintf(fullpath, sizeof(fullpath), "%s/bin/ssld%s",
- ConfigFileEntry.dpath, suffix);
+ snprintf(fullpath, sizeof(fullpath), "%s%cbin%cssld%s",
+ ConfigFileEntry.dpath, RB_PATH_SEPARATOR, RB_PATH_SEPARATOR, suffix);
if(access(fullpath, X_OK) == -1)
{
ilog(L_MAIN,
"Unable to execute ssld%s in %s or %s/bin",
- suffix, PKGLIBEXECDIR, ConfigFileEntry.dpath);
+ suffix, ircd_paths[IRCD_PATH_LIBEXEC], ConfigFileEntry.dpath);
return 0;
}
}
remote_rehash_oper_p = source_p;
free_cachefile(oper_motd);
- oper_motd = cache_file(OPATH, "opers.motd", 0);
+ oper_motd = cache_file(ircd_paths[IRCD_PATH_IRCD_OMOTD], "opers.motd", 0);
}
static void