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 1iziO4-0007xO-Jt for pgsql-committers@arkaria.postgresql.org; Thu, 06 Feb 2020 14:44:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iziO1-0000b5-Ki for pgsql-committers@arkaria.postgresql.org; Thu, 06 Feb 2020 14:44:09 +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 1iziO1-0000ay-Cc for pgsql-committers@lists.postgresql.org; Thu, 06 Feb 2020 14:44:09 +0000 Received: from tamriel.snowman.net ([2001:470:e38f::11]) by magus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1iziNy-0008GR-43 for pgsql-committers@lists.postgresql.org; Thu, 06 Feb 2020 14:44:08 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id C92FE5F7A0; Thu, 6 Feb 2020 09:44:07 -0500 (EST) Date: Thu, 6 Feb 2020 09:44:07 -0500 From: Stephen Frost To: Magnus Hagander Cc: Michael Paquier , pgsql-committers Subject: Re: pgsql: Prevent running pg_basebackup as root Message-ID: <20200206144407.GF3195@tamriel.snowman.net> References: <20200205172259.GW3195@tamriel.snowman.net> <20200206070417.GJ23913@paquier.xyz> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="dQH07zyeeMyNByQ/" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --dQH07zyeeMyNByQ/ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Greetings, * Magnus Hagander (magnus@hagander.net) wrote: > On Thu, Feb 6, 2020 at 8:04 AM Michael Paquier wrot= e: > > > > On Wed, Feb 05, 2020 at 12:22:59PM -0500, Stephen Frost wrote: > > > In any case, sorry for not responding on this sooner (was traveling f= or > > > FOSDEM and such), but I'm not really convinced this is something we w= ant > > > and it certainly breaks at least somewhat reasonable use-cases when y= ou > > > think about using pg_basebackup with -Ft. In that vein, this change = is > > > kinda like saying "you can't run pg_dump as root".. > > > > It seems to me that this is entirely different than the case of > > pg_dump, as it is possible to restore a dump even as root, something > > that cannot happen with physical backups without an extra chmod -R. >=20 > I don't see how that's relevant? And yes, you can restore physical > backups this way too, if the userids match. (though see Stephens > comment about the username, but that's independent of this issue) Right. > And pg_basebackup is about taking backups, not restores :) Yes- one of the downsides of pg_basebackup is that it doesn't really do much for you when it comes to restores, in fact.. Something that will have to change if it starts doing incrementals of some kind. That's mostly orthogonal to this discussion though. > > You have a point with -Ft as untaring the tarballs from a base backup > > taken with pg_basebackup -Ft used by root generates files owned by the > > original user. -Fp enforces the files to be owned by the user taking > > the backup, which makes the most sense, so for consistency with the > > other tools preventing root to run pg_basebackup makes sense to me > > with -Fp. Any thoughts from others to restrict the tool with -Fp but > > not with -Ft? The argument of consistency mattered for me first for > > both formats. Erm- no, with -Ft + untar-as-root they get owned by "postgres", NOT the original user. That's what I was pointing out up-thread (since it seems to be confusing- and clearly not always well understood..) and it's an issue imv, but it's independent of this, so probably deserves its own thread if someone wants to do something about that. Having -Fp run-as-root result in the files being owned by root isn't good and I agree that's unfortunate and it would be good to fix it, but preventing pg_basebackup from ever being run as root isn't a good solution to that issue. > I think having -Fp and -Ft consistent is a lot more important than > being consistent with other tools that aren't really that closely > related. And it's already inconsistent against probably the most > related command, being pg_dump. Yeah, I agree on consistency here being important too, and that pg_dump is a closer command to be thinking about than initdb and friends. > So *very* strong objection to makeing -Fp and -Ft behave differently > in this regard. What we aren't consistent about today is what happens when you do: - Backup as root with -Ft - Untar results as root - Backup as root with -Fp and that really seems less than ideal, but I don't think the answer is "don't allow backing up as root". > I agree with Stephen that this seems to be misguided, and my vote is > to revert. I would've also objected had you given more than 2 days > warning before committing, and it happened to be during FOSDEM. I saw > the original email which clearly said it'd be in the March commitfest, > so I figured I'd have time... Yeah, I also agree with reverting this change. Even if we can come to something we all agree on, I'm pretty confident it's not going to be exactly this patch, so let's back it out for now and discuss it further on the -hackers thread. Thanks, Stephen --dQH07zyeeMyNByQ/ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJePCY3AAoJEO1sijiDR2RVaskP+wSTevxZV0pPQtyNsq7oTZw/ oFjmH/7EMJhGdfoxOAcq51yMsn1Vot2KjTeHmfDJ9F82LNuGEwGv1jAFzRNf3hM3 5fNzr46KDjdn4StVeAOu/z12yRdP0qOBkQYCXWOzRpXk9XOyPf9ulTVbBEM+2vE+ 1Qd0kvJN9m7QCtz4fL/zvVUHb4PPvqU9AHJ6svRagAOr0c/JHP8TfPHc8lQYXOw+ goC4aocac81MzJAy1lN2BlHYfoVT5tnpSz9aCEdH4eUgeqCIlMEqjCvtKG/DELu8 KgXyez+OwtiX1bqq0m2/3YjqxO1MNpYcYIx3v2HqbE34o5nB4nqUvwamu1iNsazu tINj2T1Y+yH+0UohKzuUUi7jDX7FllQHHTNafzxDbrvGYyi/dS3vNyN/IBKKeLSt 6vu9+RAxZVwcK6MVI6tJWtApF+xwiCQBICRXqfP7/BIKqT38pxi5fzNLS8I/MAum igCrHUSwlaCaSmXiPDzFZ0tpRuZXeDHalJkvuRjexFfyK3LrLwtw/LpysK6G3k81 ZQ23ybD5fESx4iYi8f7HcSz5JCw6m4xWiniVKSHHm/FsQYi5k2XmqFdZQ/FtvICP INo9Ba7PWeONKZ8PuMo04kjTCM66JOodCm1oDguCtKGp0zMIjvZszrDe34zvA/G8 8KTR3rqg7UiGvzBafE51 =hpj1 -----END PGP SIGNATURE----- --dQH07zyeeMyNByQ/--