Index: channels/chan_usbradio.c
===================================================================
--- channels/chan_usbradio.c	(revision 167122)
+++ channels/chan_usbradio.c	(working copy)
@@ -73,6 +73,7 @@
 #include <errno.h>
 #include <usb.h>
 #include <alsa/asoundlib.h>
+#include "../defaults.h"
 
 //#define HAVE_XPMRX				1
 #ifdef RADIO_XPMRX
@@ -86,13 +87,13 @@
 #define DEBUG_CAP_TX_OUT	    0			
 #define DEBUG_FILETEST			0			 
 
-#define RX_CAP_RAW_FILE			"/tmp/rx_cap_in.pcm"
-#define RX_CAP_TRACE_FILE		"/tmp/rx_trace.pcm"
-#define RX_CAP_OUT_FILE			"/tmp/rx_cap_out.pcm"
+#define RX_CAP_RAW_FILE			DEFAULT_TMP_DIR "/rx_cap_in.pcm"
+#define RX_CAP_TRACE_FILE		DEFAULT_TMP_DIR "/rx_trace.pcm"
+#define RX_CAP_OUT_FILE			DEFAULT_TMP_DIR "/rx_cap_out.pcm"
 
-#define TX_CAP_RAW_FILE			"/tmp/tx_cap_in.pcm"
-#define TX_CAP_TRACE_FILE		"/tmp/tx_trace.pcm"
-#define TX_CAP_OUT_FILE			"/tmp/tx_cap_out.pcm"
+#define TX_CAP_RAW_FILE			DEFAULT_TMP_DIR "/tx_cap_in.pcm"
+#define TX_CAP_TRACE_FILE		DEFAULT_TMP_DIR "/tx_trace.pcm"
+#define TX_CAP_OUT_FILE			DEFAULT_TMP_DIR "/tx_cap_out.pcm"
 
 #define	MIXER_PARAM_MIC_PLAYBACK_SW "Mic Playback Switch"
 #define MIXER_PARAM_MIC_PLAYBACK_VOL "Mic Playback Volume"
Index: channels/chan_sip.c
===================================================================
--- channels/chan_sip.c	(revision 167122)
+++ channels/chan_sip.c	(working copy)
@@ -216,6 +216,7 @@
 
 #include "asterisk/network.h"
 #include "asterisk/paths.h"	/* need ast_config_AST_SYSTEM_NAME */
+#include "../defaults.h"
 
 #include "asterisk/lock.h"
 #include "asterisk/channel.h"
@@ -242,9 +243,10 @@
 #include "asterisk/astobj.h"
 /* 
    Uncomment the define below,  if you are having refcount related memory leaks.
-   With this uncommented, this module will generate a file, /tmp/refs, which contains
-   a history of the ao2_ref() calls. To be useful, all calls to ao2_* functions should
-   be modified to ao2_t_* calls, and include a tag describing what is happening with 
+   With this uncommented, this module will generate a file, 
+   /var/spool/asterisk/tmp/refs, which contains a history of the ao2_ref() 
+   calls. To be useful, all calls to ao2_* functions should be modified to 
+   ao2_t_* calls, and include a tag describing what is happening with 
    enough detail, to make pairing up a reference count increment with its corresponding decrement.
    The refcounter program in utils/ can be invaluable in highlighting objects that are not
    balanced, along with the complete history for that object.
Index: channels/chan_iax2.c
===================================================================
--- channels/chan_iax2.c	(revision 167122)
+++ channels/chan_iax2.c	(working copy)
@@ -55,6 +55,7 @@
 #include <regex.h>
 
 #include "asterisk/paths.h"	/* need ast_config_AST_DATA_DIR for firmware */
+#include "../defaults.h"
 
 #include "asterisk/lock.h"
 #include "asterisk/frame.h" 
@@ -2064,7 +2065,7 @@
 	else
 		last = s;
 
