[PATCH] setenv|putenv rc checking (usr.sbin)

Alexey Slynko slynko at tronet.ru
Thu Sep 29 04:44:28 PDT 2005


===================================================================
RCS file: /mnt/share/dragonfly-cvs/src/usr.sbin/cron/cron/cron.c,v
retrieving revision 1.6
diff -u -r1.6 cron.c
--- cron/cron/cron.c	18 Dec 2004 22:48:03 -0000	1.6
+++ cron/cron/cron.c	29 Sep 2005 02:20:36 -0000
@@ -88,7 +88,8 @@
 	set_cron_cwd();
 
 #if defined(POSIX)
-	setenv("PATH", _PATH_DEFPATH, 1);
+	if (setenv("PATH", _PATH_DEFPATH, 1) == ENOMEM)
+		err(1, "setenv: cannot set PATH=%s", _PATH_DEFPATH);
 #endif
 
 	/* if there are no debug flags turned on, fork as a daemon should.
Index: inetd/inetd.c
===================================================================
RCS file: /mnt/share/dragonfly-cvs/src/usr.sbin/inetd/inetd.c,v
retrieving revision 1.8
diff -u -r1.8 inetd.c
--- inetd/inetd.c	21 Mar 2005 19:26:14 -0000	1.8
+++ inetd/inetd.c	29 Sep 2005 02:24:54 -0000
@@ -241,7 +241,7 @@
 int	wrap_ex = 0;
 int	wrap_bi = 0;
 int	debug = 0;
-int	log = 0;
+int	logconn = 0;
 int	maxsock;			/* highest-numbered descriptor */
 fd_set	allsock;
 int	options;
@@ -347,7 +347,7 @@
 			options |= SO_DEBUG;
 			break;
 		case 'l':
-			log = 1;
+			logconn = 1;
 			break;
 		case 'R':
 			getvalue(optarg, &toomany,
@@ -504,7 +504,8 @@
 
 		memset(dummy, 'x', DUMMYSIZE - 1);
 		dummy[DUMMYSIZE - 1] = '\0';
-		setenv("inetd_dummy", dummy, 1);
+		if (setenv("inetd_dummy", dummy, 1) == ENOMEM)
+			err(1, "setenv: cannot set inetd_dummy=%s", dummy);
 	}
 
 	if (pipe(signalpipe) != 0) {
@@ -614,7 +615,7 @@
 			    }
 		    } else
 			    ctrl = sep->se_fd;
-		    if (log && !ISWRAP(sep)) {
+		    if (logconn && !ISWRAP(sep)) {
 			    char pname[INET6_ADDRSTRLEN] = "unknown";
 			    socklen_t sl;
 			    sl = sizeof peermax;
@@ -733,7 +734,7 @@
 					_exit(0);
 				    }
 				}
-				if (log) {
+				if (logconn) {
 				    syslog(allow_severity,
 				        "connection from %.500s, service %s (%s%s)",
 					eval_client(&req), service, sep->se_proto,
Index: pstat/pstat.c
===================================================================
RCS file: /mnt/share/dragonfly-cvs/src/usr.sbin/pstat/pstat.c,v
retrieving revision 1.15
diff -u -r1.15 pstat.c
--- pstat/pstat.c	17 Mar 2005 17:28:44 -0000	1.15
+++ pstat/pstat.c	29 Sep 2005 02:19:27 -0000
@@ -226,7 +226,8 @@
 			fileflag = 1;
 			break;
 		case 'k':
-			putenv("BLOCKSIZE=1K");
+			if (putenv("BLOCKSIZE=1K") == ENOMEM)
+				err(1, "putenv: cannot set BLOCKSIZE=1K");
 			break;
 		case 'M':
 			memf = optarg;
Index: tzsetup/tzsetup.c
===================================================================
RCS file: /mnt/share/dragonfly-cvs/src/usr.sbin/tzsetup/tzsetup.c,v
retrieving revision 1.4
diff -u -r1.4 tzsetup.c
--- tzsetup/tzsetup.c	19 Feb 2005 01:43:06 -0000	1.4
+++ tzsetup/tzsetup.c	29 Sep 2005 02:36:18 -0000
@@ -586,7 +586,8 @@
 	time_t t = time(0);
 	int rv;
 	
-	setenv("TZ", filename, 1);
+	if (setenv("TZ", filename, 1) == ENOMEM)
+		err(1, "setenv: cannot set TZ=%s", filename);
 	tzset();
 	tm = localtime(&t);
 




More information about the Submit mailing list