pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Permissions on postgresql.conf, psql and patroni
5+ messages / 3 participants
[nested] [flat]

* Permissions on postgresql.conf, psql and patroni
@ 2019-09-09 10:58  Peter J. Holzer <hjp-pgsql@hjp.at>
  0 siblings, 2 replies; 5+ messages in thread

From: Peter J. Holzer @ 2019-09-09 10:58 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

Yesterday I "apt upgrade"d patroni (to version 1.6.0-1.pgdg18.04+1 from
http://apt.postgresql.org/pub/repos/apt bionic-pgdg/main).

Today I noticed that I couldn't invoke psql as an unprivileged user
anymore:

% psql
Error: Invalid data directory for cluster 11 main

Further investigation showed that the read permissions on
/etc/.../postgresql.conf were revoked at the time of the upgrade. Either
by a post-install script or maybe by patroni itself, when it started up
again.

This leads me to two questions:

1) Is there a reason to restrict read access to postgresql.conf to the
   user postgres? AFAIK this file doesn't normally contain sensitive data
   (unlike pg_hba.conf and pg_ident.conf which are restricted by default).

2) Why does psql need to read postgresql.conf, and more specifically,
   why does it care about the location of the data directory? It
   shouldn't access files directly, just talk to the server via the
   socket.

        hp

-- 
   _  | Peter J. Holzer    | we build much bigger, better disasters now
|_|_) |                    | because we have much more sophisticated
| |   | hjp@hjp.at         | management tools.
__/   | http://www.hjp.at/ | -- Ross Anderson <https://www.edge.org/;

Attachments:

  signature.asc (application/pgp-signature, 832B) download

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Permissions on postgresql.conf, psql and patroni
@ 2019-09-09 11:29  Daniel Verite <daniel@manitou-mail.org>
  parent: Peter J. Holzer <hjp-pgsql@hjp.at>
  1 sibling, 1 reply; 5+ messages in thread

From: Daniel Verite @ 2019-09-09 11:29 UTC (permalink / raw)
  To: Peter J. Holzer <hjp-pgsql@hjp.at>; +Cc: pgsql-general@lists.postgresql.org

	Peter J. Holzer wrote:

> 2) Why does psql need to read postgresql.conf, and more specifically,
>   why does it care about the location of the data directory? It
>   shouldn't access files directly, just talk to the server via the
>   socket.

It's not psql itself, it's pg_wrapper.

$ ls -l /usr/bin/psql
lrwxrwxrwx 1 root root 37 Aug  8 12:48 /usr/bin/psql ->
../share/postgresql-common/pg_wrapper

See http://manpages.ubuntu.com/manpages/bionic/man1/pg_wrapper.1.html


Best regards,
-- 
Daniel Vérité
PostgreSQL-powered mailer: http://www.manitou-mail.org
Twitter: @DanielVerite





^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Permissions on postgresql.conf, psql and patroni
@ 2019-09-09 14:03  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Peter J. Holzer <hjp-pgsql@hjp.at>
  1 sibling, 0 replies; 5+ messages in thread

From: Tom Lane @ 2019-09-09 14:03 UTC (permalink / raw)
  To: Peter J. Holzer <hjp-pgsql@hjp.at>; +Cc: pgsql-general@lists.postgresql.org

"Peter J. Holzer" <hjp-pgsql@hjp.at> writes:
> Yesterday I "apt upgrade"d patroni (to version 1.6.0-1.pgdg18.04+1 from
> http://apt.postgresql.org/pub/repos/apt bionic-pgdg/main).
> Today I noticed that I couldn't invoke psql as an unprivileged user
> anymore:
> % psql
> Error: Invalid data directory for cluster 11 main

FYI, there's no such error string in the core Postgres sources.
I imagine that it's coming from some wrapper script.

> 1) Is there a reason to restrict read access to postgresql.conf to the
>    user postgres?

Probably not, though it only matters if you keep that outside the
data directory.

> 2) Why does psql need to read postgresql.conf, and more specifically,
>    why does it care about the location of the data directory?

psql itself won't/doesn't.  I suspect you're dealing with a wrapper
that is trying to figure out which version of psql to invoke.

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Permissions on postgresql.conf, psql and patroni
@ 2019-09-09 17:15  Peter J. Holzer <hjp-pgsql@hjp.at>
  parent: Daniel Verite <daniel@manitou-mail.org>
  0 siblings, 1 reply; 5+ messages in thread

