[PATCH 4/8] busybox -- SELinux option support for coreutils: ver3

Bernhard Fischer rep.dot.nop at gmail.com
Thu Mar 8 12:45:34 UTC 2007


On Fri, Feb 23, 2007 at 05:48:01PM +0900, Yuichi Nakamura wrote:
>[4/8] busybox-coreutils-04-stat.v3.patch
> - -Z option support for stat. Security context of file is shown by -Z option.
>
>Signed-off-by:  Yoshinori Sato <ysato at users.sourceforge.jp>
Index: coreutils/stat.c
===================================================================
--- coreutils/stat.c    (revision 17961)
+++ coreutils/stat.c    (working copy)
...
+ * Copyright (C) 2006 by Yoshinori Sato <ysato at users.sourceforge.jp>

copyright year (email addr?)

@@ -164,6 +167,14 @@
                strncat(pformat, "jd", buf_len);
                printf(pformat, (intmax_t) (statfsbuf->f_ffree));
                break;
+#if ENABLE_SELINUX
+       case 'C':
+               if (flags & OPT_SELINUX) {
+                       strcat(pformat, "s");
+                       printf(scontext);
+               }
+               break;
+#endif

You don't need strncat here, do you?

@@ -301,6 +313,14 @@                                
                strncat(pformat, TYPE_SIGNED(time_t) ? "ld" : "lu", buf_len);
                printf(pformat, (unsigned long int) statbuf->st_ctime);
                break;
+#if ENABLE_SELINUX
+       case 'C':
+               if (flags & OPT_SELINUX) {
+                       strcat(pformat, "s");
+                       printf(pformat, scontext);
+               }
+               break;
+#endif

That sounds rather familiar. Deja vu? Any way around that duplication?

@@ -360,11 +381,25 @@
 }
 #endif

+#define _getfilecon(filename, scontext) \
+       (flags & OPT_DEREFERENCE ? \
+        lgetfilecon(filename, scontext): \
+        getfilecon(filename, scontext))
+
You use this define just in one place. Please expand it manually at the
call-site.

I'd prefer if you would just #if ENABLE_SELINUX and not duplicate the
"format". Makes grepping for duplicates easier, imo.



More information about the busybox mailing list