aboutsummaryrefslogtreecommitdiff
path: root/coreutils/id.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2005-05-03 06:25:50 +0000
committerRob Landley <rob@landley.net>2005-05-03 06:25:50 +0000
commit60158cb93eb0b3207dd1084cdf5bdd9226bd9e89 (patch)
treefe97ec71775deb1f3078c6db0cb8db554bc6b76f /coreutils/id.c
parent988a78c61cffe91b005d37f0b7d6e2cb2c5ea713 (diff)
downloadbusybox-w32-60158cb93eb0b3207dd1084cdf5bdd9226bd9e89.tar.gz
busybox-w32-60158cb93eb0b3207dd1084cdf5bdd9226bd9e89.tar.bz2
busybox-w32-60158cb93eb0b3207dd1084cdf5bdd9226bd9e89.zip
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 d5182b953..541c3d16b 100644
--- a/coreutils/id.c
+++ b/coreutils/id.c
@@ -32,8 +32,7 @@
32#include <sys/types.h> 32#include <sys/types.h>
33 33
34#ifdef CONFIG_SELINUX 34#ifdef CONFIG_SELINUX
35#include <proc_secure.h> 35#include <selinux/selinux.h> /* for is_selinux_enabled() */
36#include <flask_util.h>
37#endif 36#endif
38 37
39#define PRINT_REAL 1 38#define PRINT_REAL 1
@@ -61,9 +60,6 @@ extern int id_main(int argc, char **argv)
61 gid_t gid; 60 gid_t gid;
62 unsigned long flags; 61 unsigned long flags;
63 short status; 62 short status;
64#ifdef CONFIG_SELINUX
65 int is_flask_enabled_flag = is_flask_enabled();
66#endif
67 63
68 bb_opt_complementaly = "u~g:g~u"; 64 bb_opt_complementaly = "u~g:g~u";
69 flags = bb_getopt_ulflags(argc, argv, "rnug"); 65 flags = bb_getopt_ulflags(argc, argv, "rnug");
@@ -109,17 +105,26 @@ extern int id_main(int argc, char **argv)
109 putchar(' '); 105 putchar(' ');
110 /* my_getgrgid doesn't exit on failure here */ 106 /* my_getgrgid doesn't exit on failure here */
111 status|=printf_full(gid, my_getgrgid(NULL, gid, 0), 'g'); 107 status|=printf_full(gid, my_getgrgid(NULL, gid, 0), 'g');
108
112#ifdef CONFIG_SELINUX 109#ifdef CONFIG_SELINUX
113 if(is_flask_enabled_flag) { 110 if ( is_selinux_enabled() ) {
114 security_id_t mysid = getsecsid(); 111 security_context_t mysid;
115 char context[80]; 112 char context[80];
116 int len = sizeof(context); 113 int len = sizeof(context);
117 context[0] = '\0'; 114
118 if(security_sid_to_context(mysid, context, &len)) 115 getcon(&mysid);
119 strcpy(context, "unknown"); 116 context[0] = '\0';
117 if (mysid) {
118 len = strlen(mysid)+1;
119 safe_strncpy(context, mysid, len);
120 freecon(mysid);
121 }else{
122 safe_strncpy(context, "unknown",8);
123 }
120 bb_printf(" context=%s", context); 124 bb_printf(" context=%s", context);
121 } 125 }
122#endif 126#endif
127
123 putchar('\n'); 128 putchar('\n');
124 bb_fflush_stdout_and_exit(status); 129 bb_fflush_stdout_and_exit(status);
125} 130}