pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Julien Rouhaud <rjuju123@gmail.com>
To: Mike Fröhner <mikefroehner@gmx.de>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re:  BUG #17647: 12.12 package has difference on ubuntu 18.04
Date: Tue, 18 Oct 2022 21:25:19 +0800
Message-ID: <20221018132519.tt3feryowdyhdvbn@jrouhaud> (raw)
In-Reply-To: <Y06fn/2t3y6cp5VQ@jrouhaud>
References: <17647-355ab16b3ab3c775@postgresql.org>
	<trinity-aee76dd0-5787-4adc-8c24-ce1a081277fa-1666081158225@msvc-mesg-gmx003>
	<Y06fn/2t3y6cp5VQ@jrouhaud>

On Tue, Oct 18, 2022 at 08:44:15PM +0800, Julien Rouhaud wrote:
> Hi,
> 
> On Tue, Oct 18, 2022 at 10:19:20AM +0200, Mike Fröhner wrote:
> > 
> > <html>
> >  <head>
> >   <meta name="viewport" content="width=device-width">
> >   <meta http-equiv="Content-Type" content="text/vnd.ui.insecure+html;charset=utf-8">
> >  </head>
> >  <body style="overflow-wrap:break-word; word-break: break-word;"><div class="mail_android_message" style="line-height: 1; padding: 0.5em">Hello<br/><br/>I have made some deeper investigation:<br/><br/>Steps to reproduce:<br/><br/>```<br/>docker pull ubuntu:18.04 &amp;&amp; docker run -it --rm ubuntu:18.04 bash<br/>## or<br/>docker pull ubuntu:20.04 &amp;&amp; docker run -it --rm ubuntu:20.04 bash<br/>## or<br/>docker pull ubuntu:22.04 &amp;&amp; docker run -it --rm ubuntu:22.04 bash<br/><br/><br/>apt-get update<br/>apt-get install -y vim strace less curl ca-certificates gnupg sudo lsb-release<br/><br/>curl <a href="https://www.postgresql.org/media/keys/ACCC4CF8.asc">https://www.postgresql.org/media/keys/ACC...; | gpg --dearmor | sudo tee /etc/apt/<a href="http://trusted.gpg">trusted.gpg</a>.d/<a href="http://apt.postgresql.org.gpg">apt.postgresql.org.gpg</a; &gt;/dev/null<br/><br/>sh -c &#39;echo &quot;deb <a href="http://apt.postgresql.org/pub/repos/apt">http://apt.postgresql.org/pub/repos/apt</a; $(lsb_release -cs)-pgdg main&quot; &gt; /etc/apt/<a href="http://sources.list">sources.list</a>.d/<a href="http://pgdg.list">pgdg.list</a>&#39;<br/>apt-get update<br/>apt-get install -y postgresql-12<br/><br/>pg_ctlcluster 12 main start<br/><br/>sudo -u postgres -i<br/>psql<br/>CREATE DATABASE database_name;<br/>CREATE USER my_username WITH PASSWORD &#39;my_password&#39;;<br/>GRANT ALL PRIVILEGES ON DATABASE &quot;database_name&quot; to my_username;<br/>exit<br/><br/>echo &#39;*:*:*:my_username:my_password&#39; &gt; .pgpass<br/>chmod 0600 .pgpass<br/>exit<br/><br/>##<br/>## this does not work for ubuntu 18.04 but for ubuntu 20.04/22.04<br/>##<br/>/usr/bin/sudo -u postgres psql -U my_username -h <a href="http://127.0.0.1">127.0.0.1</a; database_name -c &quot;CREATE TABLE foo (foo char);&quot;<br/><br/>##<br/>## this works for all<br/>##<br/>sudo -u postgres -i<br/>psql -U my_username -h <a href="http://127.0.0.1">127.0.0.1</a; database_name -c &quot;CREATE TABLE foo (foo char);&quot;<br/>```<br/><br/>We have narrowed it down to three packages which have been upgraded on ubuntu 18.04 between working and broken state:<br/>- `libpq5` upgraded from `14.5-1.pgdg18.04+1` to `15.0-1.pgdg18.04+1`<br/>- `postgresql-client-common` and `postgresql-common` from `243.pgdg18.04+1` to `244.pgdg18.04+1`<br/><br/>None other packages have been upgraded (incl. ubuntu repo packages)!<br/><br/>For me it does look like a bug with in psql client package.<br/><br/>regards<br/>Mike<br/><br/>--<br/>Diese Nachricht wurde von meinem Android Mobiltelefon mit GMX Mail gesendet.</div><div class="mail_android_quote" style="line-height: 1; padding: 0.3em"><html><body>Am 17.10.22, 16:19 schrieb PG Bug reporting form &lt;noreply@postgresql.org&gt;:</body></html><blockquote class="gmail_quote" style="margin: 0.8ex 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
> 
> You should configure your MUA to send plaintext too and not only html, as some
> people can't (and don't want to) read html-only emails.  After reading it on
> the html archives, I'm surprised to see that this would work at all on other
> ubuntu versions, and it doesn't look like a bug in our code.  sudo without -i
> will look for the .pgpass in the wrong place:
> 
> # sudo -u postgres bash -c "echo \$HOME"
> /root
> 
> # sudo -iu postgres bash -c "echo \$HOME"
> /var/lib/postgresql
> 
> Do you get a different behavior for those commands on other ubuntu versions?

Scratch that, after checking the code I can see that up to version 14 we were
only relying on getpwuid or getpwuid_r (which would work with or without -i),
but starting with pg15 we first look at the $HOME variable which indeed is
problematic.

This was introduced in 376ce3e404b, per request at
https://www.postgresql.org/message-id/1634252654444.90107@mit.edu:

> According to getpwnam(3):
>
>   An application that wants to determine its user's home directory
>   should inspect the value of HOME (rather than the value
>   getpwuid(getuid())->pw_dir) since this allows the user to modify
>   their notion of "the home directory" during a login session.

So there is indeed a behavior change, but it's wanted and documented in the
release notes.





view thread (2+ messages)

Message-ID: <20221018132519.tt3feryowdyhdvbn@jrouhaud>
Permalink:  ../20221018132519.tt3feryowdyhdvbn@jrouhaud/
Also on:    postgresql.org/message-id/20221018132519.tt3feryowdyhdvbn@jrouhaud

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: rjuju123@gmail.com, mikefroehner@gmx.de
  Subject: Re: BUG #17647: 12.12 package has difference on ubuntu 18.04
  In-Reply-To: <20221018132519.tt3feryowdyhdvbn@jrouhaud>
  References: <17647-355ab16b3ab3c775@postgresql.org> <trinity-aee76dd0-5787-4adc-8c24-ce1a081277fa-1666081158225@msvc-mesg-gmx003> <Y06fn/2t3y6cp5VQ@jrouhaud> <20221018132519.tt3feryowdyhdvbn@jrouhaud>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox