ircd: start staging for relocatable paths
This commit is contained in:
parent
ac2f2189f9
commit
4d8cfacd95
10 changed files with 80 additions and 40 deletions
|
@ -36,6 +36,27 @@
|
|||
* 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 */
|
||||
|
|
14
ircd/authd.c
14
ircd/authd.c
|
@ -55,20 +55,20 @@ start_authd(void)
|
|||
#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;
|
||||
}
|
||||
|
||||
|
|
|
@ -80,21 +80,21 @@ start_bandb(void)
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
|
16
ircd/cache.c
16
ircd/cache.c
|
@ -64,8 +64,8 @@ init_cache(void)
|
|||
|
||||
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);
|
||||
|
@ -253,7 +253,7 @@ load_help(void)
|
|||
free_cachefile(cacheptr);
|
||||
}
|
||||
|
||||
helpfile_dir = opendir(HPATH);
|
||||
helpfile_dir = opendir(ircd_paths[IRCD_PATH_OPERHELP]);
|
||||
|
||||
if(helpfile_dir == NULL)
|
||||
return;
|
||||
|
@ -262,13 +262,13 @@ load_help(void)
|
|||
{
|
||||
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;
|
||||
|
@ -277,7 +277,7 @@ load_help(void)
|
|||
{
|
||||
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)
|
||||
|
@ -341,7 +341,7 @@ cache_user_motd(void)
|
|||
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);
|
||||
|
||||
|
@ -355,7 +355,7 @@ cache_user_motd(void)
|
|||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
|
29
ircd/ircd.c
29
ircd/ircd.c
|
@ -94,9 +94,6 @@ rb_dlink_list global_serv_list; /* global servers on the network */
|
|||
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;
|
||||
|
@ -118,6 +115,28 @@ int split_users;
|
|||
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)
|
||||
{
|
||||
|
@ -562,8 +581,8 @@ charybdis_main(int argc, char *argv[])
|
|||
|
||||
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 */
|
||||
|
|
|
@ -193,10 +193,10 @@ void cinclude(void)
|
|||
|
||||
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. */
|
||||
|
|
|
@ -129,8 +129,8 @@ modules_init(void)
|
|||
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()
|
||||
|
@ -243,11 +243,11 @@ load_all_modules(int warn)
|
|||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -258,7 +258,7 @@ load_all_modules(int warn)
|
|||
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);
|
||||
}
|
||||
|
||||
|
@ -281,7 +281,7 @@ load_core_modules(int warn)
|
|||
|
||||
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)
|
||||
|
|
|
@ -72,10 +72,10 @@ server_reboot(void)
|
|||
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);
|
||||
|
|
|
@ -278,17 +278,17 @@ start_ssldaemon(int count, const char *ssl_cert, const char *ssl_private_key, co
|
|||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -117,7 +117,7 @@ rehash_omotd(struct Client *source_p)
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue