[PATCH 3/6] busybox -- SELinux option support for coreutils

Denis Vlasenko vda.linux at googlemail.com
Thu Feb 8 22:53:43 UTC 2007


On Thursday 08 February 2007 07:54, Yuichi Nakamura wrote:
> [3/6] busybox-coreutils-03-mk.patch
>  - -Z option support for mkdir, mkfifo, mknod. 
>     By -Z, security context for created file can be set.
> 
> Signed-off-by: Yoshinori Sato <ysato at users.sourceforge.jp>


+#if ENABLE_SELINUX
+	security_context_t scontext = NULL;
+#endif
 
 #if ENABLE_FEATURE_MKDIR_LONG_OPTIONS
 	applet_long_options = mkdir_long_options;
 #endif
-	opt = getopt32(argc, argv, "m:p", &smode);
+	opt = getopt32(argc, argv, "m:p" USE_SELINUX("Z:"), &smode USE_SELINUX(,&scontext));
 	if (opt & 1) {
 		mode = 0777;
 		if (!bb_parse_mode(smode, &mode)) {
@@ -50,6 +61,15 @@
 	}
 	if (opt & 2)
 		flags |= FILEUTILS_RECUR;
+#if ENABLE_SELINUX
+	if(opt & 4) {
+		selinux_or_die();
+		if (setfscreatecon(scontext)) {
+			bb_error_msg_and_die ("Sorry, cannot set default context "
+					      "to %s.\n", scontext);

Initializing scontext to NULL is useless code. bb_error_msg_and_die
has useless "Sorry" (with wrong capitalization: "mkdir: Sorry...")
and useless ".\n" at the end.

Sorry guys, I would be really happy if these patches get
a little bit prettier...
--
vda



More information about the busybox mailing list