From: Peter J. Holzer <hjp-pgsql@hjp.at>
To: pgsql-general@lists.postgresql.org
Subject: Re: How do I create a Backup Operator account ?
Date: Wed, 31 Jul 2019 22:25:58 +0200
Message-ID: <20190731202558.GA16749@hjp.at> (raw)
In-Reply-To: <CAKoxK+5U8569beRbFVeVfur6dtG66QMZCrsh+43ya9yE9qjCoQ@mail.gmail.com>
References: <CALrcA6=BD-+7tq=rDELRGtfWaStk2YznFMQb_tAdvZVcs6NBWQ@mail.gmail.com>
<CAKoxK+4KtWSPH+LNqnsFFddyynjkjud4ZFh0QS2dhDJmU7bMrw@mail.gmail.com>
<1d1008e3-d2bd-60ee-70ec-27ac54b164d1@gmail.com>
<CAKoxK+4xE=RoWT1e3Xug6U0vHegEGXbwEXFxrDRd5JvgaxssyQ@mail.gmail.com>
<CALrcA6=Bmo5mXYAyavKe1aEmzLsaAaXLQXPLGW1Dwi0ODBPsUA@mail.gmail.com>
<CAKoxK+5U8569beRbFVeVfur6dtG66QMZCrsh+43ya9yE9qjCoQ@mail.gmail.com>
On 2019-07-31 07:48:36 +0200, Luca Ferrari wrote:
> On Wed, Jul 31, 2019 at 2:48 AM Marcos Aurelio Nobre
> <marconobre@gmail.com> wrote:
> > But I don't know how to implement this on Linux, nor how to write this entry in the pg_hba.conf file.
>
> I would start with an entry in pg_hba.conf like the following:
>
> host all pg_backup_username localhost md5
>
> or
>
> host all pg_backup_username localhost md5
>
>
> The problem then comes on how to prevent the operating system user to
> run psql.
This problem can be solved by not granting anyone shell access as that
user. It is only used as a target for sudo, and sudo is configured to
run only pg_dump and pg_restore as that user (plus maybe other programs
to list available backups, review logs, remove old backups, ...)
A web interface might be used as an alternative to sudo.
> Even something like the following (untested) in /etc/sudoers will NOT
> prevent the user to access the database:
>
>
> User_Alias PGBACKUPUSERS = pg_backup_username
> Cmd_Alias PGBACKUP = /usr/local/bin/pg_dump,
> /usr/local/bin/pg_restore, ! /usr/local/bin/psql
> PGBACKUPUSERS backup_host = PGBACKUP
This is the wrong way around. It should be something like
alice, bob = (pg_backup_username) /usr/local/bin/pg_dump
(Apologies if I didn't get the syntax right. Slogging through the sudoes
manual reminded me why I wrote xssd 15 years ago).
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
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-general@postgresql.org
Cc: hjp-pgsql@hjp.at
Subject: Re: How do I create a Backup Operator account ?
In-Reply-To: <20190731202558.GA16749@hjp.at>
References: <CALrcA6=BD-+7tq=rDELRGtfWaStk2YznFMQb_tAdvZVcs6NBWQ@mail.gmail.com> <CAKoxK+4KtWSPH+LNqnsFFddyynjkjud4ZFh0QS2dhDJmU7bMrw@mail.gmail.com> <1d1008e3-d2bd-60ee-70ec-27ac54b164d1@gmail.com> <CAKoxK+4xE=RoWT1e3Xug6U0vHegEGXbwEXFxrDRd5JvgaxssyQ@mail.gmail.com> <CALrcA6=Bmo5mXYAyavKe1aEmzLsaAaXLQXPLGW1Dwi0ODBPsUA@mail.gmail.com> <CAKoxK+5U8569beRbFVeVfur6dtG66QMZCrsh+43ya9yE9qjCoQ@mail.gmail.com> <20190731202558.GA16749@hjp.at>
* 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