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 1izsru-0000fU-IE for pgsql-committers@arkaria.postgresql.org; Fri, 07 Feb 2020 01:55:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1izsrt-0002G5-Dt for pgsql-committers@arkaria.postgresql.org; Fri, 07 Feb 2020 01:55:41 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1izsrr-0002Fy-Ke for pgsql-committers@lists.postgresql.org; Fri, 07 Feb 2020 01:55:41 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1izsro-0001G8-Fk for pgsql-committers@lists.postgresql.org; Fri, 07 Feb 2020 01:55:38 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 60356221FB; Thu, 6 Feb 2020 20:55:35 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 06 Feb 2020 20:55:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm3; bh=L9UvsBc70y1R53EgB5WeJCGb7Yp CiSn3JvpBSq5i3C0=; b=HUxi+EShqJT4jAebm4I2EUL93UPz9iOARTgVQXTbqvf Yt22XlUudnCR9zrNC9/+COLVgUK/44AKiHDPCba1ZmDJ/AyxZNaVX1l6593X/Gpw 2zpDVQj5VFhWRkjT+XdQTGu7dSzH5Jm+5VOxOpd98vj/gYKmWCFh1vRp7e1llqjL PtdlAG3ljn/FQDh0uTmEe43H7iWKQVPBSc1zYDlmdgFxGYccSK4UuNTibJJ9Axd3 5vCSOZ/PxEwScQMMjnvy1iA1wvmqG75V01Os3YvULq4994begPFwiioHtsTrqKwp OXFzks5CqWhkwkJ+id6qOY0lr64gCcNhdxGVH92RKgA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=L9UvsB c70y1R53EgB5WeJCGb7YpCiSn3JvpBSq5i3C0=; b=shnbX99aa2+l4rS6nCdmhO 1NSuzz18re++Kp+X5iG/3qoUuuB/KutNhaESe/kWECDMm2jolCRYploUOmHj5wfV pYJiPflmBq0a0V75FtRwUyOE4uHdsq3elhuuilYIBQ9zlZkEsvijz7+x2V8bsFGS f90vKFLdFOK6heKXelp12h7I2OLyqHs9wo6VwdoWI+F0Ja7td3MHlOWn9Gp+9ao/ uzULYu8pH2PCJYWDAWlv9NodOKamv/S9aWcLtlbTGQh476Khl6O5tAmjL63W6Vsg 1W5Z9MYxG6M0E6z+Ww4INPvWa5ROZrb0JK8kjHKPaxUdgtQja5JbGHU2ZABWv8eA == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedrheeggdegudcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfg hrlhcuvffnffculddvfedmnecujfgurhepfffhvffukfhfgggtuggjsehgtderredttddv necuhfhrohhmpefoihgthhgrvghlucfrrghquhhivghruceomhhitghhrggvlhesphgrqh huihgvrhdrgiihiieqnecuffhomhgrihhnpehgnhhurdhorhhgnecukfhppeduudekrddv gedurddvhedurddufeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrih hlfhhrohhmpehmihgthhgrvghlsehprghquhhivghrrdighiii X-ME-Proxy: Received: from paquier.xyz (mp76f1fb0d.ap.nuro.jp [118.241.251.13]) by mail.messagingengine.com (Postfix) with ESMTPA id A4995328005A; Thu, 6 Feb 2020 20:55:33 -0500 (EST) Date: Fri, 7 Feb 2020 10:55:30 +0900 From: Michael Paquier To: Stephen Frost Cc: Magnus Hagander , pgsql-committers Subject: Re: pgsql: Prevent running pg_basebackup as root Message-ID: <20200207015530.GP23913@paquier.xyz> References: <20200205172259.GW3195@tamriel.snowman.net> <20200206070417.GJ23913@paquier.xyz> <20200206144407.GF3195@tamriel.snowman.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="/7+LvQqw8N5lf/3J" Content-Disposition: inline In-Reply-To: <20200206144407.GF3195@tamriel.snowman.net> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --/7+LvQqw8N5lf/3J Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Feb 06, 2020 at 09:44:07AM -0500, Stephen Frost wrote: > * Magnus Hagander (magnus@hagander.net) wrote: >> On Thu, Feb 6, 2020 at 8:04 AM Michael Paquier wro= te: >>> 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. >=20 > 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. Hmm. I don't think that you are completely correct here either as it depends on if the OS user "postgres" exists or not. As mentioned in https://www.gnu.org/software/tar/manual/tar.html#SEC138, if the user name cannot be found in /etc/passwd, then tar switches to the user ID (if one does not have any user or group named "postgres", then the files are untar'ed with the same user and group as the one running the cluster and that's to the UID and GID set by tarCreateHeader, as you say). I think that it is a problem to not have more documentation on the matter (now there is just a small mention in the base backup restore about being sure to have the proper permissions). And it may be interesting to add into pg_basebackup options to enforce the user and/or group similarly to what tar does with --owner and --group? >> 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... >=20 > 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. OK, done that part as of dcddc3f. -- Michael --/7+LvQqw8N5lf/3J Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAl48w5IACgkQnvQgOdby QH0tOw//cfWZQwLCZjGMzbP8i8rq864YniHlcUDP3krJZkGD6KT73A4Qon1qdNiC h02h42JQfgctj9nJUUITc6Sqa10wkwLtsT59XCwNm6As708JJhBbNnxtCgaTNZxV 3C6N6eTuG5FAogxhXsHBcJoQHxACL4HX/Cryau9SF2u7mxjQocz+BYVysMcUIuNL /6qjvtSpC+1RB7/t+10KEj0uhqXTQJ1jVCh1ZsNaozaWHwXOCQtYnPfFOLnWcYGH DauiT2KAKBHOy6B6l61xw1yLFA2NH6mPN0Ua4d47e3ZdXpam0RU7XwnhBK0i5DDI pnLO20zXnAEwCDk5z/Qs7ffOtGgtD4w8qAWpp4nx7GAKFsu+qR2UPb7aQgpJDCMB a/fRZSEYWIbrP1Y4i1k5tuOJprEl9NMTZNIEdrTpnCnAKhKEjVeiUEaj5q9mlO7E p2WH8MdbvpS9ebE/NQKueSwIwHkmGK1rjEowq4rzrldq7EeUYcqTz3m78gcF0lmT nqRRlgrIfQpVvUk7z3NHsUWP1UArfkzCZpYQQS27x9NV5ESqgUqKMg/YlYyRLNG/ a9pqkSXr1LaFaVZ+Z+SZ6rSKG/C4G/bwb0EFcWtWZAFUnaQqbbnE7JcR3xYnnnCi JJnfQyav3Ur9EZcHXsMSu6X7ujW89Pg46JzETo5aTMsbb4pdZsA= =Ejbb -----END PGP SIGNATURE----- --/7+LvQqw8N5lf/3J--