aboutsummaryrefslogtreecommitdiff
path: root/coreutils/id.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2006-10-05 22:50:22 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2006-10-05 22:50:22 +0000
commitde59c0f58fa5dc75b753f94da61be92bfa0935ec (patch)
treefea308471e3d73fb6770ff6e4cda23da53b65bec /coreutils/id.c
parent01c27fc5ac89b07821a5430880d771e3c993c1c1 (diff)
downloadbusybox-w32-de59c0f58fa5dc75b753f94da61be92bfa0935ec.tar.gz
busybox-w32-de59c0f58fa5dc75b753f94da61be92bfa0935ec.tar.bz2
busybox-w32-de59c0f58fa5dc75b753f94da61be92bfa0935ec.zip
httpd: add -u user[:grp] support
Diffstat (limited to 'coreutils/id.c')
-rw-r--r--coreutils/id.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/coreutils/id.c b/coreutils/id.c
index 9e49999cd..9d605325c 100644
--- a/coreutils/id.c
+++ b/coreutils/id.c
@@ -29,11 +29,11 @@
29static short printf_full(unsigned int id, const char *arg, const char prefix) 29static short printf_full(unsigned int id, const char *arg, const char prefix)
30{ 30{
31 const char *fmt = "%cid=%u"; 31 const char *fmt = "%cid=%u";
32 short status=EXIT_FAILURE; 32 short status = EXIT_FAILURE;
33 33
34 if(arg) { 34 if (arg) {
35 fmt = "%cid=%u(%s)"; 35 fmt = "%cid=%u(%s)";
36 status=EXIT_SUCCESS; 36 status = EXIT_SUCCESS;
37 } 37 }
38 bb_printf(fmt, prefix, id, arg); 38 bb_printf(fmt, prefix, id, arg);
39 return status; 39 return status;
@@ -60,21 +60,21 @@ int id_main(int argc, char **argv)
60 gid = getgid(); 60 gid = getgid();
61 } 61 }
62 62
63 if(argv[optind]) { 63 if (argv[optind]) {
64 p=getpwnam(argv[optind]); 64 p = getpwnam(argv[optind]);
65 /* bb_xgetpwnam is needed because it exits on failure */ 65 /* bb_xgetpwnam is needed because it exits on failure */
66 uid = bb_xgetpwnam(argv[optind]); 66 uid = bb_xgetpwnam(argv[optind]);
67 gid = p->pw_gid; 67 gid = p->pw_gid;
68 /* in this case PRINT_REAL is the same */ 68 /* in this case PRINT_REAL is the same */
69 } 69 }
70 70
71 if(flags & (JUST_GROUP | JUST_USER)) { 71 if (flags & (JUST_GROUP | JUST_USER)) {
72 /* JUST_GROUP and JUST_USER are mutually exclusive */ 72 /* JUST_GROUP and JUST_USER are mutually exclusive */
73 if(flags & NAME_NOT_NUMBER) { 73 if (flags & NAME_NOT_NUMBER) {
74 /* bb_getpwuid and bb_getgrgid exit on failure so puts cannot segfault */ 74 /* bb_getpwuid and bb_getgrgid exit on failure so puts cannot segfault */
75 puts((flags & JUST_USER) ? bb_getpwuid(NULL, uid, -1 ) : bb_getgrgid(NULL, gid, -1 )); 75 puts((flags & JUST_USER) ? bb_getpwuid(NULL, uid, -1 ) : bb_getgrgid(NULL, gid, -1 ));
76 } else { 76 } else {
77 bb_printf("%u\n",(flags & JUST_USER) ? uid : gid); 77 bb_printf("%u\n", (flags & JUST_USER) ? uid : gid);
78 } 78 }
79 /* exit */ 79 /* exit */
80 bb_fflush_stdout_and_exit(EXIT_SUCCESS); 80 bb_fflush_stdout_and_exit(EXIT_SUCCESS);
@@ -82,13 +82,13 @@ int id_main(int argc, char **argv)
82 82
83 /* Print full info like GNU id */ 83 /* Print full info like GNU id */
84 /* bb_getpwuid doesn't exit on failure here */ 84 /* bb_getpwuid doesn't exit on failure here */
85 status=printf_full(uid, bb_getpwuid(NULL, uid, 0), 'u'); 85 status = printf_full(uid, bb_getpwuid(NULL, uid, 0), 'u');
86 putchar(' '); 86 putchar(' ');
87 /* bb_getgrgid doesn't exit on failure here */ 87 /* bb_getgrgid doesn't exit on failure here */
88 status|=printf_full(gid, bb_getgrgid(NULL, gid, 0), 'g'); 88 status |= printf_full(gid, bb_getgrgid(NULL, gid, 0), 'g');
89 89
90#ifdef CONFIG_SELINUX 90#ifdef CONFIG_SELINUX
91 if ( is_selinux_enabled() ) { 91 if (is_selinux_enabled()) {
92 security_context_t mysid; 92 security_context_t mysid;
93 char context[80]; 93 char context[80];
94 int len = sizeof(context); 94 int len = sizeof(context);
@@ -99,8 +99,8 @@ int id_main(int argc, char **argv)
99 len = strlen(mysid)+1; 99 len = strlen(mysid)+1;
100 safe_strncpy(context, mysid, len); 100 safe_strncpy(context, mysid, len);
101 freecon(mysid); 101 freecon(mysid);
102 }else{ 102 } else {
103 safe_strncpy(context, "unknown",8); 103 safe_strncpy(context, "unknown", 8);
104 } 104 }
105 bb_printf(" context=%s", context); 105 bb_printf(" context=%s", context);
106 } 106 }