id.c #ifdefectomy. (ifdefs belong in headers, not in C code.)

This commit is contained in:
Rob Landley 2015-01-16 13:43:09 -06:00
parent 7e2af1c748
commit 3b915991f8
2 changed files with 14 additions and 10 deletions

View File

@ -239,4 +239,7 @@ pid_t xfork(void);
#if CFG_TOYBOX_SELINUX
#include <selinux/selinux.h>
#else
#define is_selinux_enabled() 0
int getcon(void* con);
#endif

View File

@ -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');
}