From: Peter J. Holzer @ 2019-09-09 17:15 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

On 2019-09-09 13:29:38 +0200, Daniel Verite wrote:
> 	Peter J. Holzer wrote:
> > 2) Why does psql need to read postgresql.conf, and more specifically,
> >   why does it care about the location of the data directory? It
> >   shouldn't access files directly, just talk to the server via the
> >   socket.
> 
> It's not psql itself, it's pg_wrapper.
> 
> $ ls -l /usr/bin/psql
> lrwxrwxrwx 1 root root 37 Aug  8 12:48 /usr/bin/psql ->
> ../share/postgresql-common/pg_wrapper
> 
> See http://manpages.ubuntu.com/manpages/bionic/man1/pg_wrapper.1.html

Ah, thanks.


On 2019-09-09 10:03:57 -0400, Tom Lane wrote:
> "Peter J. Holzer" <hjp-pgsql@hjp.at> writes:
> > Yesterday I "apt upgrade"d patroni (to version 1.6.0-1.pgdg18.04+1 from
> > http://apt.postgresql.org/pub/repos/apt bionic-pgdg/main).
> > Today I noticed that I couldn't invoke psql as an unprivileged user
> > anymore:
> > % psql
> > Error: Invalid data directory for cluster 11 main
> 
> FYI, there's no such error string in the core Postgres sources.
> I imagine that it's coming from some wrapper script.

Yep. Daniel shoved me into the right direction. The message is from
PgCommon.pm, used by pg_wrapper.

It's a good thing both packages are maintained by the same team. Saves
the discussion who's going to fix it :-).

        hp


-- 
   _  | Peter J. Holzer    | we build much bigger, better disasters now
|_|_) |                    | because we have much more sophisticated
| |   | hjp@hjp.at         | management tools.
__/   | http://www.hjp.at/ | -- Ross Anderson <https://www.edge.org/;

Attachments:

  signature.asc (application/pgp-signature, 832B) download

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Permissions on postgresql.conf, psql and patroni
@ 2019-09-09 18:43  Peter J. Holzer <hjp-pgsql@hjp.at>
  parent: Peter J. Holzer <hjp-pgsql@hjp.at>
  0 siblings, 0 replies; 5+ messages in thread

From: Peter J. Holzer @ 2019-09-09 18:43 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

On 2019-09-09 19:15:19 +0200, Peter J. Holzer wrote:
> On 2019-09-09 10:03:57 -0400, Tom Lane wrote:
> > "Peter J. Holzer" <hjp-pgsql@hjp.at> writes:
> > > Yesterday I "apt upgrade"d patroni (to version 1.6.0-1.pgdg18.04+1
> > > from http://apt.postgresql.org/pub/repos/apt bionic-pgdg/main).
> > > Today I noticed that I couldn't invoke psql as an unprivileged user
> > > anymore:
> > > % psql
> > > Error: Invalid data directory for cluster 11 main
> > 
> > FYI, there's no such error string in the core Postgres sources.
> > I imagine that it's coming from some wrapper script.
> 
> Yep. Daniel shoved me into the right direction. The message is from
> PgCommon.pm, used by pg_wrapper.
> 
> It's a good thing both packages are maintained by the same team. Saves
> the discussion who's going to fix it :-).

Since this issue is specific to the debian/ubuntu packages, I've opened
a ticket in redmine: https://redmine.postgresql.org/issues/4717 (as
suggested in the wiki).

        hp


-- 
   _  | Peter J. Holzer    | we build much bigger, better disasters now
|_|_) |                    | because we have much more sophisticated
| |   | hjp@hjp.at         | management tools.
__/   | http://www.hjp.at/ | -- Ross Anderson <https://www.edge.org/;

Attachments:

  signature.asc (application/pgp-signature, 832B) download

^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2019-09-09 18:43 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-09-09 10:58 Permissions on postgresql.conf, psql and patroni Peter J. Holzer <hjp-pgsql@hjp.at>
2019-09-09 11:29 ` Daniel Verite <daniel@manitou-mail.org>
2019-09-09 17:15   ` Peter J. Holzer <hjp-pgsql@hjp.at>
2019-09-09 18:43     ` Peter J. Holzer <hjp-pgsql@hjp.at>
2019-09-09 14:03 ` Tom Lane <tgl@sss.pgh.pa.us>

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