Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UZlhr-0007QX-Ha for pgsql-bugs@arkaria.postgresql.org; Tue, 07 May 2013 17:29:39 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UZlhq-0004IT-WA for pgsql-bugs@arkaria.postgresql.org; Tue, 07 May 2013 17:29:39 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UZk2e-0004yW-GG for pgsql-bugs@postgresql.org; Tue, 07 May 2013 15:43:00 +0000 Received: from mahout.postgresql.org ([2001:4800:7903:4::123]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UZk2b-0006oC-Ig for pgsql-bugs@postgresql.org; Tue, 07 May 2013 15:42:59 +0000 Received: from [204.145.124.246] (helo=wrigleys.postgresql.org) by mahout.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UZk2a-0007ir-Qv for pgsql-bugs@postgresql.org; Tue, 07 May 2013 15:42:57 +0000 Received: from www-data by wrigleys.postgresql.org with local (Exim 4.72) (envelope-from ) id 1UZk2V-0005oP-Eh for pgsql-bugs@postgresql.org; Tue, 07 May 2013 15:42:51 +0000 Date: Tue, 07 May 2013 15:42:51 +0000 Message-Id: Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #8139: initdb: Misleading error message when current user not in /etc/passwd To: pgsql-bugs@postgresql.org From: nicolas@marchildon.net 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 The following bug has been logged on the website: Bug reference: 8139 Logged by: Nicolas Marchildon Email address: nicolas@marchildon.net PostgreSQL version: 9.2.4 Operating system: RHEL 6 Description:=20=20=20=20=20=20=20=20 Running initdb while logged in as a user that has no entry in /etc/passwd, which happens when authenticating with Kerberos, and missing sssd-client prints a misleading error message: "initdb: could not obtain information about current user: Success" The misleading part is the "Success". This comes from errno: pw =3D 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=20 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= =20 the call. First, initdb's get_id function does not set errno to zero, which is a bug. Second, when the return value is NULL, it should only print strerror(errno) when errno !=3D 0. --=20 Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs