Re: BUG #8139: initdb: Misleading error message when current user not in /etc/passwd

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Christoph Berg <cb(at)df7cb(dot)de>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, nicolas(at)marchildon(dot)net, Bugs for PostgreSQL <pgsql-bugs(at)postgresql(dot)org>, David Fetter <david(at)fetter(dot)org>
Subject: Re: BUG #8139: initdb: Misleading error message when current user not in /etc/passwd
Date: 2014-03-28 16:55:12
Message-ID: 20140328165512.GC18523@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Fri, Mar 28, 2014 at 10:33:48AM -0400, Bruce Momjian wrote:
> On Fri, Mar 28, 2014 at 10:31:06AM -0400, Tom Lane wrote:
> > Christoph Berg <cb(at)df7cb(dot)de> writes:
> > > the quoted code bit above in src/backend/libpq/auth.c is utterly
> > > broken: for peer authentication, it uses get_user_name(), which yields
> > > the *server* user name, not the client's. For that reason, peer
> > > authentication in 9.4devel is broken - you can't log in with your user
> > > name, but you can just say -U postgres (or what the initdb user was),
> > > and it will let you in.
> >
> > > The attached patch reverts the src/backend/libpq/auth.c portion of
> > > 613c6d26bd42dd8c2dd0664315be9551475b8864 and fixes peer auth.
> >
> > Applied, thanks!
>
> I guess I should have said I was working on an updated patch. I will
> merge my changes in.

I have applied the attached patch to make the code more closely match
what is done in src/common/username.c, particularly to display the errno
string on failure.

Christoph, thanks so much for finding this error now, rather than later.

I looked over the original patch that introduced this bug and
auth_peer() is the only place where we were passing in a user id, rather
than passing geteuid() directly to getpwuid, e.g.:

getpwuid(geteuid())

I think we are good now. My apologies for introducing this bug.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ Everyone has their own god. +

Attachment Content-Type Size
peer.diff text/x-diff 1.6 KB

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Jeff Janes 2014-03-28 17:39:52 Re: BUG #9756: Inconsistent database after OS restart
Previous Message Alvaro Herrera 2014-03-28 15:39:19 Re: BUG #9749: ERROR: unexpected classid 3600