<p>Corey Farrell has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/8627">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">core: Create main/options.c.<br><br>This creates a separate source to 'own' symbols related to options.h and<br>paths.h. This significantly reduces the number of exports created by<br>main/asterisk.o. This change is required to eventually be able to<br>link unmodified Asterisk sources to utilities and/or stand-alone tests.<br><br>ASTERISK~26245<br><br>Change-Id: I5cf184f4757f9363b80c9e678bdc35c477122380<br>---<br>M include/asterisk/_private.h<br>M include/asterisk/paths.h<br>M main/asterisk.c<br>A main/options.c<br>4 files changed, 486 insertions(+), 415 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/27/8627/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/include/asterisk/_private.h b/include/asterisk/_private.h<br>index 431f961..d19c589 100644<br>--- a/include/asterisk/_private.h<br>+++ b/include/asterisk/_private.h<br>@@ -15,6 +15,11 @@<br> #ifndef _ASTERISK__PRIVATE_H<br> #define _ASTERISK__PRIVATE_H<br> <br>+/* Load settings from asterisk.conf, provided by options.c */<br>+void load_asterisk_conf(void);<br>+void set_asterisk_conf_path(const char *path);<br>+void set_socket_path(const char *path);<br>+<br> int load_modules(unsigned int); /*!< Provided by loader.c */<br> int modules_shutdown(void); /*!< Provided by loader.c */<br> int load_pbx(void); /*!< Provided by pbx.c */<br>diff --git a/include/asterisk/paths.h b/include/asterisk/paths.h<br>index 3e3b8ea..de28c75 100644<br>--- a/include/asterisk/paths.h<br>+++ b/include/asterisk/paths.h<br>@@ -37,5 +37,9 @@<br> extern const char *ast_config_AST_RUN_USER;<br> extern const char *ast_config_AST_SYSTEM_NAME;<br> extern const char *ast_config_AST_SBIN_DIR;<br>+extern const char *ast_config_AST_CTL_PERMISSIONS;<br>+extern const char *ast_config_AST_CTL_OWNER;<br>+extern const char *ast_config_AST_CTL_GROUP;<br>+extern const char *ast_config_AST_CTL;<br> <br> #endif /* _ASTERISK_PATHS_H */<br>diff --git a/main/asterisk.c b/main/asterisk.c<br>index 36b1b54..fa1b852 100644<br>--- a/main/asterisk.c<br>+++ b/main/asterisk.c<br>@@ -294,10 +294,6 @@<br> #define AST_MAX_CONNECTS 128<br> #define NUM_MSGS 64<br> <br>-/*! Default minimum DTMF digit length - 80ms */<br>-#define AST_MIN_DTMF_DURATION 80<br>-<br>-<br> /*! \brief Welcome message when starting a CLI interface */<br> #define WELCOME_MESSAGE \<br> ast_verbose("Asterisk %s, Copyright (C) 1999 - 2016, Digium, Inc. and others.\n" \<br>@@ -307,40 +303,6 @@<br> "License version 2 and other licenses; you are welcome to redistribute it under\n" \<br> "certain conditions. Type 'core show license' for details.\n" \<br> "=========================================================================\n", ast_get_version()) \<br>-<br>-/*! \defgroup main_options Main Configuration Options<br>- * \brief Main configuration options from asterisk.conf or OS command line on starting Asterisk.<br>- * \arg \ref Config_ast "asterisk.conf"<br>- * \note Some of them can be changed in the CLI<br>- */<br>-/*! @{ */<br>-<br>-struct ast_flags ast_options = { AST_DEFAULT_OPTIONS };<br>-<br>-/*! Maximum active system verbosity level. */<br>-int ast_verb_sys_level;<br>-<br>-int option_verbose; /*!< Verbosity level */<br>-int option_debug; /*!< Debug level */<br>-int ast_pjproject_max_log_level = -1;/* Default to -1 to know if we have read the level from pjproject yet. */<br>-int ast_option_pjproject_log_level;<br>-int ast_option_pjproject_cache_pools;<br>-double ast_option_maxload; /*!< Max load avg on system */<br>-int ast_option_maxcalls; /*!< Max number of active calls */<br>-int ast_option_maxfiles; /*!< Max number of open file handles (files, sockets) */<br>-unsigned int option_dtmfminduration; /*!< Minimum duration of DTMF. */<br>-#if defined(HAVE_SYSINFO)<br>-long option_minmemfree; /*!< Minimum amount of free system memory - stop accepting calls if free memory falls below this watermark */<br>-#endif<br>-int ast_option_rtpusedynamic;<br>-unsigned int ast_option_rtpptdynamic;<br>-<br>-/*! @} */<br>-<br>-struct ast_eid ast_eid_default;<br>-<br>-/* XXX tmpdir is a subdir of the spool directory, and no way to remap it */<br>-char record_cache_dir[AST_CACHE_DIR_LEN] = DEFAULT_TMP_DIR;<br> <br> static int ast_socket = -1; /*!< UNIX Socket for allowing remote control */<br> static int ast_socket_is_sd = 0; /*!< Is socket activation responsible for ast_socket? */<br>@@ -375,8 +337,6 @@<br> <br> struct console consoles[AST_MAX_CONNECTS];<br> <br>-char ast_defaultlanguage[MAX_LANGUAGE] = DEFAULT_LANGUAGE;<br>-<br> static int ast_el_add_history(const char *);<br> static int ast_el_read_history(const char *);<br> static int ast_el_write_history(const char *);<br>@@ -385,62 +345,6 @@<br> static void ast_el_write_default_histfile(void);<br> <br> static void asterisk_daemon(int isroot, const char *runuser, const char *rungroup);<br>-<br>-#define DEFAULT_MONITOR_DIR DEFAULT_SPOOL_DIR "/monitor"<br>-#define DEFAULT_RECORDING_DIR DEFAULT_SPOOL_DIR "/recording"<br>-<br>-struct _cfg_paths {<br>- char config_dir[PATH_MAX];<br>- char module_dir[PATH_MAX];<br>- char spool_dir[PATH_MAX];<br>- char monitor_dir[PATH_MAX];<br>- char recording_dir[PATH_MAX];<br>- char var_dir[PATH_MAX];<br>- char data_dir[PATH_MAX];<br>- char log_dir[PATH_MAX];<br>- char agi_dir[PATH_MAX];<br>- char run_dir[PATH_MAX];<br>- char key_dir[PATH_MAX];<br>-<br>- char config_file[PATH_MAX];<br>- char db_path[PATH_MAX];<br>- char sbin_dir[PATH_MAX];<br>- char pid_path[PATH_MAX];<br>- char socket_path[PATH_MAX];<br>- char run_user[PATH_MAX];<br>- char run_group[PATH_MAX];<br>- char system_name[128];<br>-};<br>-<br>-static struct _cfg_paths cfg_paths;<br>-<br>-const char *ast_config_AST_CONFIG_DIR = cfg_paths.config_dir;<br>-const char *ast_config_AST_CONFIG_FILE = cfg_paths.config_file;<br>-const char *ast_config_AST_MODULE_DIR = cfg_paths.module_dir;<br>-const char *ast_config_AST_SPOOL_DIR = cfg_paths.spool_dir;<br>-const char *ast_config_AST_MONITOR_DIR = cfg_paths.monitor_dir;<br>-const char *ast_config_AST_RECORDING_DIR = cfg_paths.recording_dir;<br>-const char *ast_config_AST_VAR_DIR = cfg_paths.var_dir;<br>-const char *ast_config_AST_DATA_DIR = cfg_paths.data_dir;<br>-const char *ast_config_AST_LOG_DIR = cfg_paths.log_dir;<br>-const char *ast_config_AST_AGI_DIR = cfg_paths.agi_dir;<br>-const char *ast_config_AST_KEY_DIR = cfg_paths.key_dir;<br>-const char *ast_config_AST_RUN_DIR = cfg_paths.run_dir;<br>-const char *ast_config_AST_SBIN_DIR = cfg_paths.sbin_dir;<br>-<br>-const char *ast_config_AST_DB = cfg_paths.db_path;<br>-const char *ast_config_AST_PID = cfg_paths.pid_path;<br>-const char *ast_config_AST_SOCKET = cfg_paths.socket_path;<br>-const char *ast_config_AST_RUN_USER = cfg_paths.run_user;<br>-const char *ast_config_AST_RUN_GROUP = cfg_paths.run_group;<br>-const char *ast_config_AST_SYSTEM_NAME = cfg_paths.system_name;<br>-<br>-static char ast_config_AST_CTL_PERMISSIONS[PATH_MAX];<br>-static char ast_config_AST_CTL_OWNER[PATH_MAX] = "\0";<br>-static char ast_config_AST_CTL_GROUP[PATH_MAX] = "\0";<br>-static char ast_config_AST_CTL[PATH_MAX] = "asterisk.ctl";<br>-<br>-extern unsigned int ast_FD_SETSIZE;<br> <br> static char *_argv[256];<br> <br>@@ -1802,29 +1706,6 @@<br> .sa_handler = _child_handler,<br> .sa_flags = SA_RESTART,<br> };<br>-<br>-/*! \brief Set maximum open files */<br>-static void set_ulimit(int value)<br>-{<br>- struct rlimit l = {0, 0};<br>-<br>- if (value <= 0) {<br>- ast_log(LOG_WARNING, "Unable to change max files open to invalid value %i\n",value);<br>- return;<br>- }<br>-<br>- l.rlim_cur = value;<br>- l.rlim_max = value;<br>-<br>- if (setrlimit(RLIMIT_NOFILE, &l)) {<br>- ast_log(LOG_WARNING, "Unable to disable core size resource limit: %s\n",strerror(errno));<br>- return;<br>- }<br>-<br>- ast_log(LOG_NOTICE, "Setting max files open to %d\n",value);<br>-<br>- return;<br>-}<br> <br> /*! \brief Set an X-term or screen title */<br> static void set_title(char *text)<br>@@ -3441,296 +3322,6 @@<br> return 0;<br> }<br> <br>-static void ast_readconfig(void)<br>-{<br>- struct ast_config *cfg;<br>- struct ast_variable *v;<br>- char hostname[MAXHOSTNAMELEN] = "";<br>- struct ast_flags config_flags = { CONFIG_FLAG_NOREALTIME };<br>- struct {<br>- unsigned int dbdir:1;<br>- unsigned int keydir:1;<br>- } found = { 0, 0 };<br>- /* Default to false for security */<br>- int live_dangerously = 0;<br>- int option_debug_new = 0;<br>- int option_verbose_new = 0;<br>-<br>- /* Set default value */<br>- option_dtmfminduration = AST_MIN_DTMF_DURATION;<br>- ast_option_rtpusedynamic = 1;<br>- ast_option_rtpptdynamic = 35;<br>-<br>- /* init with buildtime config */<br>- ast_copy_string(cfg_paths.config_dir, DEFAULT_CONFIG_DIR, sizeof(cfg_paths.config_dir));<br>- ast_copy_string(cfg_paths.spool_dir, DEFAULT_SPOOL_DIR, sizeof(cfg_paths.spool_dir));<br>- ast_copy_string(cfg_paths.module_dir, DEFAULT_MODULE_DIR, sizeof(cfg_paths.module_dir));<br>- ast_copy_string(cfg_paths.monitor_dir, DEFAULT_MONITOR_DIR, sizeof(cfg_paths.monitor_dir));<br>- ast_copy_string(cfg_paths.recording_dir, DEFAULT_RECORDING_DIR, sizeof(cfg_paths.recording_dir));<br>- ast_copy_string(cfg_paths.var_dir, DEFAULT_VAR_DIR, sizeof(cfg_paths.var_dir));<br>- ast_copy_string(cfg_paths.data_dir, DEFAULT_DATA_DIR, sizeof(cfg_paths.data_dir));<br>- ast_copy_string(cfg_paths.log_dir, DEFAULT_LOG_DIR, sizeof(cfg_paths.log_dir));<br>- ast_copy_string(cfg_paths.agi_dir, DEFAULT_AGI_DIR, sizeof(cfg_paths.agi_dir));<br>- ast_copy_string(cfg_paths.db_path, DEFAULT_DB, sizeof(cfg_paths.db_path));<br>- ast_copy_string(cfg_paths.sbin_dir, DEFAULT_SBIN_DIR, sizeof(cfg_paths.sbin_dir));<br>- ast_copy_string(cfg_paths.key_dir, DEFAULT_KEY_DIR, sizeof(cfg_paths.key_dir));<br>- ast_copy_string(cfg_paths.pid_path, DEFAULT_PID, sizeof(cfg_paths.pid_path));<br>- ast_copy_string(cfg_paths.socket_path, DEFAULT_SOCKET, sizeof(cfg_paths.socket_path));<br>- ast_copy_string(cfg_paths.run_dir, DEFAULT_RUN_DIR, sizeof(cfg_paths.run_dir));<br>-<br>-#ifdef REF_DEBUG<br>- /* The REF_DEBUG compiler flag is now only used to enable refdebug by default.<br>- * Support for debugging reference counts is always compiled in. */<br>- ast_set2_flag(&ast_options, 1, AST_OPT_FLAG_REF_DEBUG);<br>-#endif<br>-<br>- ast_set_default_eid(&ast_eid_default);<br>-<br>- cfg = ast_config_load2(ast_config_AST_CONFIG_FILE, "" /* core, can't reload */, config_flags);<br>-<br>- /* If AST_OPT_FLAG_EXEC_INCLUDES was previously enabled with -X turn it off now.<br>- * Using #exec from other configs requires that it be enabled from asterisk.conf. */<br>- ast_clear_flag(&ast_options, AST_OPT_FLAG_EXEC_INCLUDES);<br>-<br>- /* no asterisk.conf? no problem, use buildtime config! */<br>- if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) {<br>- fprintf(stderr, "Unable to open specified master config file '%s', using built-in defaults\n", ast_config_AST_CONFIG_FILE);<br>- return;<br>- }<br>-<br>- for (v = ast_variable_browse(cfg, "files"); v; v = v->next) {<br>- if (!strcasecmp(v->name, "astctlpermissions"))<br>- ast_copy_string(ast_config_AST_CTL_PERMISSIONS, v->value, sizeof(ast_config_AST_CTL_PERMISSIONS));<br>- else if (!strcasecmp(v->name, "astctlowner"))<br>- ast_copy_string(ast_config_AST_CTL_OWNER, v->value, sizeof(ast_config_AST_CTL_OWNER));<br>- else if (!strcasecmp(v->name, "astctlgroup"))<br>- ast_copy_string(ast_config_AST_CTL_GROUP, v->value, sizeof(ast_config_AST_CTL_GROUP));<br>- else if (!strcasecmp(v->name, "astctl"))<br>- ast_copy_string(ast_config_AST_CTL, v->value, sizeof(ast_config_AST_CTL));<br>- }<br>-<br>- for (v = ast_variable_browse(cfg, "directories"); v; v = v->next) {<br>- if (!strcasecmp(v->name, "astetcdir")) {<br>- ast_copy_string(cfg_paths.config_dir, v->value, sizeof(cfg_paths.config_dir));<br>- } else if (!strcasecmp(v->name, "astspooldir")) {<br>- ast_copy_string(cfg_paths.spool_dir, v->value, sizeof(cfg_paths.spool_dir));<br>- snprintf(cfg_paths.monitor_dir, sizeof(cfg_paths.monitor_dir), "%s/monitor", v->value);<br>- snprintf(cfg_paths.recording_dir, sizeof(cfg_paths.recording_dir), "%s/recording", v->value);<br>- } else if (!strcasecmp(v->name, "astvarlibdir")) {<br>- ast_copy_string(cfg_paths.var_dir, v->value, sizeof(cfg_paths.var_dir));<br>- if (!found.dbdir)<br>- snprintf(cfg_paths.db_path, sizeof(cfg_paths.db_path), "%s/astdb", v->value);<br>- } else if (!strcasecmp(v->name, "astdbdir")) {<br>- snprintf(cfg_paths.db_path, sizeof(cfg_paths.db_path), "%s/astdb", v->value);<br>- found.dbdir = 1;<br>- } else if (!strcasecmp(v->name, "astdatadir")) {<br>- ast_copy_string(cfg_paths.data_dir, v->value, sizeof(cfg_paths.data_dir));<br>- if (!found.keydir)<br>- snprintf(cfg_paths.key_dir, sizeof(cfg_paths.key_dir), "%s/keys", v->value);<br>- } else if (!strcasecmp(v->name, "astkeydir")) {<br>- snprintf(cfg_paths.key_dir, sizeof(cfg_paths.key_dir), "%s/keys", v->value);<br>- found.keydir = 1;<br>- } else if (!strcasecmp(v->name, "astlogdir")) {<br>- ast_copy_string(cfg_paths.log_dir, v->value, sizeof(cfg_paths.log_dir));<br>- } else if (!strcasecmp(v->name, "astagidir")) {<br>- ast_copy_string(cfg_paths.agi_dir, v->value, sizeof(cfg_paths.agi_dir));<br>- } else if (!strcasecmp(v->name, "astrundir")) {<br>- snprintf(cfg_paths.pid_path, sizeof(cfg_paths.pid_path), "%s/%s", v->value, "asterisk.pid");<br>- ast_copy_string(cfg_paths.run_dir, v->value, sizeof(cfg_paths.run_dir));<br>- } else if (!strcasecmp(v->name, "astmoddir")) {<br>- ast_copy_string(cfg_paths.module_dir, v->value, sizeof(cfg_paths.module_dir));<br>- } else if (!strcasecmp(v->name, "astsbindir")) {<br>- ast_copy_string(cfg_paths.sbin_dir, v->value, sizeof(cfg_paths.sbin_dir));<br>- }<br>- }<br>-<br>- /* Combine astrundir and astctl settings. */<br>- snprintf(cfg_paths.socket_path, sizeof(cfg_paths.socket_path), "%s/%s",<br>- ast_config_AST_RUN_DIR, ast_config_AST_CTL);<br>-<br>- for (v = ast_variable_browse(cfg, "options"); v; v = v->next) {<br>- /* verbose level (-v at startup) */<br>- if (!strcasecmp(v->name, "verbose")) {<br>- option_verbose_new = atoi(v->value);<br>- /* whether or not to force timestamping in CLI verbose output. (-T at startup) */<br>- } else if (!strcasecmp(v->name, "timestamp")) {<br>- ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_TIMESTAMP);<br>- /* whether or not to support #exec in config files */<br>- } else if (!strcasecmp(v->name, "execincludes")) {<br>- ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_EXEC_INCLUDES);<br>- /* debug level (-d at startup) */<br>- } else if (!strcasecmp(v->name, "debug")) {<br>- option_debug_new = 0;<br>- if (sscanf(v->value, "%30d", &option_debug_new) != 1) {<br>- option_debug_new = ast_true(v->value) ? 1 : 0;<br>- }<br>- } else if (!strcasecmp(v->name, "refdebug")) {<br>- ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_REF_DEBUG);<br>-#if HAVE_WORKING_FORK<br>- /* Disable forking (-f at startup) */<br>- } else if (!strcasecmp(v->name, "nofork")) {<br>- ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_NO_FORK);<br>- /* Always fork, even if verbose or debug are enabled (-F at startup) */<br>- } else if (!strcasecmp(v->name, "alwaysfork")) {<br>- ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_ALWAYS_FORK);<br>-#endif<br>- /* Run quietly (-q at startup ) */<br>- } else if (!strcasecmp(v->name, "quiet")) {<br>- ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_QUIET);<br>- /* Run as console (-c at startup, implies nofork) */<br>- } else if (!strcasecmp(v->name, "console")) {<br>- ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_NO_FORK | AST_OPT_FLAG_CONSOLE);<br>- /* Run with high priority if the O/S permits (-p at startup) */<br>- } else if (!strcasecmp(v->name, "highpriority")) {<br>- ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_HIGH_PRIORITY);<br>- /* Initialize RSA auth keys (IAX2) (-i at startup) */<br>- } else if (!strcasecmp(v->name, "initcrypto")) {<br>- ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_INIT_KEYS);<br>- /* Disable ANSI colors for console (-c at startup) */<br>- } else if (!strcasecmp(v->name, "nocolor")) {<br>- ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_NO_COLOR);<br>- /* Disable some usage warnings for picky people :p */<br>- } else if (!strcasecmp(v->name, "dontwarn")) {<br>- ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_DONT_WARN);<br>- /* Dump core in case of crash (-g) */<br>- } else if (!strcasecmp(v->name, "dumpcore")) {<br>- ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_DUMP_CORE);<br>- /* Cache recorded sound files to another directory during recording */<br>- } else if (!strcasecmp(v->name, "cache_record_files")) {<br>- ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_CACHE_RECORD_FILES);<br>-#if !defined(LOW_MEMORY)<br>- /* Cache media frames for performance */<br>- } else if (!strcasecmp(v->name, "cache_media_frames")) {<br>- ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_CACHE_MEDIA_FRAMES);<br>-#endif<br>- /* Specify cache directory */<br>- } else if (!strcasecmp(v->name, "record_cache_dir")) {<br>- ast_copy_string(record_cache_dir, v->value, AST_CACHE_DIR_LEN);<br>- /* Build transcode paths via SLINEAR, instead of directly */<br>- } else if (!strcasecmp(v->name, "transcode_via_sln")) {<br>- ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_TRANSCODE_VIA_SLIN);<br>- /* Transmit SLINEAR silence while a channel is being recorded or DTMF is being generated on a channel */<br>- } else if (!strcasecmp(v->name, "transmit_silence_during_record") || !strcasecmp(v->name, "transmit_silence")) {<br>- ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_TRANSMIT_SILENCE);<br>- /* Enable internal timing */<br>- } else if (!strcasecmp(v->name, "internal_timing")) {<br>- if (!ast_opt_remote) {<br>- fprintf(stderr,<br>- "NOTICE: The internal_timing option is no longer needed.\n"<br>- " It will always be enabled if you have a timing module loaded.\n");<br>- }<br>- } else if (!strcasecmp(v->name, "mindtmfduration")) {<br>- if (sscanf(v->value, "%30u", &option_dtmfminduration) != 1) {<br>- option_dtmfminduration = AST_MIN_DTMF_DURATION;<br>- }<br>- } else if (!strcasecmp(v->name, "rtp_use_dynamic")) {<br>- ast_option_rtpusedynamic = ast_true(v->value);<br>- /* http://www.iana.org/assignments/rtp-parameters<br>- * RTP dynamic payload types start at 96 normally; extend down to 0 */<br>- } else if (!strcasecmp(v->name, "rtp_pt_dynamic")) {<br>- ast_parse_arg(v->value, PARSE_UINT32|PARSE_IN_RANGE,<br>- &ast_option_rtpptdynamic, 0, AST_RTP_PT_FIRST_DYNAMIC);<br>- } else if (!strcasecmp(v->name, "maxcalls")) {<br>- if ((sscanf(v->value, "%30d", &ast_option_maxcalls) != 1) || (ast_option_maxcalls < 0)) {<br>- ast_option_maxcalls = 0;<br>- }<br>- } else if (!strcasecmp(v->name, "maxload")) {<br>- double test[1];<br>-<br>- if (getloadavg(test, 1) == -1) {<br>- ast_log(LOG_ERROR, "Cannot obtain load average on this system. 'maxload' option disabled.\n");<br>- ast_option_maxload = 0.0;<br>- } else if ((sscanf(v->value, "%30lf", &ast_option_maxload) != 1) || (ast_option_maxload < 0.0)) {<br>- ast_option_maxload = 0.0;<br>- }<br>- /* Set the maximum amount of open files */<br>- } else if (!strcasecmp(v->name, "maxfiles")) {<br>- ast_option_maxfiles = atoi(v->value);<br>- if (!ast_opt_remote) {<br>- set_ulimit(ast_option_maxfiles);<br>- }<br>- /* What user to run as */<br>- } else if (!strcasecmp(v->name, "runuser")) {<br>- ast_copy_string(cfg_paths.run_user, v->value, sizeof(cfg_paths.run_user));<br>- /* What group to run as */<br>- } else if (!strcasecmp(v->name, "rungroup")) {<br>- ast_copy_string(cfg_paths.run_group, v->value, sizeof(cfg_paths.run_group));<br>- } else if (!strcasecmp(v->name, "systemname")) {<br>- ast_copy_string(cfg_paths.system_name, v->value, sizeof(cfg_paths.system_name));<br>- } else if (!strcasecmp(v->name, "autosystemname")) {<br>- if (ast_true(v->value)) {<br>- if (!gethostname(hostname, sizeof(hostname) - 1))<br>- ast_copy_string(cfg_paths.system_name, hostname, sizeof(cfg_paths.system_name));<br>- else {<br>- if (ast_strlen_zero(ast_config_AST_SYSTEM_NAME)){<br>- ast_copy_string(cfg_paths.system_name, "localhost", sizeof(cfg_paths.system_name));<br>- }<br>- ast_log(LOG_ERROR, "Cannot obtain hostname for this system. Using '%s' instead.\n", ast_config_AST_SYSTEM_NAME);<br>- }<br>- }<br>- } else if (!strcasecmp(v->name, "languageprefix")) {<br>- ast_language_is_prefix = ast_true(v->value);<br>- } else if (!strcasecmp(v->name, "defaultlanguage")) {<br>- ast_copy_string(ast_defaultlanguage, v->value, MAX_LANGUAGE);<br>- } else if (!strcasecmp(v->name, "lockmode")) {<br>- if (!strcasecmp(v->value, "lockfile")) {<br>- ast_set_lock_type(AST_LOCK_TYPE_LOCKFILE);<br>- } else if (!strcasecmp(v->value, "flock")) {<br>- ast_set_lock_type(AST_LOCK_TYPE_FLOCK);<br>- } else {<br>- ast_log(LOG_WARNING, "'%s' is not a valid setting for the lockmode option, "<br>- "defaulting to 'lockfile'\n", v->value);<br>- ast_set_lock_type(AST_LOCK_TYPE_LOCKFILE);<br>- }<br>-#if defined(HAVE_SYSINFO)<br>- } else if (!strcasecmp(v->name, "minmemfree")) {<br>- /* specify the minimum amount of free memory to retain. Asterisk should stop accepting new calls<br>- * if the amount of free memory falls below this watermark */<br>- if ((sscanf(v->value, "%30ld", &option_minmemfree) != 1) || (option_minmemfree < 0)) {<br>- option_minmemfree = 0;<br>- }<br>-#endif<br>- } else if (!strcasecmp(v->name, "entityid")) {<br>- struct ast_eid tmp_eid;<br>- if (!ast_str_to_eid(&tmp_eid, v->value)) {<br>- ast_eid_default = tmp_eid;<br>- } else {<br>- ast_log(LOG_WARNING, "Invalid Entity ID '%s' provided\n", v->value);<br>- }<br>- } else if (!strcasecmp(v->name, "lightbackground")) {<br>- ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_LIGHT_BACKGROUND);<br>- } else if (!strcasecmp(v->name, "forceblackbackground")) {<br>- ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_FORCE_BLACK_BACKGROUND);<br>- } else if (!strcasecmp(v->name, "hideconnect")) {<br>- ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_HIDE_CONSOLE_CONNECT);<br>- } else if (!strcasecmp(v->name, "lockconfdir")) {<br>- ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_LOCK_CONFIG_DIR);<br>- } else if (!strcasecmp(v->name, "stdexten")) {<br>- /* Choose how to invoke the extensions.conf stdexten */<br>- if (!strcasecmp(v->value, "gosub")) {<br>- ast_clear_flag(&ast_options, AST_OPT_FLAG_STDEXTEN_MACRO);<br>- } else if (!strcasecmp(v->value, "macro")) {<br>- ast_set_flag(&ast_options, AST_OPT_FLAG_STDEXTEN_MACRO);<br>- } else {<br>- ast_log(LOG_WARNING,<br>- "'%s' is not a valid setting for the stdexten option, defaulting to 'gosub'\n",<br>- v->value);<br>- ast_clear_flag(&ast_options, AST_OPT_FLAG_STDEXTEN_MACRO);<br>- }<br>- } else if (!strcasecmp(v->name, "live_dangerously")) {<br>- live_dangerously = ast_true(v->value);<br>- }<br>- }<br>- if (!ast_opt_remote) {<br>- pbx_live_dangerously(live_dangerously);<br>- }<br>-<br>- option_debug += option_debug_new;<br>- option_verbose += option_verbose_new;<br>-<br>- ast_config_destroy(cfg);<br>-}<br>-<br> static void read_pjproject_startup_options(void)<br> {<br> struct ast_config *cfg;<br>@@ -3915,9 +3506,6 @@<br> }<br> ast_mainpid = getpid();<br> <br>- /* Set config file to default before checking arguments for override. */<br>- ast_copy_string(cfg_paths.config_file, DEFAULT_CONFIG_FILE, sizeof(cfg_paths.config_file));<br>-<br> /* Process command-line options that effect asterisk.conf load. */<br> while ((c = getopt(argc, argv, getopt_settings)) != -1) {<br> switch (c) {<br>@@ -3925,7 +3513,7 @@<br> ast_set_flag(&ast_options, AST_OPT_FLAG_EXEC_INCLUDES);<br> break;<br> case 'C':<br>- ast_copy_string(cfg_paths.config_file, optarg, sizeof(cfg_paths.config_file));<br>+ set_asterisk_conf_path(optarg);<br> break;<br> case 'd':<br> option_debug++;<br>@@ -3954,7 +3542,7 @@<br> /* Initialize env so it is available if #exec is used in asterisk.conf. */<br> env_init();<br> <br>- ast_readconfig();<br>+ load_asterisk_conf();<br> <br> /* Update env to include any systemname that was set. */<br> env_init();<br>@@ -4047,7 +3635,7 @@<br> break;<br> case 's':<br> if (ast_opt_remote) {<br>- ast_copy_string((char *) cfg_paths.socket_path, optarg, sizeof(cfg_paths.socket_path));<br>+ set_socket_path(optarg);<br> }<br> break;<br> case 'T':<br>diff --git a/main/options.c b/main/options.c<br>new file mode 100644<br>index 0000000..51743fa<br>--- /dev/null<br>+++ b/main/options.c<br>@@ -0,0 +1,474 @@<br>+/*<br>+ * Asterisk -- An open source telephony toolkit.<br>+ *<br>+ * Copyright (C) 2018, CFWare, LLC<br>+ *<br>+ * Corey Farrell <git@cfware.com><br>+ *<br>+ * See http://www.asterisk.org for more information about<br>+ * the Asterisk project. Please do not directly contact<br>+ * any of the maintainers of this project for assistance;<br>+ * the project provides a web site, mailing lists and IRC<br>+ * channels for your use.<br>+ *<br>+ * This program is free software, distributed under the terms of<br>+ * the GNU General Public License Version 2. See the LICENSE file<br>+ * at the top of the source tree.<br>+ */<br>+<br>+/*! \file<br>+ *<br>+ * \brief Symbols related to asterisk.conf options and paths.<br>+ *<br>+ * \author Corey Farrell <git@cfware.com><br>+ */<br>+<br>+/*** MODULEINFO<br>+ <support_level>core</support_level><br>+ ***/<br>+<br>+#include "asterisk.h"<br>+#include "asterisk/_private.h"<br>+#include "asterisk/app.h"<br>+#include "asterisk/config.h"<br>+#include "asterisk/logger.h"<br>+#include "asterisk/options.h"<br>+#include "asterisk/paths.h"<br>+#include "asterisk/pbx.h"<br>+#include "asterisk/rtp_engine.h"<br>+#include "asterisk/strings.h"<br>+#include "asterisk/utils.h"<br>+<br>+#include "../defaults.h"<br>+<br>+#include <sys/time.h><br>+#include <sys/resource.h><br>+<br>+/*! \defgroup main_options Main Configuration Options<br>+ * \brief Main configuration options from asterisk.conf or OS command line on starting Asterisk.<br>+ * \arg \ref Config_ast "asterisk.conf"<br>+ * \note Some of them can be changed in the CLI<br>+ */<br>+/*! @{ */<br>+<br>+struct ast_flags ast_options = { AST_DEFAULT_OPTIONS };<br>+<br>+/*! Maximum active system verbosity level. */<br>+int ast_verb_sys_level;<br>+<br>+/*! Verbosity level */<br>+int option_verbose;<br>+/*! Debug level */<br>+int option_debug;<br>+/*! Default to -1 to know if we have read the level from pjproject yet. */<br>+int ast_pjproject_max_log_level = -1;<br>+int ast_option_pjproject_log_level;<br>+int ast_option_pjproject_cache_pools;<br>+/*! Max load avg on system */<br>+double ast_option_maxload;<br>+/*! Max number of active calls */<br>+int ast_option_maxcalls;<br>+/*! Max number of open file handles (files, sockets) */<br>+int ast_option_maxfiles;<br>+/*! Minimum duration of DTMF. */<br>+unsigned int option_dtmfminduration = AST_MIN_DTMF_DURATION;<br>+#if defined(HAVE_SYSINFO)<br>+/*! Minimum amount of free system memory - stop accepting calls if free memory falls below this watermark */<br>+long option_minmemfree;<br>+#endif<br>+int ast_option_rtpusedynamic = 1;<br>+unsigned int ast_option_rtpptdynamic = 35;<br>+<br>+/*! @} */<br>+<br>+struct ast_eid ast_eid_default;<br>+<br>+/* XXX tmpdir is a subdir of the spool directory, and no way to remap it */<br>+char record_cache_dir[AST_CACHE_DIR_LEN] = DEFAULT_TMP_DIR;<br>+<br>+char ast_defaultlanguage[MAX_LANGUAGE] = DEFAULT_LANGUAGE;<br>+<br>+/*! Default minimum DTMF digit length - 80ms */<br>+#define AST_MIN_DTMF_DURATION 80<br>+<br>+#define DEFAULT_MONITOR_DIR DEFAULT_SPOOL_DIR "/monitor"<br>+#define DEFAULT_RECORDING_DIR DEFAULT_SPOOL_DIR "/recording"<br>+<br>+struct _cfg_paths {<br>+ char config_dir[PATH_MAX];<br>+ char module_dir[PATH_MAX];<br>+ char spool_dir[PATH_MAX];<br>+ char monitor_dir[PATH_MAX];<br>+ char recording_dir[PATH_MAX];<br>+ char var_dir[PATH_MAX];<br>+ char data_dir[PATH_MAX];<br>+ char log_dir[PATH_MAX];<br>+ char agi_dir[PATH_MAX];<br>+ char run_dir[PATH_MAX];<br>+ char key_dir[PATH_MAX];<br>+<br>+ char config_file[PATH_MAX];<br>+ char db_path[PATH_MAX];<br>+ char sbin_dir[PATH_MAX];<br>+ char pid_path[PATH_MAX];<br>+ char socket_path[PATH_MAX];<br>+ char run_user[PATH_MAX];<br>+ char run_group[PATH_MAX];<br>+ char system_name[128];<br>+ char ctl_perms[PATH_MAX];<br>+ char ctl_owner[PATH_MAX];<br>+ char ctl_group[PATH_MAX];<br>+ char ctl_file[PATH_MAX];<br>+};<br>+<br>+static struct _cfg_paths cfg_paths = {<br>+ .config_dir = DEFAULT_CONFIG_DIR,<br>+ .module_dir = DEFAULT_MODULE_DIR,<br>+ .spool_dir = DEFAULT_SPOOL_DIR,<br>+ .monitor_dir = DEFAULT_MONITOR_DIR,<br>+ .recording_dir = DEFAULT_RECORDING_DIR,<br>+ .var_dir = DEFAULT_VAR_DIR,<br>+ .data_dir = DEFAULT_DATA_DIR,<br>+ .log_dir = DEFAULT_LOG_DIR,<br>+ .agi_dir = DEFAULT_AGI_DIR,<br>+ .run_dir = DEFAULT_RUN_DIR,<br>+ .key_dir = DEFAULT_KEY_DIR,<br>+<br>+ .config_file = DEFAULT_CONFIG_FILE,<br>+ .db_path = DEFAULT_DB,<br>+ .sbin_dir = DEFAULT_SBIN_DIR,<br>+ .pid_path = DEFAULT_PID,<br>+ .socket_path = DEFAULT_SOCKET,<br>+ .ctl_file = "asterisk.ctl",<br>+};<br>+<br>+const char *ast_config_AST_CONFIG_DIR = cfg_paths.config_dir;<br>+const char *ast_config_AST_CONFIG_FILE = cfg_paths.config_file;<br>+const char *ast_config_AST_MODULE_DIR = cfg_paths.module_dir;<br>+const char *ast_config_AST_SPOOL_DIR = cfg_paths.spool_dir;<br>+const char *ast_config_AST_MONITOR_DIR = cfg_paths.monitor_dir;<br>+const char *ast_config_AST_RECORDING_DIR = cfg_paths.recording_dir;<br>+const char *ast_config_AST_VAR_DIR = cfg_paths.var_dir;<br>+const char *ast_config_AST_DATA_DIR = cfg_paths.data_dir;<br>+const char *ast_config_AST_LOG_DIR = cfg_paths.log_dir;<br>+const char *ast_config_AST_AGI_DIR = cfg_paths.agi_dir;<br>+const char *ast_config_AST_KEY_DIR = cfg_paths.key_dir;<br>+const char *ast_config_AST_RUN_DIR = cfg_paths.run_dir;<br>+const char *ast_config_AST_SBIN_DIR = cfg_paths.sbin_dir;<br>+<br>+const char *ast_config_AST_DB = cfg_paths.db_path;<br>+const char *ast_config_AST_PID = cfg_paths.pid_path;<br>+const char *ast_config_AST_SOCKET = cfg_paths.socket_path;<br>+const char *ast_config_AST_RUN_USER = cfg_paths.run_user;<br>+const char *ast_config_AST_RUN_GROUP = cfg_paths.run_group;<br>+const char *ast_config_AST_SYSTEM_NAME = cfg_paths.system_name;<br>+<br>+const char *ast_config_AST_CTL_PERMISSIONS = cfg_paths.ctl_perms;<br>+const char *ast_config_AST_CTL_OWNER = cfg_paths.ctl_owner;<br>+const char *ast_config_AST_CTL_GROUP = cfg_paths.ctl_group;<br>+const char *ast_config_AST_CTL = cfg_paths.ctl_file;<br>+<br>+/*! \brief Set maximum open files */<br>+static void set_ulimit(int value)<br>+{<br>+ struct rlimit l = {0, 0};<br>+<br>+ if (value <= 0) {<br>+ ast_log(LOG_WARNING, "Unable to change max files open to invalid value %i\n",value);<br>+ return;<br>+ }<br>+<br>+ l.rlim_cur = value;<br>+ l.rlim_max = value;<br>+<br>+ if (setrlimit(RLIMIT_NOFILE, &l)) {<br>+ ast_log(LOG_WARNING, "Unable to disable core size resource limit: %s\n",strerror(errno));<br>+ return;<br>+ }<br>+<br>+ ast_log(LOG_NOTICE, "Setting max files open to %d\n",value);<br>+<br>+ return;<br>+}<br>+<br>+void set_asterisk_conf_path(const char *path)<br>+{<br>+ ast_copy_string(cfg_paths.config_file, path, sizeof(cfg_paths.config_file));<br>+}<br>+<br>+void set_socket_path(const char *path)<br>+{<br>+ ast_copy_string(cfg_paths.socket_path, path, sizeof(cfg_paths.socket_path));<br>+}<br>+<br>+void load_asterisk_conf(void)<br>+{<br>+ struct ast_config *cfg;<br>+ struct ast_variable *v;<br>+ char hostname[MAXHOSTNAMELEN] = "";<br>+ struct ast_flags config_flags = { CONFIG_FLAG_NOREALTIME };<br>+ struct {<br>+ unsigned int dbdir:1;<br>+ unsigned int keydir:1;<br>+ } found = { 0, 0 };<br>+ /* Default to false for security */<br>+ int live_dangerously = 0;<br>+ int option_debug_new = 0;<br>+ int option_verbose_new = 0;<br>+<br>+ /* init with buildtime config */<br>+#ifdef REF_DEBUG<br>+ /* The REF_DEBUG compiler flag is now only used to enable refdebug by default.<br>+ * Support for debugging reference counts is always compiled in. */<br>+ ast_set2_flag(&ast_options, 1, AST_OPT_FLAG_REF_DEBUG);<br>+#endif<br>+<br>+ ast_set_default_eid(&ast_eid_default);<br>+<br>+ cfg = ast_config_load2(ast_config_AST_CONFIG_FILE, "" /* core, can't reload */, config_flags);<br>+<br>+ /* If AST_OPT_FLAG_EXEC_INCLUDES was previously enabled with -X turn it off now.<br>+ * Using #exec from other configs requires that it be enabled from asterisk.conf. */<br>+ ast_clear_flag(&ast_options, AST_OPT_FLAG_EXEC_INCLUDES);<br>+<br>+ /* no asterisk.conf? no problem, use buildtime config! */<br>+ if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) {<br>+ fprintf(stderr, "Unable to open specified master config file '%s', using built-in defaults\n", ast_config_AST_CONFIG_FILE);<br>+ return;<br>+ }<br>+<br>+ for (v = ast_variable_browse(cfg, "files"); v; v = v->next) {<br>+ if (!strcasecmp(v->name, "astctlpermissions")) {<br>+ ast_copy_string(cfg_paths.ctl_perms, v->value, sizeof(cfg_paths.ctl_perms));<br>+ } else if (!strcasecmp(v->name, "astctlowner")) {<br>+ ast_copy_string(cfg_paths.ctl_owner, v->value, sizeof(cfg_paths.ctl_owner));<br>+ } else if (!strcasecmp(v->name, "astctlgroup")) {<br>+ ast_copy_string(cfg_paths.ctl_group, v->value, sizeof(cfg_paths.ctl_group));<br>+ } else if (!strcasecmp(v->name, "astctl")) {<br>+ ast_copy_string(cfg_paths.ctl_file, v->value, sizeof(cfg_paths.ctl_file));<br>+ }<br>+ }<br>+<br>+ for (v = ast_variable_browse(cfg, "directories"); v; v = v->next) {<br>+ if (!strcasecmp(v->name, "astetcdir")) {<br>+ ast_copy_string(cfg_paths.config_dir, v->value, sizeof(cfg_paths.config_dir));<br>+ } else if (!strcasecmp(v->name, "astspooldir")) {<br>+ ast_copy_string(cfg_paths.spool_dir, v->value, sizeof(cfg_paths.spool_dir));<br>+ snprintf(cfg_paths.monitor_dir, sizeof(cfg_paths.monitor_dir), "%s/monitor", v->value);<br>+ snprintf(cfg_paths.recording_dir, sizeof(cfg_paths.recording_dir), "%s/recording", v->value);<br>+ } else if (!strcasecmp(v->name, "astvarlibdir")) {<br>+ ast_copy_string(cfg_paths.var_dir, v->value, sizeof(cfg_paths.var_dir));<br>+ if (!found.dbdir) {<br>+ snprintf(cfg_paths.db_path, sizeof(cfg_paths.db_path), "%s/astdb", v->value);<br>+ }<br>+ } else if (!strcasecmp(v->name, "astdbdir")) {<br>+ snprintf(cfg_paths.db_path, sizeof(cfg_paths.db_path), "%s/astdb", v->value);<br>+ found.dbdir = 1;<br>+ } else if (!strcasecmp(v->name, "astdatadir")) {<br>+ ast_copy_string(cfg_paths.data_dir, v->value, sizeof(cfg_paths.data_dir));<br>+ if (!found.keydir) {<br>+ snprintf(cfg_paths.key_dir, sizeof(cfg_paths.key_dir), "%s/keys", v->value);<br>+ }<br>+ } else if (!strcasecmp(v->name, "astkeydir")) {<br>+ snprintf(cfg_paths.key_dir, sizeof(cfg_paths.key_dir), "%s/keys", v->value);<br>+ found.keydir = 1;<br>+ } else if (!strcasecmp(v->name, "astlogdir")) {<br>+ ast_copy_string(cfg_paths.log_dir, v->value, sizeof(cfg_paths.log_dir));<br>+ } else if (!strcasecmp(v->name, "astagidir")) {<br>+ ast_copy_string(cfg_paths.agi_dir, v->value, sizeof(cfg_paths.agi_dir));<br>+ } else if (!strcasecmp(v->name, "astrundir")) {<br>+ snprintf(cfg_paths.pid_path, sizeof(cfg_paths.pid_path), "%s/%s", v->value, "asterisk.pid");<br>+ ast_copy_string(cfg_paths.run_dir, v->value, sizeof(cfg_paths.run_dir));<br>+ } else if (!strcasecmp(v->name, "astmoddir")) {<br>+ ast_copy_string(cfg_paths.module_dir, v->value, sizeof(cfg_paths.module_dir));<br>+ } else if (!strcasecmp(v->name, "astsbindir")) {<br>+ ast_copy_string(cfg_paths.sbin_dir, v->value, sizeof(cfg_paths.sbin_dir));<br>+ }<br>+ }<br>+<br>+ /* Combine astrundir and astctl settings. */<br>+ snprintf(cfg_paths.socket_path, sizeof(cfg_paths.socket_path), "%s/%s",<br>+ ast_config_AST_RUN_DIR, ast_config_AST_CTL);<br>+<br>+ for (v = ast_variable_browse(cfg, "options"); v; v = v->next) {<br>+ /* verbose level (-v at startup) */<br>+ if (!strcasecmp(v->name, "verbose")) {<br>+ option_verbose_new = atoi(v->value);<br>+ /* whether or not to force timestamping in CLI verbose output. (-T at startup) */<br>+ } else if (!strcasecmp(v->name, "timestamp")) {<br>+ ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_TIMESTAMP);<br>+ /* whether or not to support #exec in config files */<br>+ } else if (!strcasecmp(v->name, "execincludes")) {<br>+ ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_EXEC_INCLUDES);<br>+ /* debug level (-d at startup) */<br>+ } else if (!strcasecmp(v->name, "debug")) {<br>+ option_debug_new = 0;<br>+ if (sscanf(v->value, "%30d", &option_debug_new) != 1) {<br>+ option_debug_new = ast_true(v->value) ? 1 : 0;<br>+ }<br>+ } else if (!strcasecmp(v->name, "refdebug")) {<br>+ ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_REF_DEBUG);<br>+#if HAVE_WORKING_FORK<br>+ /* Disable forking (-f at startup) */<br>+ } else if (!strcasecmp(v->name, "nofork")) {<br>+ ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_NO_FORK);<br>+ /* Always fork, even if verbose or debug are enabled (-F at startup) */<br>+ } else if (!strcasecmp(v->name, "alwaysfork")) {<br>+ ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_ALWAYS_FORK);<br>+#endif<br>+ /* Run quietly (-q at startup ) */<br>+ } else if (!strcasecmp(v->name, "quiet")) {<br>+ ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_QUIET);<br>+ /* Run as console (-c at startup, implies nofork) */<br>+ } else if (!strcasecmp(v->name, "console")) {<br>+ ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_NO_FORK | AST_OPT_FLAG_CONSOLE);<br>+ /* Run with high priority if the O/S permits (-p at startup) */<br>+ } else if (!strcasecmp(v->name, "highpriority")) {<br>+ ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_HIGH_PRIORITY);<br>+ /* Initialize RSA auth keys (IAX2) (-i at startup) */<br>+ } else if (!strcasecmp(v->name, "initcrypto")) {<br>+ ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_INIT_KEYS);<br>+ /* Disable ANSI colors for console (-c at startup) */<br>+ } else if (!strcasecmp(v->name, "nocolor")) {<br>+ ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_NO_COLOR);<br>+ /* Disable some usage warnings for picky people :p */<br>+ } else if (!strcasecmp(v->name, "dontwarn")) {<br>+ ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_DONT_WARN);<br>+ /* Dump core in case of crash (-g) */<br>+ } else if (!strcasecmp(v->name, "dumpcore")) {<br>+ ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_DUMP_CORE);<br>+ /* Cache recorded sound files to another directory during recording */<br>+ } else if (!strcasecmp(v->name, "cache_record_files")) {<br>+ ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_CACHE_RECORD_FILES);<br>+#if !defined(LOW_MEMORY)<br>+ /* Cache media frames for performance */<br>+ } else if (!strcasecmp(v->name, "cache_media_frames")) {<br>+ ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_CACHE_MEDIA_FRAMES);<br>+#endif<br>+ /* Specify cache directory */<br>+ } else if (!strcasecmp(v->name, "record_cache_dir")) {<br>+ ast_copy_string(record_cache_dir, v->value, AST_CACHE_DIR_LEN);<br>+ /* Build transcode paths via SLINEAR, instead of directly */<br>+ } else if (!strcasecmp(v->name, "transcode_via_sln")) {<br>+ ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_TRANSCODE_VIA_SLIN);<br>+ /* Transmit SLINEAR silence while a channel is being recorded or DTMF is being generated on a channel */<br>+ } else if (!strcasecmp(v->name, "transmit_silence_during_record") || !strcasecmp(v->name, "transmit_silence")) {<br>+ ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_TRANSMIT_SILENCE);<br>+ /* Enable internal timing */<br>+ } else if (!strcasecmp(v->name, "internal_timing")) {<br>+ if (!ast_opt_remote) {<br>+ fprintf(stderr,<br>+ "NOTICE: The internal_timing option is no longer needed.\n"<br>+ " It will always be enabled if you have a timing module loaded.\n");<br>+ }<br>+ } else if (!strcasecmp(v->name, "mindtmfduration")) {<br>+ if (sscanf(v->value, "%30u", &option_dtmfminduration) != 1) {<br>+ option_dtmfminduration = AST_MIN_DTMF_DURATION;<br>+ }<br>+ } else if (!strcasecmp(v->name, "rtp_use_dynamic")) {<br>+ ast_option_rtpusedynamic = ast_true(v->value);<br>+ /* http://www.iana.org/assignments/rtp-parameters<br>+ * RTP dynamic payload types start at 96 normally; extend down to 0 */<br>+ } else if (!strcasecmp(v->name, "rtp_pt_dynamic")) {<br>+ ast_parse_arg(v->value, PARSE_UINT32|PARSE_IN_RANGE,<br>+ &ast_option_rtpptdynamic, 0, AST_RTP_PT_FIRST_DYNAMIC);<br>+ } else if (!strcasecmp(v->name, "maxcalls")) {<br>+ if ((sscanf(v->value, "%30d", &ast_option_maxcalls) != 1) || (ast_option_maxcalls < 0)) {<br>+ ast_option_maxcalls = 0;<br>+ }<br>+ } else if (!strcasecmp(v->name, "maxload")) {<br>+ double test[1];<br>+<br>+ if (getloadavg(test, 1) == -1) {<br>+ ast_log(LOG_ERROR, "Cannot obtain load average on this system. 'maxload' option disabled.\n");<br>+ ast_option_maxload = 0.0;<br>+ } else if ((sscanf(v->value, "%30lf", &ast_option_maxload) != 1) || (ast_option_maxload < 0.0)) {<br>+ ast_option_maxload = 0.0;<br>+ }<br>+ /* Set the maximum amount of open files */<br>+ } else if (!strcasecmp(v->name, "maxfiles")) {<br>+ ast_option_maxfiles = atoi(v->value);<br>+ if (!ast_opt_remote) {<br>+ set_ulimit(ast_option_maxfiles);<br>+ }<br>+ /* What user to run as */<br>+ } else if (!strcasecmp(v->name, "runuser")) {<br>+ ast_copy_string(cfg_paths.run_user, v->value, sizeof(cfg_paths.run_user));<br>+ /* What group to run as */<br>+ } else if (!strcasecmp(v->name, "rungroup")) {<br>+ ast_copy_string(cfg_paths.run_group, v->value, sizeof(cfg_paths.run_group));<br>+ } else if (!strcasecmp(v->name, "systemname")) {<br>+ ast_copy_string(cfg_paths.system_name, v->value, sizeof(cfg_paths.system_name));<br>+ } else if (!strcasecmp(v->name, "autosystemname")) {<br>+ if (ast_true(v->value)) {<br>+ if (!gethostname(hostname, sizeof(hostname) - 1)) {<br>+ ast_copy_string(cfg_paths.system_name, hostname, sizeof(cfg_paths.system_name));<br>+ } else {<br>+ if (ast_strlen_zero(ast_config_AST_SYSTEM_NAME)){<br>+ ast_copy_string(cfg_paths.system_name, "localhost", sizeof(cfg_paths.system_name));<br>+ }<br>+ ast_log(LOG_ERROR, "Cannot obtain hostname for this system. Using '%s' instead.\n", ast_config_AST_SYSTEM_NAME);<br>+ }<br>+ }<br>+ } else if (!strcasecmp(v->name, "languageprefix")) {<br>+ ast_language_is_prefix = ast_true(v->value);<br>+ } else if (!strcasecmp(v->name, "defaultlanguage")) {<br>+ ast_copy_string(ast_defaultlanguage, v->value, MAX_LANGUAGE);<br>+ } else if (!strcasecmp(v->name, "lockmode")) {<br>+ if (!strcasecmp(v->value, "lockfile")) {<br>+ ast_set_lock_type(AST_LOCK_TYPE_LOCKFILE);<br>+ } else if (!strcasecmp(v->value, "flock")) {<br>+ ast_set_lock_type(AST_LOCK_TYPE_FLOCK);<br>+ } else {<br>+ ast_log(LOG_WARNING, "'%s' is not a valid setting for the lockmode option, "<br>+ "defaulting to 'lockfile'\n", v->value);<br>+ ast_set_lock_type(AST_LOCK_TYPE_LOCKFILE);<br>+ }<br>+#if defined(HAVE_SYSINFO)<br>+ } else if (!strcasecmp(v->name, "minmemfree")) {<br>+ /* specify the minimum amount of free memory to retain. Asterisk should stop accepting new calls<br>+ * if the amount of free memory falls below this watermark */<br>+ if ((sscanf(v->value, "%30ld", &option_minmemfree) != 1) || (option_minmemfree < 0)) {<br>+ option_minmemfree = 0;<br>+ }<br>+#endif<br>+ } else if (!strcasecmp(v->name, "entityid")) {<br>+ struct ast_eid tmp_eid;<br>+ if (!ast_str_to_eid(&tmp_eid, v->value)) {<br>+ ast_eid_default = tmp_eid;<br>+ } else {<br>+ ast_log(LOG_WARNING, "Invalid Entity ID '%s' provided\n", v->value);<br>+ }<br>+ } else if (!strcasecmp(v->name, "lightbackground")) {<br>+ ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_LIGHT_BACKGROUND);<br>+ } else if (!strcasecmp(v->name, "forceblackbackground")) {<br>+ ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_FORCE_BLACK_BACKGROUND);<br>+ } else if (!strcasecmp(v->name, "hideconnect")) {<br>+ ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_HIDE_CONSOLE_CONNECT);<br>+ } else if (!strcasecmp(v->name, "lockconfdir")) {<br>+ ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_LOCK_CONFIG_DIR);<br>+ } else if (!strcasecmp(v->name, "stdexten")) {<br>+ /* Choose how to invoke the extensions.conf stdexten */<br>+ if (!strcasecmp(v->value, "gosub")) {<br>+ ast_clear_flag(&ast_options, AST_OPT_FLAG_STDEXTEN_MACRO);<br>+ } else if (!strcasecmp(v->value, "macro")) {<br>+ ast_set_flag(&ast_options, AST_OPT_FLAG_STDEXTEN_MACRO);<br>+ } else {<br>+ ast_log(LOG_WARNING,<br>+ "'%s' is not a valid setting for the stdexten option, defaulting to 'gosub'\n",<br>+ v->value);<br>+ ast_clear_flag(&ast_options, AST_OPT_FLAG_STDEXTEN_MACRO);<br>+ }<br>+ } else if (!strcasecmp(v->name, "live_dangerously")) {<br>+ live_dangerously = ast_true(v->value);<br>+ }<br>+ }<br>+ if (!ast_opt_remote) {<br>+ pbx_live_dangerously(live_dangerously);<br>+ }<br>+<br>+ option_debug += option_debug_new;<br>+ option_verbose += option_verbose_new;<br>+<br>+ ast_config_destroy(cfg);<br>+}<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/8627">change 8627</a>. To unsubscribe, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/8627"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I5cf184f4757f9363b80c9e678bdc35c477122380 </div>
<div style="display:none"> Gerrit-Change-Number: 8627 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Corey Farrell <git@cfware.com> </div>