PERFORCE change 15677 for review

Robert Watson rwatson at freebsd.org
Thu Aug 8 12:37:00 GMT 2002


http://people.freebsd.org/~peter/p4db/chv.cgi?CH=15677

Change 15677 by rwatson at rwatson_tislabs on 2002/08/08 05:36:35

	If no command line is passed to setpmac, default to executing the
	user's shell in an identical style to chroot(8).

Affected files ...

.. //depot/projects/trustedbsd/mac/usr.sbin/setpmac/setpmac.c#4 edit

Differences ...

==== //depot/projects/trustedbsd/mac/usr.sbin/setpmac/setpmac.c#4 (text+ko) ====

@@ -1,7 +1,10 @@
 #include <sys/types.h>
 #include <sys/mac.h>
 
+#include <err.h>
+#include <paths.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <unistd.h>
 
 extern char **environ;
@@ -9,10 +12,11 @@
 int
 main(int argc, char *argv[])
 {
+	const char *shell;
 	struct mac *label;
 	int error;
 
-	if (argc < 3) {
+	if (argc < 2) {
 		fprintf(stderr, "setpmac [label] [binary] [args...]\n");
 		return (-1);
 	}
@@ -31,11 +35,14 @@
 
 	mac_free(label);
 
-	error = execve(argv[2], argv + 2, environ);
-	if (error) {
-		perror(argv[2]);
-		return (-1);
+	if (argc >= 3) {
+		execvp(argv[2], argv + 2);
+		err(1, "%s", argv[2]);
+	} else {
+		if (!(shell = getenv("SHELL")))
+			shell = _PATH_BSHELL;
+		execlp(shell, shell, "-i", (char *)NULL);
+		err(1, "%s", shell);
 	}
-
-	return (0);
+	/* NOTREACHED */
 }
To Unsubscribe: send mail to majordomo at trustedbsd.org
with "unsubscribe trustedbsd-cvs" in the body of the message



More information about the trustedbsd-cvs mailing list