Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 8 Aug 2002 05:37:00 -0700 (PDT)
From:      Robert Watson <rwatson@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 15677 for review
Message-ID:  <200208081237.g78Cb0wZ019095@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://people.freebsd.org/~peter/p4db/chv.cgi?CH=15677

Change 15677 by rwatson@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@FreeBSD.org
with "unsubscribe p4-projects" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200208081237.g78Cb0wZ019095>