Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1okmb4-0006YJ-BU for pgsql-bugs@arkaria.postgresql.org; Tue, 18 Oct 2022 13:25:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1okmb3-0006BZ-7r for pgsql-bugs@arkaria.postgresql.org; Tue, 18 Oct 2022 13:25:29 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1okmb2-0006BQ-Uo for pgsql-bugs@lists.postgresql.org; Tue, 18 Oct 2022 13:25:28 +0000 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1okmb0-00019A-5Q for pgsql-bugs@lists.postgresql.org; Tue, 18 Oct 2022 13:25:28 +0000 Received: by mail-pg1-x52e.google.com with SMTP id 128so13313745pga.1 for ; Tue, 18 Oct 2022 06:25:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=HJZDYM90/2OY188aWVrd71H5E6IkOItvM4V7VbwkyZM=; b=g5+lbEHttxXjpDoVQf4+ytzNHlJPBwWzRFIbqg63vGSO/AYub2EjUlaWPq/MQ6j1qO i+s5hQ8C3SaC8j41lrok1OfPZEBvA7QjiIFJOJiASBpMnwiSXjvvkw1aXbpil+iCEs9w +mj9qLhGKM61XnxWOFVmP6as1nI0NawTn0/cbdLmelSIxfnZ9L/9Qz58mI9sstWCEFHZ 3VTwga8NfU9gTSXrq6Q4P/SPXuu8zOWyLqSSPN69BMdzejRXgu9WrXa5cgAWXOTBftpc PeJqPRkLJ9E8VLyDZN+Vz/fzTu05PRgUmq89XjHNwPl4gfkHx8XkIrwYzYhH8nQcpPKT bcRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=HJZDYM90/2OY188aWVrd71H5E6IkOItvM4V7VbwkyZM=; b=D/0cV/PkLxZMAvbp+r6AL79J6r7mt0GE1E0JswZYJadfxsYpQhIp+kqCMuiVyVJ9z+ zbSqjQkeaZ21fUiNRnQv+jiS0oMHVNslRmmv7N8Ybnrt0O+gEw3kwuo+l3ejlk6mv0aE 0BpB7ZyL1pLTrsd5AZ8z9+RtwJb5DJMJinH3B3iP7VK2f3EVAuWt1V+yAAoBmp1ucjjo Dg0RhVjv1OltAS8EFx/LgW/50YrReQi25TjikyQFmU7vduY55ekALQOA9lIQzx9hxEcG X9y48RpRbJLyIo5QmHlSw+Xwbrf573FYCM7uTaHUl5nQWsiLbwDJEnhlOShVl3iq+q/t ErOg== X-Gm-Message-State: ACrzQf2v+/nSf+u4V9XT6tzBbrc6wklS3S9jJFlWib52rvz+HpQi8PKk h2ZHn+cr0p/8Bc3ILlnB0XA= X-Google-Smtp-Source: AMsMyM6BTG+LB+rxtrfKiEi3bayBftcBZukB+9zK8Y07C5H+tOS77rMDcHY+taVQWcHCAUAbocLLMQ== X-Received: by 2002:a05:6a00:1306:b0:555:6d3f:11ed with SMTP id j6-20020a056a00130600b005556d3f11edmr3199096pfu.55.1666099524063; Tue, 18 Oct 2022 06:25:24 -0700 (PDT) Received: from jrouhaud (2001-b011-1006-1ebe-d832-ef37-671f-0ce2.dynamic-ip6.hinet.net. [2001:b011:1006:1ebe:d832:ef37:671f:ce2]) by smtp.gmail.com with ESMTPSA id k3-20020a635a43000000b00459a36795cbsm7991535pgm.42.2022.10.18.06.25.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Oct 2022 06:25:23 -0700 (PDT) Date: Tue, 18 Oct 2022 21:25:19 +0800 From: Julien Rouhaud To: Mike =?utf-8?Q?Fr=C3=B6hner?= Cc: pgsql-bugs@lists.postgresql.org Subject: Re: =?utf-8?Q?=C2=A0BU?= =?utf-8?Q?G?= #17647: 12.12 package has difference on ubuntu 18.04 Message-ID: <20221018132519.tt3feryowdyhdvbn@jrouhaud> References: <17647-355ab16b3ab3c775@postgresql.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Oct 18, 2022 at 08:44:15PM +0800, Julien Rouhaud wrote: > Hi, >=20 > On Tue, Oct 18, 2022 at 10:19:20AM +0200, Mike Fr=F6hner wrote: > >=20 > > > > > > > > > > > > He= llo

I have made some deeper investigation:

Steps to repro= duce:

```
docker pull ubuntu:18.04 && docker run -it -= -rm ubuntu:18.04 bash
## or
docker pull ubuntu:20.04 && doc= ker run -it --rm ubuntu:20.04 bash
## or
docker pull ubuntu:22.04 &= amp;& docker run -it --rm ubuntu:22.04 bash


apt-get updat= e
apt-get install -y vim strace less curl ca-certificates gnupg sudo ls= b-release

curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --= dearmor | sudo tee /etc/apt/trusted.gpg.= d/apt.postgresql.org.gpg >= /dev/null

sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_rel= ease -cs)-pgdg main" > /etc/apt/sou= rces.list.d/pgdg.list'
apt-get= update
apt-get install -y postgresql-12

pg_ctlcluster 12 main= start

sudo -u postgres -i
psql
CREATE DATABASE database_n= ame;
CREATE USER my_username WITH PASSWORD 'my_password';
G= RANT ALL PRIVILEGES ON DATABASE "database_name" to my_username;exit

echo '*:*:*:my_username:my_password' > .pgpass<= br/>chmod 0600 .pgpass
exit

##
## this does not work for u= buntu 18.04 but for ubuntu 20.04/22.04
##
/usr/bin/sudo -u postgres= psql -U my_username -h 127.0.0.1 database= _name -c "CREATE TABLE foo (foo char);"

##
## this w= orks for all
##
sudo -u postgres -i
psql -U my_username -h 127.0.0.1 database_name -c "CREATE TABLE = foo (foo char);"
```

We have narrowed it down to three pa= ckages which have been upgraded on ubuntu 18.04 between working and broken = state:
- `libpq5` upgraded from `14.5-1.pgdg18.04+1` to `15.0-1.pgdg18.= 04+1`
- `postgresql-client-common` and `postgresql-common` from `243.pg= dg18.04+1` to `244.pgdg18.04+1`

None other packages have been upgr= aded (incl. ubuntu repo packages)!

For me it does look like a bug = with in psql client package.

regards
Mike

--
Dies= e Nachricht wurde von meinem Android Mobiltelefon mit GMX Mail gesendet.
Am 17.10.22, 16:19 schrieb PG Bug reporting form <noreply= @postgresql.org>:
>=20 > 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 ot= her > ubuntu versions, and it doesn't look like a bug in our code. sudo withou= t -i > will look for the .pgpass in the wrong place: >=20 > # sudo -u postgres bash -c "echo \$HOME" > /root >=20 > # sudo -iu postgres bash -c "echo \$HOME" > /var/lib/postgresql >=20 > Do you get a different behavior for those commands on other ubuntu versio= ns? Scratch that, after checking the code I can see that up to version 14 we we= re 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.