-	snprintf(s2, strlen(s) + 100, "/var/tmp/%s-%ld", last, (unsigned long)ast_random());
+	snprintf(s2, strlen(s) + 100, DEFAULT_TMP_DIR "/%s-%ld", last, (unsigned long)ast_random());
 
 	if ((res = stat(s, &stbuf) < 0)) {
 		ast_log(LOG_WARNING, "Failed to stat '%s': %s\n", s, strerror(errno));
Index: apps/app_festival.c
===================================================================
--- apps/app_festival.c	(revision 167122)
+++ apps/app_festival.c	(working copy)
@@ -49,6 +49,7 @@
 #include "asterisk/utils.h"
 #include "asterisk/lock.h"
 #include "asterisk/app.h"
+#include "../defaults.h"
 
 #define FESTIVAL_CONFIG "festival.conf"
 #define MAXLEN 180
@@ -333,7 +334,7 @@
 		usecache = ast_true(temp);
 	}
 	if (!(cachedir = ast_variable_retrieve(cfg, "general", "cachedir"))) {
-		cachedir = "/tmp/";
+		cachedir = DEFAULT_TMP_DIR;
 	}
 
 	data = ast_strdupa(vdata);
Index: apps/app_rpt.c
===================================================================
--- apps/app_rpt.c	(revision 167122)
+++ apps/app_rpt.c	(working copy)
@@ -243,7 +243,7 @@
 #define	ENDCHAR '#'
 #define	EXTNODEFILE "/var/lib/asterisk/rpt_extnodes"
 #define	NODENAMES "rpt/nodenames"
-#define	PARROTFILE "/tmp/parrot_%s_%u"
+#define	PARROTFILE DEFAULT_TMP_DIR "/parrot_%s_%u"
 
 #define	PARROTTIME 1000
 
@@ -360,6 +360,7 @@
 #include "asterisk/options.h"
 #include "asterisk/manager.h"
 #include <termios.h>
+#include "../defaults.h"
 
 #ifdef	NEW_ASTERISK
 struct ast_flags config_flags = { CONFIG_FLAG_WITHCOMMENTS };
Index: apps/app_minivm.c
===================================================================
--- apps/app_minivm.c	(revision 167122)
+++ apps/app_minivm.c	(working copy)
@@ -171,6 +171,7 @@
 #include "asterisk/linkedlists.h"
 #include "asterisk/callerid.h"
 #include "asterisk/event.h"
+#include "../defaults.h"
 
 /*** DOCUMENTATION
 <application name="MinivmRecord" language="en_US">
@@ -1034,7 +1035,7 @@
 	char bound[256];
 	char fname[PATH_MAX];
 	char dur[PATH_MAX];
-	char tmp[80] = "/tmp/astmail-XXXXXX";
+	char tmp[80] = DEFAULT_TMP_DIR "/astmail-XXXXXX";
 	char tmp2[PATH_MAX];
 	struct timeval now;
 	struct ast_tm tm;
@@ -1073,7 +1074,7 @@
 		char tmpcmd[PATH_MAX];
 		int tmpfd;
 
-		ast_copy_string(newtmp, "/tmp/XXXXXX", sizeof(newtmp));
+		ast_copy_string(newtmp, DEFAULT_TMP_DIR "/XXXXXX", sizeof(newtmp));
 		ast_debug(3, "newtmp: %s\n", newtmp);
 		tmpfd = mkstemp(newtmp);
 		snprintf(tmpcmd, sizeof(tmpcmd), "sox -v %.4f %s.%s %s.%s", vmu->volgain, filename, format, newtmp, format);
Index: apps/app_voicemail.c
===================================================================
--- apps/app_voicemail.c	(revision 167122)
+++ apps/app_voicemail.c	(working copy)
@@ -112,6 +112,7 @@
 #include "asterisk/smdi.h"
 #include "asterisk/event.h"
 #include "asterisk/taskprocessor.h"
+#include "../defaults.h"
 
 #ifdef ODBC_STORAGE
 #include "asterisk/res_odbc.h"
@@ -1827,7 +1828,7 @@
 	char mailbox[256];
 	char *stringp;
 	FILE *p=NULL;
-	char tmp[80] = "/tmp/astmail-XXXXXX";
+	char tmp[80] = DEFAULT_TMP_DIR "/astmail-XXXXXX";
 	long len;
 	void *buf;
 	int tempcopy = 0;
@@ -4234,7 +4235,7 @@
 static int sendmail(char *srcemail, struct ast_vm_user *vmu, int msgnum, char *context, char *mailbox, char *cidnum, char *cidname, char *attach, char *attach2, char *format, int duration, int attach_user_voicemail, struct ast_channel *chan, const char *category, const char *flag)
 {
 	FILE *p=NULL;
-	char tmp[80] = "/tmp/astmail-XXXXXX";
+	char tmp[80] = DEFAULT_TMP_DIR "/astmail-XXXXXX";
 	char tmp2[256];
 
 	if (vmu && ast_strlen_zero(vmu->email)) {
@@ -4265,7 +4266,7 @@
 	char host[MAXHOSTNAMELEN] = "";
 	char who[256];
 	char dur[PATH_MAX];
-	char tmp[80] = "/tmp/astmail-XXXXXX";
+	char tmp[80] = DEFAULT_TMP_DIR "/astmail-XXXXXX";
 	char tmp2[PATH_MAX];
 	struct ast_tm tm;
 	FILE *p;
Index: main/config.c
===================================================================
--- main/config.c	(revision 167122)
+++ main/config.c	(working copy)
@@ -47,6 +47,7 @@
 #include "asterisk/app.h"
 #include "asterisk/astobj2.h"
 #include "asterisk/strings.h"	/* for the ast_str_*() API */
