Re: BUG #8139: initdb: Misleading error message when current user not in /etc/passwd - Mailing list pgsql-bugs

From Bruce Momjian
Subject Re: BUG #8139: initdb: Misleading error message when current user not in /etc/passwd
Date
Msg-id 20131209210532.GA2119@momjian.us
Whole thread Raw
In response to Re: BUG #8139: initdb: Misleading error message when current user not in /etc/passwd  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Responses Re: BUG #8139: initdb: Misleading error message when current user not in /etc/passwd  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: BUG #8139: initdb: Misleading error message when current user not in /etc/passwd  (Alvaro Herrera <alvherre@2ndquadrant.com>)
List pgsql-bugs
On Wed, Dec  4, 2013 at 04:03:39PM -0300, Alvaro Herrera wrote:
> Bruce Momjian wrote:
> > On Tue, May  7, 2013 at 02:19:05PM -0400, Alvaro Herrera wrote:
>
> > I have developed the attached patch to fix this and another instance I
> > saw.
>
> Remember to set errno = 0 before calling the getpw* function; at least
> in initdb it would be meaningful.  And in the pg_upgrade case, it seems
> better to abort the upgrade if this call doesn't work.  (Also, there are
> other uses of getpwuid/getpwnam elsewhere.  Not sure we want to worry
> too much about them.)

Wow, that is an odd API.  Once I started to look at all the errno
clearing necessary, I realized that the function in bin/scripts/common.c
could be moved to src/port and generalized to reduce code duplication.

Updated patch attached, with centralized checking for errno and more
consistent behavior for username lookups.

--
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + Everyone has their own god. +

Attachment

pgsql-bugs by date:

Previous
From: Maciek Sakrejda
Date:
Subject: Re: BUG #8656: Duplicate data violating unique constraints
Next
From: Tom Lane
Date:
Subject: Re: BUG #8139: initdb: Misleading error message when current user not in /etc/passwd