From 3b915991f8c8648f939498777f4d76aad04f2817 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Fri, 16 Jan 2015 13:43:09 -0600 Subject: id.c #ifdefectomy. (ifdefs belong in headers, not in C code.) --- lib/portability.h | 3 +++ toys/posix/id.c | 21 +++++++++++---------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/lib/portability.h b/lib/portability.h index 67ac5b58..4097defa 100644 --- a/lib/portability.h +++ b/lib/portability.h @@ -239,4 +239,7 @@ pid_t xfork(void); #if CFG_TOYBOX_SELINUX #include +#else +#define is_selinux_enabled() 0 +int getcon(void* con); #endif diff --git a/toys/posix/id.c b/toys/posix/id.c index 4e1ec8cb..353aa041 100644 --- a/toys/posix/id.c +++ b/toys/posix/id.c @@ -146,17 +146,18 @@ void do_id(char *username) } } -#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'); } -- cgit v1.2.3