+#include "../defaults.h"
 
 #define MAX_NESTED_COMMENTS 128
 #define COMMENT_START ";--"
@@ -1072,7 +1073,7 @@
 			struct timeval now = ast_tvnow();
 			if (!ast_test_flag(&flags, CONFIG_FLAG_NOCACHE))
 				config_cache_attribute(configfile, ATTRIBUTE_EXEC, NULL, who_asked);
-			snprintf(exec_file, sizeof(exec_file), "/var/tmp/exec.%d%d.%ld", (int)now.tv_sec, (int)now.tv_usec, (long)pthread_self());
+			snprintf(exec_file, sizeof(exec_file), DEFAULT_TMP_DIR "/exec.%d%d.%ld", (int)now.tv_sec, (int)now.tv_usec, (long)pthread_self());
 			snprintf(cmd, sizeof(cmd), "%s > %s 2>&1", cur, exec_file);
 			ast_safe_system(cmd);
 			cur = exec_file;
Index: main/manager.c
===================================================================
--- main/manager.c	(revision 167122)
+++ main/manager.c	(working copy)
@@ -74,6 +74,7 @@
 #include "asterisk/term.h"
 #include "asterisk/astobj2.h"
 #include "asterisk/features.h"
+#include "../defaults.h"
 
 enum error_type {
 	UNKNOWN_ACTION = 1,
@@ -2178,7 +2179,7 @@
 	const char *cmd = astman_get_header(m, "Command");
 	const char *id = astman_get_header(m, "ActionID");
 	char *buf, *final_buf;
-	char template[] = "/tmp/ast-ami-XXXXXX";	/* template for temporary file */
+	char template[] = DEFAULT_TMP_DIR "/ast-ami-XXXXXX";	/* template for temporary file */
 	int fd = mkstemp(template);
 	off_t l;
 
@@ -3706,7 +3707,7 @@
 	uint32_t ident = 0;
 	int blastaway = 0;
 	struct ast_variable *v;
-	char template[] = "/tmp/ast-http-XXXXXX";	/* template for temporary file */
+	char template[] = DEFAULT_TMP_DIR "/ast-http-XXXXXX";	/* template for temporary file */
 	struct ast_str *out = NULL;
 	struct message m = { 0 };
 	unsigned int x;
Index: main/abstract_jb.c
===================================================================
--- main/abstract_jb.c	(revision 167122)
+++ main/abstract_jb.c	(working copy)
@@ -41,6 +41,7 @@
 #include "asterisk/abstract_jb.h"
 #include "fixedjitterbuf.h"
 #include "jitterbuf.h"
+#include "../defaults.h"
 
 /*! Internal jb flags */
 enum {
@@ -499,7 +500,7 @@
 			*tmp = '#';
 		
 		snprintf(logfile_pathname, sizeof(logfile_pathname),
-			"/tmp/ast_%s_jb_%s--%s.log", jbimpl->name, name1, name2);
+			DEFAULT_TMP_DIR "/ast_%s_jb_%s--%s.log", jbimpl->name, name1, name2);
 		jb->logfile = fopen(logfile_pathname, "w+b");
 		
 		if (!jb->logfile)
Index: main/astobj2.c
===================================================================
--- main/astobj2.c	(revision 167122)
+++ main/astobj2.c	(working copy)
@@ -25,7 +25,8 @@
 #include "asterisk/astobj2.h"
 #include "asterisk/utils.h"
 #include "asterisk/cli.h"
-#define REF_FILE "/tmp/refs"
+#include "../defaults.h"
+#define REF_FILE DEFAULT_TMP_DIR "/refs"
 
 /*!
  * astobj2 objects are always preceded by this data structure,
Index: res/res_odbc.c
===================================================================
--- res/res_odbc.c	(revision 167122)
+++ res/res_odbc.c	(working copy)
@@ -50,6 +50,7 @@
 #include "asterisk/res_odbc.h"
 #include "asterisk/time.h"
 #include "asterisk/astobj2.h"
+#include "../defaults.h"
 
 struct odbc_class
 {
@@ -806,7 +807,7 @@
 	unsigned char msg[200], state[10];
 #ifdef NEEDTRACE
 	SQLINTEGER enable = 1;
-	char *tracefile = "/tmp/odbc.trace";
+	char *tracefile = DEFAULT_TMP_DIR "/odbc.trace";
 #endif
 	ast_mutex_lock(&obj->lock);
 
Index: utils/extconf.c
===================================================================
--- utils/extconf.c	(revision 167122)
+++ utils/extconf.c	(working copy)
@@ -49,6 +49,7 @@
 #include <pthread.h>
 #include <netdb.h>
 #include <sys/param.h>
+#include "../defaults.h"
 
 static void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...) __attribute__((format(printf, 5, 6)));
 void ast_verbose(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
@@ -3655,7 +3656,7 @@
 				/* #exec </path/to/executable>
 				   We create a tmp file, then we #include it, then we delete it. */
 				if (do_exec) { 
-					snprintf(exec_file, sizeof(exec_file), "/var/tmp/exec.%d.%ld", (int)time(NULL), (long)pthread_self());
+					snprintf(exec_file, sizeof(exec_file), DEFAULT_TMP_DIR "/exec.%d.%ld", (int)time(NULL), (long)pthread_self());
 					snprintf(cmd, sizeof(cmd), "%s > %s 2>&1", cur, exec_file);
 					ast_safe_system(cmd);
 					cur = exec_file;
Index: utils/refcounter.c
===================================================================
--- utils/refcounter.c	(revision 167122)
+++ utils/refcounter.c	(working copy)
@@ -17,17 +17,17 @@
  */
 /*! \file
  *
- *  \brief A program to read in the /tmp/refs file generated
- *         by astobj2 code when the REF_DEBUG macro is defined.
+ *  \brief A program to read in the /var/spool/asterisk/tmp/refs file 
+ *         generated by astobj2 code when the REF_DEBUG macro is defined.
  *         It will read in the file line by line, and
  *         sort the data out by object, and check to see
  *         if the refcounts balance to zero, and the object
  *         was destroyed just once. Any problems that are 
  *         found are reported to stdout and the objects
  *         ref count history is printed out. If all is well,
- *         this program reads in the /tmp/refs file and 
+ *         this program reads in the tmp/refs file and 
  *         generates no output. No news is good news.
- *  The contents of the /tmp/refs file looks like this:
+ *  The contents of the tmp/refs file looks like this:
  *
 0x84fd718 -1   astobj2.c:926:cd_cb_debug (deref object via container destroy) [@1]
 0x84fd718 =1   chan_sip.c:19760:build_user (allocate a user struct)
@@ -51,6 +51,7 @@
 #include "asterisk/channel.h"
 #include "asterisk/utils.h"
 #include "asterisk/module.h"
+#include "../defaults.h"
 
 struct rc_hist
 {
@@ -118,7 +119,7 @@
 int main(int argc,char **argv)
 {
 	char linebuffer[300];
-	FILE *ifile = fopen("/tmp/refs", "r");
+	FILE *ifile = fopen(DEFAULT_TMP_DIR "/refs", "r");
 	char *t;
 	unsigned int un;
 	struct rc_obj *curr_obj, *count1_obj;
@@ -127,7 +128,7 @@
 	struct ast_hashtab *objhash;
 	
 	if (!ifile) {
-		printf("Sorry, Cannot open /tmp/refs!\n");
+		printf("Sorry, Cannot open " DEFAULT_TMP_DIR "/refs!\n");
 		exit(10);
 	}
 	
