From: | "David Vitek" <dvitek(at)grammatech(dot)com> |
---|---|
To: | pgsql-bugs(at)postgresql(dot)org |
Subject: | BUG #4837: initdb segv's if getpwuid fails |
Date: | 2009-06-03 15:21:08 |
Message-ID: | 200906031521.n53FL85e054804@wwwmaster.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
The following bug has been logged online:
Bug reference: 4837
Logged by: David Vitek
Email address: dvitek(at)grammatech(dot)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"
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2009-06-03 15:37:26 | Re: BUG #4835: psql server crashes when using non-existing functions |
Previous Message | Anurag Pathak | 2009-06-03 14:43:08 | Unable to find UUID Option while Installing PostGreSQL 8.3 |