Change rather bizarre code ordering in get_id(). This isn't strictly
authorTom Lane <[email protected]>
Wed, 3 Jun 2009 16:17:49 +0000 (16:17 +0000)
committerTom Lane <[email protected]>
Wed, 3 Jun 2009 16:17:49 +0000 (16:17 +0000)
cosmetic --- I'm wondering if geteuid could have side effects on errno,
thus possibly resulting in a misleading error message after failure of
getpwuid.

src/bin/initdb/initdb.c

index 6155b094727e8b5b201021c63d94c8d4ba3704d8..3bb079840abe2cfde8121552a4d78232f9aa8090 100644 (file)
@@ -42,7 +42,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  * 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)
 
    struct passwd *pw;
 
-   pw = getpwuid(geteuid());
-
    if (geteuid() == 0)         /* 0 is root's uid */
    {
        fprintf(stderr,
@@ -666,6 +664,8 @@ get_id(void)
                progname);
        exit(1);
    }
+
+   pw = getpwuid(geteuid());
    if (!pw)
    {
        fprintf(stderr,