Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VqBTF-0005nM-79 for pgsql-bugs@arkaria.postgresql.org; Tue, 10 Dec 2013 00:46:41 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VqBTE-0005Pt-HZ for pgsql-bugs@arkaria.postgresql.org; Tue, 10 Dec 2013 00:46:40 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VqBTC-0005Pk-Iz for pgsql-bugs@postgresql.org; Tue, 10 Dec 2013 00:46:38 +0000 Received: from momjian.us ([72.94.173.45]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VqBT9-0005ot-6Q for pgsql-bugs@postgresql.org; Tue, 10 Dec 2013 00:46:38 +0000 Received: from bruce by momjian.us with local (Exim 4.72) (envelope-from ) id 1VqBT4-0000A4-Id; Mon, 09 Dec 2013 19:46:30 -0500 Date: Mon, 9 Dec 2013 19:46:30 -0500 From: Bruce Momjian To: Tom Lane Cc: Alvaro Herrera , nicolas@marchildon.net, Bugs for PostgreSQL Subject: Re: BUG #8139: initdb: Misleading error message when current user not in /etc/passwd Message-ID: <20131210004630.GD2119@momjian.us> References: <296.1367950228@sss.pgh.pa.us> <20130507181904.GA26800@eldon.alvh.no-ip.org> <20131204155257.GD17114@momjian.us> <20131204190338.GP5158@eldon.alvh.no-ip.org> <20131209210532.GA2119@momjian.us> <27892.1386624956@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <27892.1386624956@sss.pgh.pa.us> User-Agent: Mutt/1.5.20 (2009-06-14) X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org On Mon, Dec 9, 2013 at 04:35:56PM -0500, Tom Lane wrote: > Bruce Momjian writes: > > Updated patch attached, with centralized checking for errno and more > > consistent behavior for username lookups. > > This bit is not good: > > + errno = 0; /* clear errno before call */ > + pw = getpwuid(geteuid()); > + if (!pw) > + { > + *errstr = psprintf(_("effective user id %d lookup failure: %s"), > + (int) geteuid(), errno ? strerror(errno) : > + _("user does not exist")); > > The second call of geteuid() could clobber errno before strerror can see it. > You should compute geteuid() just once and keep it in a variable. Good point --- fixed. > Also, I don't think that error message meets our style guidelines. > Maybe "failed to look up user id %d: ..." ? OK, updated. Updated patch attached to Alvaro's email reply. -- Bruce Momjian 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