changeset 1661:d4bc084916fd

id.c #ifdefectomy. (ifdefs belong in headers, not in C code.)
author Rob Landley <rob@landley.net>
date Fri, 16 Jan 2015 13:43:09 -0600
parents b84024067049
children c1715c752e89
files lib/portability.h toys/posix/id.c
diffstat 2 files changed, 14 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/lib/portability.h	Fri Jan 16 13:36:53 2015 -0600
+++ b/lib/portability.h	Fri Jan 16 13:43:09 2015 -0600
@@ -239,4 +239,7 @@
 
 #if CFG_TOYBOX_SELINUX
 #include <selinux/selinux.h>
+#else
+#define is_selinux_enabled() 0
+int getcon(void* con);
 #endif
--- a/toys/posix/id.c	Fri Jan 16 13:36:53 2015 -0600
+++ b/toys/posix/id.c	Fri Jan 16 13:43:09 2015 -0600
@@ -146,17 +146,18 @@
     }
   }
 
-#if CFG_TOYBOX_SELINUX
-  char *context = NULL;
-  if (is_selinux_enabled() < 1) {
-    if (TT.do_Z)
-      error_exit("SELinux disabled");
-  } else if (getcon(&context) == 0) {
-    if (!TT.do_Z) xputc(' ');
-    printf("context=%s", context);
+  if (CFG_TOYBOX_SELINUX) {
+    char *context = NULL;
+
+    if (is_selinux_enabled() < 1) {
+      if (TT.do_Z)
+        error_exit("SELinux disabled");
+    } else if (getcon(&context) == 0) {
+      if (!TT.do_Z) xputc(' ');
+      printf("context=%s", context);
+    }
+    if (CFG_TOYBOX_FREE) free(context);
   }
-  if (CFG_TOYBOX_FREE) free(context);
-#endif
 
   xputc('\n');
 }