Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UZmLa-0001Wm-As for pgsql-bugs@arkaria.postgresql.org; Tue, 07 May 2013 18:10:43 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UZmLZ-0000ct-Qi for pgsql-bugs@arkaria.postgresql.org; Tue, 07 May 2013 18:10:41 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UZmLZ-0000ck-6t for pgsql-bugs@postgresql.org; Tue, 07 May 2013 18:10:41 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UZmLU-0000os-AA for pgsql-bugs@postgresql.org; Tue, 07 May 2013 18:10:40 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.5/8.14.5) with ESMTP id r47IASYW000297; Tue, 7 May 2013 14:10:28 -0400 (EDT) From: Tom Lane To: nicolas@marchildon.net cc: pgsql-bugs@postgresql.org Subject: Re: BUG #8139: initdb: Misleading error message when current user not in /etc/passwd In-reply-to: References: Comments: In-reply-to nicolas@marchildon.net message dated "Tue, 07 May 2013 15:42:51 -0000" Date: Tue, 07 May 2013 14:10:28 -0400 Message-ID: <296.1367950228@sss.pgh.pa.us> X-Pg-Spam-Score: -3.2 (---) 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 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