[asterisk-commits] twilson: trunk r347345 - in /trunk: ./ build_tools/ configs/ include/asterisk...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Dec 7 14:15:33 CST 2011


Author: twilson
Date: Wed Dec  7 14:15:29 2011
New Revision: 347345

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=347345
Log:
Add ASTSBINDIR to the list of configurable paths

This patch also makes astdb2sqlite3 and astcanary use the configured
directory instead of relying on $PATH.

(closes issue ASTERISK-18959)
Review: https://reviewboard.asterisk.org/r/1613/
........

Merged revisions 347344 from http://svn.asterisk.org/svn/asterisk/branches/10

Modified:
    trunk/   (props changed)
    trunk/Makefile
    trunk/build_tools/make_defaults_h
    trunk/configs/asterisk.conf.sample
    trunk/include/asterisk/paths.h
    trunk/main/asterisk.c
    trunk/main/db.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-10-merged' - no diff available.

Modified: trunk/Makefile
URL: http://svnview.digium.com/svn/asterisk/trunk/Makefile?view=diff&rev=347345&r1=347344&r2=347345
==============================================================================
--- trunk/Makefile (original)
+++ trunk/Makefile Wed Dec  7 14:15:29 2011
@@ -40,6 +40,8 @@
 # DESTDIR is the staging (or final) directory where files are copied
 # during the install process. Define it before 'export', otherwise
 # export will set it to the empty string making ?= fail.
+# Trying to run asterisk from the DESTDIR is completely unsupported
+# behavior.
 # WARNING: do not put spaces or comments after the value.
 DESTDIR?=$(INSTALL_PATH)
 export DESTDIR
@@ -405,7 +407,7 @@
 $(OTHER_SUBDIRS):
 	+ at _ASTCFLAGS="$(OTHER_SUBDIR_CFLAGS) $(_ASTCFLAGS)" ASTCFLAGS="$(ASTCFLAGS)" _ASTLDFLAGS="$(_ASTLDFLAGS)" ASTLDFLAGS="$(ASTLDFLAGS)" $(SUBMAKE) --no-builtin-rules -C $@ SUBDIR=$@ all
 
-defaults.h: makeopts
+defaults.h: makeopts build_tools/make_defaults_h
 	@build_tools/make_defaults_h > $@.tmp
 	@cmp -s $@.tmp $@ || mv $@.tmp $@
 	@rm -f $@.tmp

Modified: trunk/build_tools/make_defaults_h
URL: http://svnview.digium.com/svn/asterisk/trunk/build_tools/make_defaults_h?view=diff&rev=347345&r1=347344&r2=347345
==============================================================================
--- trunk/build_tools/make_defaults_h (original)
+++ trunk/build_tools/make_defaults_h Wed Dec  7 14:15:29 2011
@@ -25,4 +25,5 @@
 #define DEFAULT_SPOOL_DIR  "${INSTALL_PATH}${ASTSPOOLDIR}"
 #define DEFAULT_TMP_DIR    "${INSTALL_PATH}${ASTSPOOLDIR}/tmp"
 
+#define DEFAULT_SBIN_DIR   "${INSTALL_PATH}${ASTSBINDIR}"
 END

Modified: trunk/configs/asterisk.conf.sample
URL: http://svnview.digium.com/svn/asterisk/trunk/configs/asterisk.conf.sample?view=diff&rev=347345&r1=347344&r2=347345
==============================================================================
--- trunk/configs/asterisk.conf.sample (original)
+++ trunk/configs/asterisk.conf.sample Wed Dec  7 14:15:29 2011
@@ -9,6 +9,7 @@
 astspooldir => /var/spool/asterisk
 astrundir => /var/run/asterisk
 astlogdir => /var/log/asterisk
+astsbindir => /usr/sbin
 
 [options]
 ;verbose = 3

Modified: trunk/include/asterisk/paths.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/paths.h?view=diff&rev=347345&r1=347344&r2=347345
==============================================================================
--- trunk/include/asterisk/paths.h (original)
+++ trunk/include/asterisk/paths.h Wed Dec  7 14:15:29 2011
@@ -35,5 +35,6 @@
 extern const char *ast_config_AST_RUN_GROUP;
 extern const char *ast_config_AST_RUN_USER;
 extern const char *ast_config_AST_SYSTEM_NAME;
+extern const char *ast_config_AST_SBIN_DIR;
 
 #endif /* _ASTERISK_PATHS_H */

