Index: branches/stable/mondo/src/common/libmondo-archive-EXT.h
===================================================================
--- branches/stable/mondo/mondo/common/libmondo-archive-EXT.h (revision 543)
+++ branches/stable/mondo/src/common/libmondo-archive-EXT.h (revision 1152)
@@ -41,3 +41,3 @@
 										  char *filelist, char *fname,
 										  int setno);
-extern void setenv_mondo_share(void);
+extern void setenv_mondo_var(void);
Index: branches/stable/mondo/src/common/libmondo-archive.c
===================================================================
--- branches/stable/mondo/src/common/libmondo-archive.c (revision 1147)
+++ branches/stable/mondo/src/common/libmondo-archive.c (revision 1152)
@@ -14,4 +14,5 @@
 #include <sys/ipc.h>
 #include <stdarg.h>
+#include <stdlib.h>
 #include <unistd.h>
 
@@ -3939,8 +3940,20 @@
 /* @} - end of utilityGroup */
 
-void setenv_mondo_share(void) {
-
-setenv("MONDO_SHARE", MONDO_SHARE, 1);
-setenv("MONDORESTORECFG", MONDORESTORECFG, 1);
-setenv("MONDO_CACHE", MONDO_CACHE, 1);
+void setenv_mondo_var(void) {
+
+	char *tmp = NULL;
+	char *p = NULL;
+	char *path_min = "/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin";
+
+	mr_setenv("MONDO_SHARE",MONDO_SHARE);
+	mr_setenv("MONDORESTORECFG",MONDORESTORECFG);
+	mr_setenv("MONDO_CACHE",MONDO_CACHE);
+
+	if ((p = getenv("PATH")) == NULL) {
+		mr_asprintf(&p,path_min);
+	}
+	mr_asprintf(&tmp, "%s:%s",p, path_min);
+	mr_free(p);
+	mr_setenv("PATH",tmp);
+	mr_free(tmp);
 }
Index: branches/stable/mondo/src/common/libmondo-tools.c
===================================================================
--- branches/stable/mondo/src/common/libmondo-tools.c (revision 1144)
+++ branches/stable/mondo/src/common/libmondo-tools.c (revision 1152)
@@ -197,5 +197,5 @@
 
 
-char *get_architecture()
+char *get_architecture(void)
 {
 #ifdef __IA32__
@@ -210,5 +210,5 @@
 
 
-double get_kernel_version()
+double get_kernel_version(void)
 {
 	char *p, tmp[200];
@@ -244,5 +244,5 @@
  * @return number of seconds since the epoch.
  */
-long get_time()
+long get_time(void)
 {
 	return (long) time((void *) 0);
Index: branches/stable/mondo/src/include/mr_mem.h
===================================================================
--- branches/stable/mondo/src/include/mr_mem.h (revision 1133)
+++ branches/stable/mondo/src/include/mr_mem.h (revision 1152)
@@ -22,4 +22,5 @@
 #define mr_getline(x,y,z) mr_getline_int(x,y,z,__LINE__,__FILE__)
 #define mr_malloc(x) mr_malloc_int((size_t)x,__LINE__,__FILE__)
+#define mr_setenv(x,y) mr_setenv_int(x,y,__LINE__,__FILE__)
 
 /* Internal function bringing debuging info 
@@ -30,4 +31,5 @@
 extern inline void mr_getline_int(char **lineptr, size_t *n, FILE *stream, int line, char *file);
 extern inline void *mr_malloc_int(size_t size, int line, char *file);
+extern inline mr_setenv_int(const char *name, const char *value, int line, char *file);
 
 #endif							/* MR_MEM_H */
Index: branches/stable/mondo/src/lib/mr_mem.c
===================================================================
--- branches/stable/mondo/src/lib/mr_mem.c (revision 1138)
+++ branches/stable/mondo/src/lib/mr_mem.c (revision 1152)
@@ -89,2 +89,21 @@
 	mr_asprintf_int(&alloc, line, file, orig);
 }
+
+/* 
+ * Function that properly put a variable in the environment
+ */
+void mr_setenv_int(const char *name, const char *value, int line, char *file) {
+	
+	if (name == NULL) {
+		mr_msg_int(1,line,file,"Unable to setenv a NULL variable\nExiting...");
+		mr_exit(-1, "Unable to setenv a NULL variable");
+	}
+	if (value == NULL) {
+		mr_msg_int(1,line,file,"Unable to affect NULL to %s\nExiting...", name);
+		mr_exit(-1, "Unable to affect a NULL variable");
+	}
+	if (mr_setenv(name, value, 1) != 0) {
+		mr_msg_int(1,line,file,"Unable to put %s in environment", name);
+		mr_exit(-1,"Unable to put in environment");
+	}
+}
Index: branches/stable/mondo/src/mondoarchive/main.c
===================================================================
--- branches/stable/mondo/src/mondoarchive/main.c (revision 1151)
+++ branches/stable/mondo/src/mondoarchive/main.c (revision 1152)
@@ -157,5 +157,5 @@
 	struct s_bkpinfo *bkpinfo;
 	struct stat stbuf;
-	char *tmp;
+	char *tmp = NULL;
 	int res, retval;
 	char *say_at_end;
@@ -178,5 +178,4 @@
 
 	malloc_libmondo_global_strings();
-	malloc_string(tmp);
 	malloc_string(say_at_end);
 
@@ -194,21 +193,9 @@
 	bkpinfo = mr_malloc(sizeof(struct s_bkpinfo));
 
-	/* make sure PATH environmental variable allows access to mkfs, fdisk, etc. */
-	strncpy(tmp, getenv("PATH"), MAX_STR_LEN - 1);
-	tmp[MAX_STR_LEN - 1] = '\0';
-	if (strlen(tmp) >= MAX_STR_LEN - 33) {
-		fatal_error
-			("Your PATH environmental variable is too long. Please shorten it.");
-	}
-	strcat(tmp, ":/sbin:/usr/sbin:/usr/local/sbin");
-	setenv("PATH", tmp, 1);
-
 	/* Add the ARCH environment variable for ia64 purposes */
-	strncpy(tmp, get_architecture(), MAX_STR_LEN - 1);
-	tmp[MAX_STR_LEN - 1] = '\0';
-	setenv("ARCH", tmp, 1);
+	setenv("ARCH", get_architecture(), 1);
 
 	/* Add MONDO_SHARE + others environment variable for mindi */
-	setenv_mondo_share();
+	setenv_mondo_var();
 
 	if (stat(MONDO_CACHE, &stbuf) != 0) {
@@ -247,5 +234,4 @@
 	if (argc == 4 && !strcmp(argv[1], "setfattr")) {
 		g_loglevel = 10;
-//      chdir("/tmp");
 		g_text_mode = TRUE;
 		setup_newt_stuff();
@@ -257,6 +243,8 @@
 		g_text_mode = TRUE;
 		setup_newt_stuff();
+		malloc_string(tmp);
 		turn_wildcard_chars_into_literal_chars(tmp, argv[2]);
 		printf("in=%s; out=%s\n", argv[2], tmp);
+		mr_free(tmp);
 		finish(1);
 	}
@@ -276,5 +264,4 @@
 	if (argc == 4 && !strcmp(argv[1], "setfacl")) {
 		g_loglevel = 10;
-//      chdir("/tmp");
 		g_text_mode = TRUE;
 		setup_newt_stuff();
@@ -286,4 +273,5 @@
 		g_text_mode = TRUE;
 		setup_newt_stuff();
+		malloc_string(tmp);
 		if (find_cdrw_device(tmp)) {
 			printf("Failed to find CDR-RW drive\n");
@@ -297,4 +285,5 @@
 			printf("CD-ROM is at %s\n", tmp);
 		}
+		mr_free(tmp);
 		finish(0);
 	}
@@ -304,4 +293,5 @@
 		g_text_mode = TRUE;
 		setup_newt_stuff();
+		malloc_string(tmp);
 		if (find_dvd_device(tmp, atoi(argv[2]))) {
 			printf("Failed to find DVD drive\n");
@@ -309,4 +299,5 @@
 			printf("DVD is at %s\n", tmp);
 		}
+		mr_free(tmp);
 		finish(0);
 	}
@@ -380,8 +371,9 @@
 		res = verify_data(bkpinfo);
 		if (res < 0) {
-			sprintf(tmp, "%d difference%c found.", -res,
+			mr_asprintf(&tmp, "%d difference%c found.", -res,
 					(-res != 1) ? 's' : ' ');
 			strcat(say_at_end, tmp);
 			log_to_screen(tmp);
+			mr_free(tmp);
 			res = 0;
 		}
@@ -427,6 +419,7 @@
 	}
 	log_to_screen(say_at_end);
-	sprintf(tmp, "umount %s/tmpfs", bkpinfo->tmpdir);
+	mr_asprintf(&tmp, "umount %s/tmpfs", bkpinfo->tmpdir);
 	run_program_and_log_output(tmp, TRUE);
+	mr_free(tmp);
 	run_program_and_log_output(g_erase_tmpdir_and_scratchdir, TRUE);
 
@@ -447,5 +440,4 @@
 	free_libmondo_global_strings();
 	mr_free(say_at_end);
-	mr_free(tmp);
 	mr_free(bkpinfo);
 
