Aw: Re:  BUG #17647: 12.12 package has difference on ubuntu 18.04 - Mailing list pgsql-bugs

From Mike Fröhner
Subject Aw: Re:  BUG #17647: 12.12 package has difference on ubuntu 18.04
Date
Msg-id trinity-442a796d-9e1a-4845-b6b5-197fad011c08-1666116814878@3c-app-gmx-bap13
Whole thread Raw
In response to Re:  BUG #17647: 12.12 package has difference on ubuntu 18.04  (Julien Rouhaud <rjuju123@gmail.com>)
Responses Re: Aw: Re:  BUG #17647: 12.12 package has difference on ubuntu 18.04
List pgsql-bugs
Gesendet: Dienstag, 18. Oktober 2022 um 15:25 Uhr
Von: "Julien Rouhaud" <rjuju123@gmail.com>
An: "Mike Fröhner" <mikefroehner@gmx.de>
Cc: pgsql-bugs@lists.postgresql.org
Betreff: Re:  BUG #17647: 12.12 package has difference on ubuntu 18.04
On Tue, Oct 18, 2022 at 08:44:15PM +0800, Julien Rouhaud wrote:

>> 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[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.

Sorry about HTML, I am not used to mailing-lists anymore. :(

I have verified that your suggestion works (with added -i flag for sudo):
# /usr/bin/sudo -iu postgres psql -U my_username -h 127.0.0.1 database_name -c "CREATE TABLE foo1 (foo1 char);"
CREATE TABLE

I have also tested the following command successfully (using su instead of sudo):
# su postgres -c 'psql -U my_username -h 127.0.0.1 database_name -c "CREATE TABLE foo2 (foo2 char);"'
CREATE TABLE

But to ensure we understand correctly - I am not talking about pg14 or pg15. We have noticed the changed behavior ONLY
whileusing postgresql-12 package on Ubuntu 18.04 with libpq5 upgraded from 14.5-1.pgdg18.04+1 to 15.0-1.pgdg18.04+1 and
postgresql-client-common+ postgresql-common upgraded from 243.pgdg18.04+1 to 244.pgdg18.04+1. With the previous
versionsof the packages, the mentioned command (without -i flag) works on all tested Ubuntu (16-22.04). With the
upgradedpackages we have to add the -i flag to make it work. The used version of postgresql-12 is always the same:
12.12-1.pgdg18.04+1for Ubuntu 18.04 and 12.12-1.pgdg20.04+1 for Ubuntu 20.04. 

We also made a diff of `dpkg -l`-output (We have daily snapshots of the mirrored repository, so we can switch between
differentstates). The diff only showed the 3 mentioned upgraded packages, even packages from Ubuntu repository haven't
beenupgraded.  

For now I am fine with adjusted command in our testing suite. But it is still strange the same command works on all
versionsof Ubuntu LTS but not on Ubuntu 18.04. I am not sure if there are differences between the compiled packages of
18.04and 2[02].04 (different flags for compiling, ...) or if they just have different dependencies (which would be
reasonablefor me). Their versions indicate they should be compiled from the same code. 

If you don't want to investigate this strange behavior anymore I am fine.

regards
Mike




pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #17650: For the sixth time, the clipping function in the 120 partition table planning stage fails
Next
From: Tom Lane
Date:
Subject: Re: Aw: Re:  BUG #17647: 12.12 package has difference on ubuntu 18.04