From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from atuin.qyliss.net (localhost [IPv6:::1]) by atuin.qyliss.net (Postfix) with ESMTP id 81E8FF414; Sat, 25 Oct 2025 11:47:30 +0000 (UTC) Received: by atuin.qyliss.net (Postfix, from userid 993) id 2C744F3F7; Sat, 25 Oct 2025 11:47:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on atuin.qyliss.net X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DMARC_MISSING,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=4.0.1 Received: from fhigh-a3-smtp.messagingengine.com (fhigh-a3-smtp.messagingengine.com [103.168.172.154]) by atuin.qyliss.net (Postfix) with ESMTPS id 2CF5DF3F5 for ; Sat, 25 Oct 2025 11:47:26 +0000 (UTC) Received: from phl-compute-12.internal (phl-compute-12.internal [10.202.2.52]) by mailfhigh.phl.internal (Postfix) with ESMTP id 321B2140018F; Sat, 25 Oct 2025 07:47:25 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-12.internal (MEProxy); Sat, 25 Oct 2025 07:47:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alyssa.is; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1761392845; x=1761479245; bh=mitVO7nmX6 u+SaugUI91NxUfB8g40gdA6ajJ5Hm844s=; b=htKHZMtib9RmoDzFiyOxh9m1zi H5zDLQErBN93Ej6p0oDa9CQHJ1HnuYm0zqfiWqLgjOem5jmFqdlMwbX9rtYUk3cH 46qC98qUVIzK/2bBhyu2wSUWBzeojYqaQUaZTHJ1iJHVvwOqFbvBeyDYwpSP66iG 14/qO/B54/lk8Jy0oEYdZuBLn+ydEvXDaeapM6XVAV4oy83C4QDvmSpNBNobOW3O JlfoJ2f3VxTAddlOE7svNda55TH72HMRmOFq8TtMcusLG090eWfp7kuS0Su9D/a1 BlQgnR9yhHrTaSdm9/MpI2Pw0GyLw2HFap+hgEujGf650oDHFkxcTQRbrQCg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1761392845; x=1761479245; bh=mitVO7nmX6u+SaugUI91NxUfB8g40gdA6aj J5Hm844s=; b=CuMavg4JydWCsjymqQbs1c16xwr7nvhFojErG3dX44b/7jSLkPd EGBIZTPKyI7XwYd1LgvXs9aYNwXvohltubLWZyaAcWQia8VRLv5BGvujV0KAtc1/ 0Baaxs2r9UGJfj334Duch9JKJpJzoHKZYXfSc2JL0Zv2z6T9WIT6bQSb937U/tOB LXUFOVxa4zBaJ8hPGnNodAwzxuahYPQIPpr552SfE+iGt+HUES+z+ynPAFtfb1A+ wSFAPWZ+1OeY6M+uGnJd9e4CwTYsgcrGmt0GIKLqmIUdL2teflFCaarGAxNCmfgV rrXFM8XTyOUROHyWn/joOhCWc2puMFTy4Mw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdduhedvudegucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefujghffffkgggtsehgtderredttdejnecuhfhrohhmpeetlhihshhsrgcu tfhoshhsuceohhhisegrlhihshhsrgdrihhsqeenucggtffrrghtthgvrhhnpefhteeigf fgkefhteejkeffvdegvdeghfeitdeilefgudejfedtteevffdvleefueenucffohhmrghi nhepshhpvggtthhruhhmqdhoshdrohhrghenucevlhhushhtvghrufhiiigvpedtnecurf grrhgrmhepmhgrihhlfhhrohhmpehhihesrghlhihsshgrrdhishdpnhgspghrtghpthht ohepvddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepuggvmhhiohgsvghnohhurh esghhmrghilhdrtghomhdprhgtphhtthhopeguvghvvghlsehsphgvtghtrhhumhdqohhs rdhorhhg X-ME-Proxy: Feedback-ID: i12284293:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 25 Oct 2025 07:47:24 -0400 (EDT) Received: by mbp.qyliss.net (Postfix, from userid 1000) id 59B4D615ABD0; Sat, 25 Oct 2025 13:47:23 +0200 (CEST) From: Alyssa Ross To: Demi Marie Obenour Subject: Re: [PATCH] scripts/make-erofs.sh: Standardize file modes in images In-Reply-To: <20251022-fix-permissions-v1-1-ba1f113fae6f@gmail.com> References: <20251022-fix-permissions-v1-1-ba1f113fae6f@gmail.com> Date: Sat, 25 Oct 2025 13:47:22 +0200 Message-ID: <878qgztd85.fsf@alyssa.is> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Message-ID-Hash: KFAA34BHWAN7JIMA3HO4KBU7IEJO2NWL X-Message-ID-Hash: KFAA34BHWAN7JIMA3HO4KBU7IEJO2NWL X-MailFrom: hi@alyssa.is X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-devel.spectrum-os.org-0; header-match-devel.spectrum-os.org-1; header-match-devel.spectrum-os.org-2; header-match-devel.spectrum-os.org-3; header-match-devel.spectrum-os.org-4; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Spectrum OS Development X-Mailman-Version: 3.3.9 Precedence: list List-Id: Patches and low-level development discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Demi Marie Obenour writes: > Enforce that anything under /var or /etc is 0755 for directories and > executable files and 0644 for anything else. Enforce that anything else > is 0555 for directories and executable files and 0444 for anything else. > This avoids depending on factors that may depend on the build > environment, such as the user's umask. > > This requires that /var always exist, so add it to img/app/Makefile. > > Signed-off-by: Demi Marie Obenour > --- > host/rootfs/Makefile | 3 ++- > img/app/Makefile | 2 +- > scripts/make-erofs.sh | 21 +++++++++++++++++++++ > 3 files changed, 24 insertions(+), 2 deletions(-) This doesn't seem to have addressed the review comments from last time[1] =E2=80=94 the special handling for directories that might want to u= se overlayfs in future is still there even though it's uncertain we'll ever do that, and so is -execdir. To save us both time, I've just gone ahead and made the changes, and pushed a simplified version of this. Thanks for fixing it =E2=80=94 I'm gl= ad I didn't have to work out that find command myself, and now we can move forward with running things as non-root. [1]: https://spectrum-os.org/lists/archives/spectrum-devel/877bxs570x.fsf@a= lyssa.is > diff --git a/host/rootfs/Makefile b/host/rootfs/Makefile > index aa45ca1d5c18d0dfb78d19267f263cc4222e8e84..ba1beddabb46afa6b20e66177= 107fbe6b6f42bd2 100644 > --- a/host/rootfs/Makefile > +++ b/host/rootfs/Makefile > @@ -40,7 +40,8 @@ DIRS =3D \ > ext \ > proc \ > run \ > - sys > + sys \ > + var >=20=20 > FIFOS =3D etc/s6-linux-init/run-image/service/s6-svscan-log/fifo >=20=20 > diff --git a/img/app/Makefile b/img/app/Makefile > index 981889ebe55d9ba03228977f3dc0ea3f26d5c4fb..2540075fbb2cdcbcde29853cb= 0ffe676de0b9063 100644 > --- a/img/app/Makefile > +++ b/img/app/Makefile > @@ -30,7 +30,7 @@ $(imgdir)/appvm/blk/root.img: ../../scripts/make-gpt.sh= ../../scripts/sfdisk-fie > build/rootfs.erofs:root:5460386f-2203-4911-8694-91400125c604:root > mv $@.tmp $@ >=20=20 > -DIRS =3D dev run proc sys tmp \ > +DIRS =3D dev run proc sys tmp var \ > etc/s6-linux-init/run-image/service \ > etc/s6-linux-init/run-image/user \ > etc/s6-linux-init/run-image/wait > diff --git a/scripts/make-erofs.sh b/scripts/make-erofs.sh > index ad04844387c880047a79f2f05e1e985d8bd4229c..5e283a380dbdae3dbfb83d439= 15e5015a2ae6f04 100755 > --- a/scripts/make-erofs.sh > +++ b/scripts/make-erofs.sh > @@ -68,4 +68,25 @@ while read -r arg1; do > cp -RT -- "$arg1" "$root/$arg2" > done >=20=20 > +# Ensure that the permissions in the image are independent > +# of those in the git repository or Nix store, except for > +# the executable bit. In particular, the mode of those > +# outside the Nix store might depend on the user's umask. > +# While the image itself is strictly read-only, it makes > +# sense to populate an overlayfs over /etc and /var, and > +# this overlayfs should be writable by root and readable > +# by all users. The remaining paths should not be writable > +# by anyone, but should be world-readable. > +find "$root" \ > + -path "$root/nix/store" -prune -o \ > + -path "$root/etc" -prune -o \ > + -path "$root/var" -prune -o \ > + -type l -o \ > + -type d -a -perm 0555 -o \ > + -type f -a -perm 0444 -o \ > + -execdir chmod ugo-w,ugo+rX -- '{}' + > +find "$root/etc" "$root/var" ! -type l -execdir chmod u+w,go-w,ugo+rX --= '{}' + > +chmod 0755 "$root" > + > +# Make the erofs image. > mkfs.erofs -x-1 -b4096 --all-root "$@" "$root" > > --- > base-commit: c5d5786d3dc938af0b279c542d1e43bce381b4b9 > change-id: 20251021-fix-permissions-4549d0653368 > > --=20 > Sincerely, > Demi Marie Obenour (she/her/hers) --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEARYKAB0WIQRV/neXydHjZma5XLJbRZGEIw/wogUCaPy4ygAKCRBbRZGEIw/w oto3AQCn1OE/yxLdbLeF5NRMz2YwrNbqY9pbv73HOvrHW1UR6wEA5PGnuJgAIs2R vdfT/XGW457tmIxy57zCtZXSbSIAVgc= =Gcu6 -----END PGP SIGNATURE----- --=-=-=--