svn commit: trunk/busybox: coreutils coreutils/libcoreutils include etc...

vda at busybox.net vda at busybox.net
Mon Mar 12 18:22:55 UTC 2007


Author: vda
Date: 2007-03-12 11:22:55 -0700 (Mon, 12 Mar 2007)
New Revision: 18073

Log:
introduce and use setfscreatecon_or_die
(patch by Yuichi Nakamura <ynakam at hitachisoft.jp>)
runcon: *yet another* fix for vda's brainfart :(


Modified:
   trunk/busybox/coreutils/install.c
   trunk/busybox/coreutils/libcoreutils/getopt_mk_fifo_nod.c
   trunk/busybox/coreutils/mkdir.c
   trunk/busybox/include/libbb.h
   trunk/busybox/libbb/copy_file.c
   trunk/busybox/libbb/selinux_common.c
   trunk/busybox/selinux/runcon.c


Changeset:
Modified: trunk/busybox/coreutils/install.c
===================================================================
--- trunk/busybox/coreutils/install.c	2007-03-12 18:16:24 UTC (rev 18072)
+++ trunk/busybox/coreutils/install.c	2007-03-12 18:22:55 UTC (rev 18073)
@@ -110,9 +110,7 @@
 	}
 	if (flags & OPT_SET_SECURITY_CONTEXT) {
 		selinux_or_die();
-		if (setfscreatecon(scontext) < 0) {
-			bb_error_msg_and_die("setfscreatecon(%s)", scontext); // perror?
-		}
+		setfscreatecon_or_die(scontext);
 		use_default_selinux_context = 0;
 		copy_flags |= FILEUTILS_SET_SECURITY_CONTEXT;
 	}

Modified: trunk/busybox/coreutils/libcoreutils/getopt_mk_fifo_nod.c
===================================================================
--- trunk/busybox/coreutils/libcoreutils/getopt_mk_fifo_nod.c	2007-03-12 18:16:24 UTC (rev 18072)
+++ trunk/busybox/coreutils/libcoreutils/getopt_mk_fifo_nod.c	2007-03-12 18:22:55 UTC (rev 18073)
@@ -43,10 +43,7 @@
 #if ENABLE_SELINUX
 	if (opt & 2) {
 		selinux_or_die();
-		if (setfscreatecon(scontext)) {
-			bb_error_msg_and_die("cannot set default file creation context "
-					      "to %s", scontext);
-		}
+		setfscreatecon_or_die(scontext);
 	}
 #endif
 

Modified: trunk/busybox/coreutils/mkdir.c
===================================================================
--- trunk/busybox/coreutils/mkdir.c	2007-03-12 18:16:24 UTC (rev 18072)
+++ trunk/busybox/coreutils/mkdir.c	2007-03-12 18:22:55 UTC (rev 18073)
@@ -62,10 +62,7 @@
 #if ENABLE_SELINUX
 	if (opt & 4) {
 		selinux_or_die();
-		if (setfscreatecon(scontext)) {
-			bb_error_msg_and_die("cannot set default file creation context "
-					      "to %s", scontext);
-		}
+		setfscreatecon_or_die(scontext);
 	}
 #endif
 

Modified: trunk/busybox/include/libbb.h
===================================================================
--- trunk/busybox/include/libbb.h	2007-03-12 18:16:24 UTC (rev 18072)
+++ trunk/busybox/include/libbb.h	2007-03-12 18:22:55 UTC (rev 18073)
@@ -601,6 +601,7 @@
 extern void set_current_security_context(security_context_t sid);
 extern context_t set_security_context_component(security_context_t cur_context,
 						char *user, char *role, char *type, char *range);
+extern void setfscreatecon_or_die(security_context_t scontext);
 #endif
 extern void selinux_or_die(void);
 extern int restricted_shell(const char *shell);

Modified: trunk/busybox/libbb/copy_file.c
===================================================================
--- trunk/busybox/libbb/copy_file.c	2007-03-12 18:16:24 UTC (rev 18072)
+++ trunk/busybox/libbb/copy_file.c	2007-03-12 18:22:55 UTC (rev 18073)
@@ -74,7 +74,7 @@
 			}
 		} else {
 			if (errno == ENOTSUP || errno == ENODATA) {
-				setfscreatecon(NULL);
+				setfscreatecon_or_die(NULL);
 			} else {
 				bb_perror_msg("cannot lgetfilecon %s", source);
 				return -1;

Modified: trunk/busybox/libbb/selinux_common.c
===================================================================
--- trunk/busybox/libbb/selinux_common.c	2007-03-12 18:16:24 UTC (rev 18072)
+++ trunk/busybox/libbb/selinux_common.c	2007-03-12 18:22:55 UTC (rev 18073)
@@ -28,3 +28,13 @@
 	context_free(con);
 	return NULL;
 }
+
+void setfscreatecon_or_die(security_context_t scontext)
+{
+	if (setfscreatecon(scontext) < 0) {
+		/* Can be NULL. All known printf implementations
+		 * display "(null)", "<null>" etc */
+		bb_perror_msg_and_die("cannot set default "
+				"file creation context to %s", scontext);
+	}
+}

Modified: trunk/busybox/selinux/runcon.c
===================================================================
--- trunk/busybox/selinux/runcon.c	2007-03-12 18:16:24 UTC (rev 18072)
+++ trunk/busybox/selinux/runcon.c	2007-03-12 18:22:55 UTC (rev 18073)
@@ -132,6 +132,6 @@
 
 	execvp(argv[0], argv);
 
-	bb_perror_msg_and_die("cannot execute '%s'", command);
+	bb_perror_msg_and_die("cannot execute '%s'", argv[0]);
 	return 1;
 }




More information about the busybox-cvs mailing list