diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-03-03 18:29:04 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-03 18:29:04 -0800 |
commit | e54eebbf1a908d65ee8cf80bab62821c05666d70 (patch) | |
tree | 4b825dc642cb6eb9a060e54bf8d69288fbee4904 /toolbox/id.c | |
parent | a1e1c1b106423de09bc918502e7a51d4ffe5a4ae (diff) | |
download | system_core-e54eebbf1a908d65ee8cf80bab62821c05666d70.zip system_core-e54eebbf1a908d65ee8cf80bab62821c05666d70.tar.gz system_core-e54eebbf1a908d65ee8cf80bab62821c05666d70.tar.bz2 |
auto import from //depot/cupcake/@135843
Diffstat (limited to 'toolbox/id.c')
-rw-r--r-- | toolbox/id.c | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/toolbox/id.c b/toolbox/id.c deleted file mode 100644 index bb03cad..0000000 --- a/toolbox/id.c +++ /dev/null @@ -1,51 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <sys/types.h> -#include <pwd.h> -#include <grp.h> - -static void print_uid(uid_t uid) -{ - struct passwd *pw = getpwuid(uid); - - if (pw) { - printf("%d(%s)", uid, pw->pw_name); - } else { - printf("%d",uid); - } -} - -static void print_gid(gid_t gid) -{ - struct group *gr = getgrgid(gid); - if (gr) { - printf("%d(%s)", gid, gr->gr_name); - } else { - printf("%d",gid); - } -} - -int id_main(int argc, char **argv) -{ - gid_t list[64]; - int n, max; - - max = getgroups(64, list); - if (max < 0) max = 0; - - printf("uid="); - print_uid(getuid()); - printf(" gid="); - print_gid(getgid()); - if (max) { - printf(" groups="); - print_gid(list[0]); - for(n = 1; n < max; n++) { - printf(","); - print_gid(list[n]); - } - } - printf("\n"); - return 0; -} |