Commit a7a7f5ca authored by Tom Lane's avatar Tom Lane

Change rather bizarre code ordering in get_id(). This isn't strictly

cosmetic --- I'm wondering if geteuid could have side effects on errno,
thus possibly resulting in a misleading error message after failure of
getpwuid.
parent e5507631
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* Portions taken from FreeBSD. * Portions taken from FreeBSD.
* *
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.170 2009/04/05 04:19:58 tgl Exp $ * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.171 2009/06/03 16:17:49 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -654,8 +654,6 @@ get_id(void) ...@@ -654,8 +654,6 @@ get_id(void)
struct passwd *pw; struct passwd *pw;
pw = getpwuid(geteuid());
if (geteuid() == 0) /* 0 is root's uid */ if (geteuid() == 0) /* 0 is root's uid */
{ {
fprintf(stderr, fprintf(stderr,
...@@ -666,6 +664,8 @@ get_id(void) ...@@ -666,6 +664,8 @@ get_id(void)
progname); progname);
exit(1); exit(1);
} }
pw = getpwuid(geteuid());
if (!pw) if (!pw)
{ {
fprintf(stderr, fprintf(stderr,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment