summaryrefslogtreecommitdiff
path: root/coreutils/id.c
diff options
context:
space:
mode:
authorRob Landley2005-05-03 06:25:50 +0000
committerRob Landley2005-05-03 06:25:50 +0000
commit60158cb93eb0b3207dd1084cdf5bdd9226bd9e89 (patch)
treefe97ec71775deb1f3078c6db0cb8db554bc6b76f /coreutils/id.c
parent988a78c61cffe91b005d37f0b7d6e2cb2c5ea713 (diff)
downloadbusybox-60158cb93eb0b3207dd1084cdf5bdd9226bd9e89.zip
busybox-60158cb93eb0b3207dd1084cdf5bdd9226bd9e89.tar.gz
A patch from Takeharu KATO to update/fix SE-Linux support.
Diffstat (limited to 'coreutils/id.c')
-rw-r--r--coreutils/id.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/coreutils/id.c b/coreutils/id.c
index d5182b9..541c3d1 100644
--- a/coreutils/id.c
+++ b/coreutils/id.c
@@ -32,8 +32,7 @@
#include <sys/types.h>
#ifdef CONFIG_SELINUX
-#include <proc_secure.h>
-#include <flask_util.h>
+#include <selinux/selinux.h> /* for is_selinux_enabled() */
#endif
#define PRINT_REAL 1
@@ -61,9 +60,6 @@ extern int id_main(int argc, char **argv)
gid_t gid;
unsigned long flags;
short status;
-#ifdef CONFIG_SELINUX
- int is_flask_enabled_flag = is_flask_enabled();
-#endif
bb_opt_complementaly = "u~g:g~u";
flags = bb_getopt_ulflags(argc, argv, "rnug");
@@ -109,17 +105,26 @@ extern int id_main(int argc, char **argv)
putchar(' ');
/* my_getgrgid doesn't exit on failure here */
status|=printf_full(gid, my_getgrgid(NULL, gid, 0), 'g');
+
#ifdef CONFIG_SELINUX
- if(is_flask_enabled_flag) {
- security_id_t mysid = getsecsid();
- char context[80];
- int len = sizeof(context);
- context[0] = '\0';
- if(security_sid_to_context(mysid, context, &len))
- strcpy(context, "unknown");
+ if ( is_selinux_enabled() ) {
+ security_context_t mysid;
+ char context[80];
+ int len = sizeof(context);
+
+ getcon(&mysid);
+ context[0] = '\0';
+ if (mysid) {
+ len = strlen(mysid)+1;
+ safe_strncpy(context, mysid, len);
+ freecon(mysid);
+ }else{
+ safe_strncpy(context, "unknown",8);
+ }
bb_printf(" context=%s", context);
}
#endif
+
putchar('\n');
bb_fflush_stdout_and_exit(status);
}