diff options
Diffstat (limited to 'src/bin/pg_id/pg_id.c')
-rw-r--r-- | src/bin/pg_id/pg_id.c | 62 |
1 files changed, 34 insertions, 28 deletions
diff --git a/src/bin/pg_id/pg_id.c b/src/bin/pg_id/pg_id.c index 4364fc1cf29..b782b091a3e 100644 --- a/src/bin/pg_id/pg_id.c +++ b/src/bin/pg_id/pg_id.c @@ -1,15 +1,15 @@ /*------------------------------------------------------------------------- * * pg_id.c-- - * Print the user ID for the login name passed as argument, - * or the real user ID of the caller if no argument. If the - * login name doesn't exist, print "NOUSER" and exit 1. + * Print the user ID for the login name passed as argument, + * or the real user ID of the caller if no argument. If the + * login name doesn't exist, print "NOUSER" and exit 1. * * Copyright (c) 1994, Regents of the University of California * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/bin/pg_id/Attic/pg_id.c,v 1.3 1996/11/08 06:01:12 momjian Exp $ + * $Header: /cvsroot/pgsql/src/bin/pg_id/Attic/pg_id.c,v 1.4 1997/09/07 04:54:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -23,33 +23,39 @@ int main(int argc, char **argv) { - struct passwd *pw; - int ch; - extern int optind; + struct passwd *pw; + int ch; + extern int optind; - while ((ch = getopt(argc, argv, "")) != EOF) - switch (ch) { - case '?': - default: - fprintf(stderr, "usage: pg_id [login]\n"); - exit(1); - } - argc -= optind; - argv += optind; + while ((ch = getopt(argc, argv, "")) != EOF) + switch (ch) + { + case '?': + default: + fprintf(stderr, "usage: pg_id [login]\n"); + exit(1); + } + argc -= optind; + argv += optind; - if (argc > 0) { - if (argc > 1) { - fprintf(stderr, "usage: pg_id [login]\n"); - exit(1); + if (argc > 0) + { + if (argc > 1) + { + fprintf(stderr, "usage: pg_id [login]\n"); + exit(1); + } + if ((pw = getpwnam(argv[0])) == NULL) + { + printf("NOUSER\n"); + exit(1); + } + printf("%ld\n", (long) pw->pw_uid); } - if ((pw = getpwnam(argv[0])) == NULL) { - printf("NOUSER\n"); - exit(1); + else + { + printf("%ld\n", (long) getuid()); } - printf("%ld\n", (long)pw->pw_uid); - } else { - printf("%ld\n", (long)getuid()); - } - exit(0); + exit(0); } |