The following bug has been logged online: Bug reference: 4837 Logged by: David Vitek Email address: dvi...@grammatech.com PostgreSQL version: 8.3 Operating system: Non-Windows Description: initdb segv's if getpwuid fails Details:
We've seen this happen in a deployment, and we are currently assuming the user has some configuration problem. Here's a patch (ignore the revisions): Index: src/bin/initdb/initdb.c =================================================================== --- src/bin/initdb/initdb.c (revision 48282) +++ src/bin/initdb/initdb.c (working copy) @@ -660,10 +660,18 @@ #ifndef WIN32 struct passwd *pw; + uid_t uid = geteuid(); - pw = getpwuid(geteuid()); + errno = 0; /* getpwuid may not alter errno on failure */ + pw = getpwuid(uid); + if( !pw ) + { + fprintf(stderr, _("%s: getpwuid failed: %s\n"), + progname, strerror(errno)); + exit(1); + } - if (geteuid() == 0) /* 0 is root's uid */ + if (uid == 0) /* 0 is root's uid */ { fprintf(stderr, _("%s: cannot be run as root\n" -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs