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

From: Christoph Berg <cb(at)df7cb(dot)de>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, 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 10:41:54
Message-ID: 20140328104153.GB15310@msgid.df7cb.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Re: Bruce Momjian 2013-12-18 <20131218171628(dot)GA1690(at)momjian(dot)us>
> On Mon, Dec 9, 2013 at 07:47:34PM -0500, Bruce Momjian wrote:
> > On Mon, Dec 9, 2013 at 06:45:39PM -0300, Alvaro Herrera wrote:
> > > Bruce Momjian wrote:
> > >
> > > > return STATUS_ERROR;
> > > > }
> > > >
> > > > ! user_name = get_user_name(&errstr);
> > > > ! if (!user_name)
> > > > {
> > > > ! ereport(LOG, (errmsg("%s\n", errstr)));
> > > > ! pfree(errstr);
> > > > return STATUS_ERROR;
> > > > }
> > >
> > > The message is already translated by get_user_name, so I think this
> > > should use errmsg_internal() instead of errmsg(). Also, why do you add
> > > a newline?
> >
> > OK, done.
> >
> > > Not clear whether the new file should be in src/port or src/common.
> >
> > Agreed. It isn't designed to add missing OS functionality, but it is
> > mostly OS-specific code.
> >
> > Updated patch attached, with Tom's requested changes.
>
> Patch applied.

Hi,

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.

Christoph
--
cb(at)df7cb(dot)de | http://www.df7cb.de/

Attachment Content-Type Size
peer-auth-broken text/plain 1.4 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message digoal 2014-03-28 11:58:02 BUG #9759: whe extend some varchar cols to varchar(n) , index filenode disappear, and 58P01 ERROR
Previous Message digoal 2014-03-28 08:15:25 BUG #9757: Why reclaim index deleted pages need twice vacuum