Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hsvAm-0004md-79 for pgsql-general@arkaria.postgresql.org; Wed, 31 Jul 2019 20:26:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hsvAk-0004Qh-P9 for pgsql-general@arkaria.postgresql.org; Wed, 31 Jul 2019 20:26:06 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hsvAj-0004QZ-Sv for pgsql-general@lists.postgresql.org; Wed, 31 Jul 2019 20:26:05 +0000 Received: from mail.hjp.at ([212.17.106.138] helo=rorschach.hjp.at) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hsvAg-0007HO-8s for pgsql-general@lists.postgresql.org; Wed, 31 Jul 2019 20:26:05 +0000 Received: by rorschach.hjp.at (Postfix, from userid 1000) id 901A22F17; Wed, 31 Jul 2019 22:25:58 +0200 (CEST) Date: Wed, 31 Jul 2019 22:25:58 +0200 From: "Peter J. Holzer" To: pgsql-general@lists.postgresql.org Subject: Re: How do I create a Backup Operator account ? Message-ID: <20190731202558.GA16749@hjp.at> References: <1d1008e3-d2bd-60ee-70ec-27ac54b164d1@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="sm4nu43k4a2Rpi4c" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --sm4nu43k4a2Rpi4c Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2019-07-31 07:48:36 +0200, Luca Ferrari wrote: > On Wed, Jul 31, 2019 at 2:48 AM Marcos Aurelio Nobre > wrote: > > But I don't know how to implement this on Linux, nor how to write this = entry in the pg_hba.conf file. >=20 > I would start with an entry in pg_hba.conf like the following: >=20 > host all pg_backup_username localhost md5 >=20 > or >=20 > host all pg_backup_username localhost md5 >=20 >=20 > 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: >=20 >=20 > User_Alias PGBACKUPUSERS =3D pg_backup_username > Cmd_Alias PGBACKUP =3D /usr/local/bin/pg_dump, > /usr/local/bin/pg_restore, ! /usr/local/bin/psql > PGBACKUPUSERS backup_host =3D PGBACKUP This is the wrong way around. It should be something like alice, bob =3D (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 --=20 _ | 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 --sm4nu43k4a2Rpi4c Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEETtJbRjyPwVTYGJ5k8g5IURL+KF0FAl1B+VEACgkQ8g5IURL+ KF1gNg/+IrzUrpbtb081ELvLefqlPgixcH6uzeVu0hwrSRJGdF1fQDR3Z8gZdCuK UGfp09lfLexOJoNJy86C93WK6QtCeEYIoeTi/qD2E9/8YEgu33As11A58193LiZn THB0niAY1LD++8SUX24kC+ho7nz7x86BhSNuLS/iBoYbeZXLmlaOTuXsV8HWleYW wuNRPWmeTSBdmebhoMTO9VYVtu4Hshm35EG3/p0BOQmQfqfy8ElcRdy7jLrKr1Dz TgbY57ILtM5Tseu3ZYuvCwCftHPJ0NMzLN+BEFLMH00G1DVDlVD3yG9G6tZqJBy/ yr5LK7UNWLVeHGW/QWZDNPuMipVayuYEhD0NFZ4ctlZyUpQU4ABWn/kNcph+ddvQ kbrN/xZmbJD/qJEojVBIXAgTGLfNMsL94GKz47Kx3/PqdYKyahYsw6r2xyvNGDXP 13HV+IXkURkG81hX+iTcl9Ifg4atpb1KY80honxb4IScp0vUw21IekskzP6dWk09 kJnyolGqePsnCFopHqrIplUidhop9qUc9d5nzBG/FZRs/rKl0vE7Wo1I/x2lUaJg PXW00GYvh/I6lM78Vga0ZiBcmJfQ409AKemWt7ixBxkrj8wZmY85kQ9VPRe+iqVd qndvOxoXjzd5KvD39ZjKDel6tgPwqmAXtWVHCKM+1HKDuSetjK4= =kZ0d -----END PGP SIGNATURE----- --sm4nu43k4a2Rpi4c--