Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Vq8Uv-0006Gv-Lb for pgsql-bugs@arkaria.postgresql.org; Mon, 09 Dec 2013 21:36:13 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Vq8Uv-0006CV-2u for pgsql-bugs@arkaria.postgresql.org; Mon, 09 Dec 2013 21:36:13 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Vq8Ut-0006Am-Ct for pgsql-bugs@postgresql.org; Mon, 09 Dec 2013 21:36:11 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Vq8Ur-0008E8-7q for pgsql-bugs@postgresql.org; Mon, 09 Dec 2013 21:36:10 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id rB9LZuMC027893; Mon, 9 Dec 2013 16:35:56 -0500 From: Tom Lane To: Bruce Momjian cc: Alvaro Herrera , nicolas@marchildon.net, Bugs for PostgreSQL Subject: Re: BUG #8139: initdb: Misleading error message when current user not in /etc/passwd In-reply-to: <20131209210532.GA2119@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> Comments: In-reply-to Bruce Momjian message dated "Mon, 09 Dec 2013 16:05:32 -0500" Date: Mon, 09 Dec 2013 16:35:56 -0500 Message-ID: <27892.1386624956@sss.pgh.pa.us> 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 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. Also, I don't think that error message meets our style guidelines. Maybe "failed to look up user id %d: ..." ? 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