Re: BUG #8139: initdb: Misleading error message when current user not in /etc/passwd

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, nicolas(at)marchildon(dot)net, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #8139: initdb: Misleading error message when current user not in /etc/passwd
Date: 2013-12-04 15:52:57
Message-ID: 20131204155257.GD17114@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Tue, May 7, 2013 at 02:19:05PM -0400, Alvaro Herrera wrote:
> Tom Lane wrote:
> > nicolas(at)marchildon(dot)net writes:
>
> > > The man page says:
> >
> > > RETURN VALUE
> > > The getpwnam() and getpwuid() functions return a pointer to a
> > > passwd
> > > structure, or NULL if the matching entry is not found or an
> > > error
> > > occurs. If an error occurs, errno is set appropriately. If one
> > > wants
> > > to check errno after the call, it should be set to zero before
> > > the
> > > call.
> >
> > AFAICS, getpwuid is not honoring its specification here: it failed to
> > set errno. I don't see that suppressing the strerror result would add
> > anything much.
>
> Well, in this case no error occured, but no matching entry was found.
> The wording in the manpage is explicit that there not being an entry is
> not an error.

I have developed the attached patch to fix this and another instance I
saw.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ Everyone has their own god. +

Attachment Content-Type Size
passwd.diff text/x-diff 1.1 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Alvaro Herrera 2013-12-04 19:03:39 Re: BUG #8139: initdb: Misleading error message when current user not in /etc/passwd
Previous Message Pavel Stehule 2013-12-04 15:02:41 Re: Re: [BUGS] BUG #7873: pg_restore --clean tries to drop tables that don't exist