diff options
author | Eric Andersen | 2003-07-03 10:07:04 +0000 |
---|---|---|
committer | Eric Andersen | 2003-07-03 10:07:04 +0000 |
commit | 9e48045e45df7e3e205575a4eb3dc39d634b05aa (patch) | |
tree | e8f993dffc34380fbcc54cc858c81da594bdb95b /coreutils/id.c | |
parent | c48d49ad988a4163cff7f38ee4bd1f9886d0ed11 (diff) | |
download | busybox-9e48045e45df7e3e205575a4eb3dc39d634b05aa.zip busybox-9e48045e45df7e3e205575a4eb3dc39d634b05aa.tar.gz |
Patch from Russell Coker:
I've attached my latest SE Linux patch for busybox against the latest CVS
version of busybox.
Diffstat (limited to 'coreutils/id.c')
-rw-r--r-- | coreutils/id.c | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/coreutils/id.c b/coreutils/id.c index 9b2d60d..971e7cd 100644 --- a/coreutils/id.c +++ b/coreutils/id.c @@ -28,9 +28,13 @@ #include <getopt.h> #include <string.h> #include <sys/types.h> +#ifdef CONFIG_SELINUX +#include <proc_secure.h> +#include <flask_util.h> +#endif -#define NO_GROUP 1 -#define NO_USER 2 +#define JUST_USER 1 +#define JUST_GROUP 2 #define PRINT_REAL 4 #define NAME_NOT_NUMBER 8 @@ -40,10 +44,13 @@ extern int id_main(int argc, char **argv) long pwnam, grnam; int uid, gid; int flags; +#ifdef CONFIG_SELINUX + int is_flask_enabled_flag = is_flask_enabled(); +#endif flags = bb_getopt_ulflags(argc, argv, "ugrn"); - if (((flags & (NO_USER | NO_GROUP)) == (NO_USER | NO_GROUP)) + if (((flags & (JUST_USER | JUST_GROUP)) == (JUST_USER | JUST_GROUP)) || (argc > optind + 1) ) { bb_show_usage(); @@ -67,9 +74,9 @@ extern int id_main(int argc, char **argv) pwnam=my_getpwnam(user); grnam=my_getgrnam(group); - if (flags & (NO_GROUP | NO_USER)) { + if (flags & (JUST_GROUP | JUST_USER)) { char *s = group; - if (flags & NO_GROUP) { + if (flags & JUST_USER) { s = user; grnam = pwnam; } @@ -79,7 +86,24 @@ extern int id_main(int argc, char **argv) printf("%ld\n", grnam); } } else { +#ifdef CONFIG_SELINUX + printf("uid=%ld(%s) gid=%ld(%s)", pwnam, user, grnam, group); + 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"); + printf(" context=%s\n", context); + } + else + printf("\n"); +#else printf("uid=%ld(%s) gid=%ld(%s)\n", pwnam, user, grnam, group); +#endif + } bb_fflush_stdout_and_exit(0); |