pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruce Momjian <bruce@momjian.us>
To: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: nicolas@marchildon.net
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #8139: initdb: Misleading error message when current user not in /etc/passwd
Date: Wed, 4 Dec 2013 10:52:57 -0500
Message-ID: <20131204155257.GD17114@momjian.us> (raw)
In-Reply-To: <20130507181904.GA26800@eldon.alvh.no-ip.org>
References: <E1UZk2V-0005oP-Eh@wrigleys.postgresql.org>
	<296.1367950228@sss.pgh.pa.us>
	<20130507181904.GA26800@eldon.alvh.no-ip.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

On Tue, May  7, 2013 at 02:19:05PM -0400, Alvaro Herrera wrote:
> Tom Lane wrote:
> > nicolas@marchildon.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@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + Everyone has their own god. +

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

Attachments:

passwd.diff (text/x-diff, 1.1K) download diff --git a/contrib/pg_upgrade/util.c b/contrib/pg_upgrade/util.c new file mode 100644 index a67bd64..9ad4220 *** a/contrib/pg_upgrade/util.c --- b/contrib/pg_upgrade/util.c *************** get_user_info(char **user_name) *** 228,234 **** user_id = 1; #endif ! *user_name = pg_strdup(pw->pw_name); return user_id; } --- 228,237 ---- user_id = 1; #endif ! if (pw) ! *user_name = pg_strdup(pw->pw_name); ! else ! *user_name = NULL; return user_id; } diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c new file mode 100644 index 30e3701..8665595 *** a/src/bin/initdb/initdb.c --- b/src/bin/initdb/initdb.c *************** get_id(void) *** 795,801 **** { fprintf(stderr, _("%s: could not obtain information about current user: %s\n"), ! progname, strerror(errno)); exit(1); } #else /* the windows code */ --- 795,801 ---- { fprintf(stderr, _("%s: could not obtain information about current user: %s\n"), ! progname, errno ? strerror(errno) : "not an operating system user"); exit(1); } #else /* the windows code */

view thread (24+ messages)  latest in thread

Message-ID: <20131204155257.GD17114@momjian.us>
Permalink:  ../20131204155257.GD17114@momjian.us/
Also on:    postgresql.org/message-id/20131204155257.GD17114@momjian.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: bruce@momjian.us, alvherre@2ndquadrant.com, 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: <20131204155257.GD17114@momjian.us>
  References: <E1UZk2V-0005oP-Eh@wrigleys.postgresql.org> <296.1367950228@sss.pgh.pa.us> <20130507181904.GA26800@eldon.alvh.no-ip.org> <20131204155257.GD17114@momjian.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