Modified: trunk/main/asterisk.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/asterisk.c?view=diff&rev=347345&r1=347344&r2=347345
==============================================================================
--- trunk/main/asterisk.c (original)
+++ trunk/main/asterisk.c Wed Dec  7 14:15:29 2011
@@ -242,6 +242,7 @@
 
 	char config_file[PATH_MAX];
 	char db_path[PATH_MAX];
+	char sbin_dir[PATH_MAX];
 	char pid_path[PATH_MAX];
 	char socket_path[PATH_MAX];
 	char run_user[PATH_MAX];
@@ -262,6 +263,7 @@
 const char *ast_config_AST_AGI_DIR	= cfg_paths.agi_dir;
 const char *ast_config_AST_KEY_DIR	= cfg_paths.key_dir;
 const char *ast_config_AST_RUN_DIR	= cfg_paths.run_dir;
+const char *ast_config_AST_SBIN_DIR = cfg_paths.sbin_dir;
 
 const char *ast_config_AST_DB		= cfg_paths.db_path;
 const char *ast_config_AST_PID		= cfg_paths.pid_path;
@@ -2968,6 +2970,7 @@
 	ast_copy_string(cfg_paths.log_dir, DEFAULT_LOG_DIR, sizeof(cfg_paths.log_dir));
 	ast_copy_string(cfg_paths.agi_dir, DEFAULT_AGI_DIR, sizeof(cfg_paths.agi_dir));
 	ast_copy_string(cfg_paths.db_path, DEFAULT_DB, sizeof(cfg_paths.db_path));
+	ast_copy_string(cfg_paths.sbin_dir, DEFAULT_SBIN_DIR, sizeof(cfg_paths.sbin_dir));
 	ast_copy_string(cfg_paths.key_dir, DEFAULT_KEY_DIR, sizeof(cfg_paths.key_dir));
 	ast_copy_string(cfg_paths.pid_path, DEFAULT_PID, sizeof(cfg_paths.pid_path));
 	ast_copy_string(cfg_paths.socket_path, DEFAULT_SOCKET, sizeof(cfg_paths.socket_path));
@@ -3021,6 +3024,8 @@
 			ast_copy_string(cfg_paths.run_dir, v->value, sizeof(cfg_paths.run_dir));
 		} else if (!strcasecmp(v->name, "astmoddir")) {
 			ast_copy_string(cfg_paths.module_dir, v->value, sizeof(cfg_paths.module_dir));
+		} else if (!strcasecmp(v->name, "astsbindir")) {
+			ast_copy_string(cfg_paths.sbin_dir, v->value, sizeof(cfg_paths.sbin_dir));
 		}
 	}
 
@@ -3738,7 +3743,7 @@
 
 		canary_pid = fork();
 		if (canary_pid == 0) {
-			char canary_binary[128], *lastslash, ppid[12];
+			char canary_binary[PATH_MAX], ppid[12];
 
 			/* Reset signal handler */
 			signal(SIGCHLD, SIG_DFL);
@@ -3748,14 +3753,9 @@
 			ast_set_priority(0);
 			snprintf(ppid, sizeof(ppid), "%d", (int) ast_mainpid);
 
-			execlp("astcanary", "astcanary", canary_filename, ppid, (char *)NULL);
-
-			/* If not found, try the same path as used to execute asterisk */
-			ast_copy_string(canary_binary, argv[0], sizeof(canary_binary));
-			if ((lastslash = strrchr(canary_binary, '/'))) {
-				ast_copy_string(lastslash + 1, "astcanary", sizeof(canary_binary) + canary_binary - (lastslash + 1));
-				execl(canary_binary, "astcanary", canary_filename, ppid, (char *)NULL);
-			}
+			/* Use the astcanary binary that we installed */
+			snprintf(canary_binary, sizeof(canary_binary), "%s/astcanary", ast_config_AST_SBIN_DIR);
+			execl(canary_binary, "astcanary", canary_filename, ppid, (char *)NULL);
 
 			/* Should never happen */
 			_exit(1);

Modified: trunk/main/db.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/db.c?view=diff&rev=347345&r1=347344&r2=347345
==============================================================================
--- trunk/main/db.c (original)
+++ trunk/main/db.c Wed Dec  7 14:15:29 2011
@@ -156,7 +156,7 @@
 	char *cmd;
 	int res;
 
-	ast_asprintf(&cmd, "astdb2sqlite3 '%s'\n", ast_config_AST_DB);
+	ast_asprintf(&cmd, "%s/astdb2sqlite3 '%s'\n", ast_config_AST_SBIN_DIR, ast_config_AST_DB);
 	res = ast_safe_system(cmd);
 	ast_free(cmd);
 




More information about the asterisk-commits mailing list