pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: nicolas@marchildon.net
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #8139: initdb: Misleading error message when current user not in /etc/passwd
Date: Tue, 07 May 2013 14:10:28 -0400
Message-ID: <296.1367950228@sss.pgh.pa.us> (raw)
In-Reply-To: <E1UZk2V-0005oP-Eh@wrigleys.postgresql.org>
References: <E1UZk2V-0005oP-Eh@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

nicolas@marchildon.net writes:
> "initdb: could not obtain information about current user: Success"

> The misleading part is the "Success". This comes from errno:

>         pw = getpwuid(geteuid());
>         if (!pw)
>         {
>                 fprintf(stderr,
>                           _("%s: could not obtain information about current
> user: %s\n"),
>                                 progname, strerror(errno));
>                 exit(1);
>         }

> 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.

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (24+ messages)  latest in thread

Message-ID: <296.1367950228@sss.pgh.pa.us>
Permalink:  ../296.1367950228@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/296.1367950228@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, nicolas@marchildon.net
  Subject: Re: BUG #8139: initdb: Misleading error message when current user not in /etc/passwd
  In-Reply-To: <296.1367950228@sss.pgh.pa.us>
  References: <E1UZk2V-0005oP-Eh@wrigleys.postgresql.org> <296.1367950228@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox