From: Ben Gras Date: Mon, 12 Dec 2005 13:55:58 +0000 (+0000) Subject: added -u flag to id for easypack X-Git-Tag: v3.1.2a~475 X-Git-Url: http://zhaoyanbai.com/repos/%22https:/www.google.com/jsapi/static/mdoc.3.html?a=commitdiff_plain;h=0a4047a8fe3c7dcfda7fa484cd9cffcf35bd55d9;p=minix.git added -u flag to id for easypack --- diff --git a/commands/simple/id.c b/commands/simple/id.c index 4a0843ebd..b2e6ae3fc 100755 --- a/commands/simple/id.c +++ b/commands/simple/id.c @@ -14,9 +14,7 @@ #include #include -_PROTOTYPE(int main, (void)); - -int main() +int main(int argc, char *argv[]) { struct passwd *pwd; struct group *grp; @@ -38,6 +36,7 @@ int main() #endif int g; int isug; + int c, uopt = 0; #if __minix_vmd get6id(&ruid, &euid, &suid, &rgid, &egid, &sgid); @@ -53,6 +52,22 @@ int main() ngroups = getgroups(NGROUPS_MAX, groups); #endif + while((c = getopt(argc, argv, "u")) != EOF) { + switch(c) { + case 'u': + uopt = 1; + break; + default: + fprintf(stderr, "%s: unrecognized option\n", argv[0]); + return(1); + } + } + + if(uopt) { + printf("%d\n", euid); + return 0; + } + if ((pwd = getpwuid(ruid)) == NULL) printf("uid=%d", ruid); else