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 0AECF5120; Sun, 21 Sep 2025 12:23:32 +0000 (UTC) Received: by atuin.qyliss.net (Postfix, from userid 993) id 37A1F50D1; Sun, 21 Sep 2025 12:23:29 +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-b7-smtp.messagingengine.com (fhigh-b7-smtp.messagingengine.com [202.12.124.158]) by atuin.qyliss.net (Postfix) with ESMTPS id 848AB50D0 for ; Sun, 21 Sep 2025 12:23:28 +0000 (UTC) Received: from phl-compute-03.internal (phl-compute-03.internal [10.202.2.43]) by mailfhigh.stl.internal (Postfix) with ESMTP id 5C9957A003F; Sun, 21 Sep 2025 08:23:27 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-03.internal (MEProxy); Sun, 21 Sep 2025 08:23:27 -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=fm3; t=1758457407; x=1758543807; bh=L0kHxVuDZ2 u/IcSSPAszmEgsSlakIsofd644czH9tqY=; b=YqYuwAG4XAs0wcXaOVI7WNEYUX Mmi9fhA0/nFI6au8fttGrr/RQ+7Tl7XxQa90VePaB2ir0MTm+4s3ocGXMNexSEzs iWCzNpUy5/cn+w+3LajCF9IK/2ek29GJ+Vu+u2Uixj3ww8cQnro9Ja27whYOOfRG /MX9vVn1GDwVk0vBdl0HqwE0JF6adItjCCP7YFYIi02HdjQDiceb+4McCc1lyXuU KwfxIqC9s28IOSMUqa1a/iPVZ3x5uYk5Q1R30dyCU2BLspaSdKt9APhob29abp0G +ItIko1rMuWx0SC756jnkzSlDP1zCGSGuz7UraxkmxDJK8Pr67ts22KBHJWQ== 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=fm1; t= 1758457407; x=1758543807; bh=L0kHxVuDZ2u/IcSSPAszmEgsSlakIsofd64 4czH9tqY=; b=ZAKNF3usDsS1hT9Uu924vnz6HV1tqMqhPjWtnzv32vR6jaJfvhq /7YXEf6TNQbYqe3+b1Br5bPqiwzupa98TWDnYzhEb620x4h7N5wo3ch/GaLM1xo1 XE7+cm3c7T4f/lUoqgzlFS0C0/XTxXouBoydcdRN8fUSvN6RxlQeQhppJ8bVUhc2 MSoRAEZwBrPHupOWQVW2BG4Yh1AN8ASx1xCpvaeP5Ok56PvQ7TRsS2kCW54OuqFD nwua48VibFiTAo5Sx+o0J5C5+Gb4yPyZojgkWiyWzMGxImPYfI0XTXXRK6i0I3yg KgHQCVO2oGZOnwP2dXOUZ+39JBEPKR5c35w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdehgeeliecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpefhvfevufgjfhffkfggtgesghdtreertddtjeenucfhrhhomheptehlhihsshgrucft ohhsshcuoehhihesrghlhihsshgrrdhisheqnecuggftrfgrthhtvghrnhepteehvedugf ejgfehhfeijeduleekleejgedvkeeuuefhhfegvdevfeetveegteeinecuvehluhhsthgv rhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhephhhisegrlhihshhsrgdrih hspdhnsggprhgtphhtthhopedvpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopegu vghmihhosggvnhhouhhrsehgmhgrihhlrdgtohhmpdhrtghpthhtohepuggvvhgvlhessh hpvggtthhruhhmqdhoshdrohhrgh X-ME-Proxy: Feedback-ID: i12284293:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 21 Sep 2025 08:23:26 -0400 (EDT) Received: by mbp.qyliss.net (Postfix, from userid 1000) id A409A24AFB82; Sun, 21 Sep 2025 14:23:10 +0200 (CEST) From: Alyssa Ross To: Demi Marie Obenour Subject: Re: [PATCH 07/20] scripts/make-erofs.sh: Standardize file modes in images In-Reply-To: References: <20250904-systemd-v1-0-2a63b790a913@gmail.com> <20250904-systemd-v1-7-2a63b790a913@gmail.com> <87348is55k.fsf@alyssa.is> Date: Sun, 21 Sep 2025 14:23:10 +0200 Message-ID: <877bxs570x.fsf@alyssa.is> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Message-ID-Hash: UQXJ4WLNFGFDHAVF277RIJZZGV6P47O7 X-Message-ID-Hash: UQXJ4WLNFGFDHAVF277RIJZZGV6P47O7 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: > On 9/19/25 13:50, Alyssa Ross wrote: >> Demi Marie Obenour writes: >>=20 >>> 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(-) >>> >>> diff --git a/host/rootfs/Makefile b/host/rootfs/Makefile >>> index f677fe580f2e2be58113457e63468d97f49a49f6..dce78e60bc1a8c18f5f448a= aa9aeed2c8a7da04e 100644 >>> --- a/host/rootfs/Makefile >>> +++ b/host/rootfs/Makefile >>> @@ -97,7 +97,8 @@ DIRS =3D \ >>> ext \ >>> run \ >>> proc \ >>> - 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 9665a6b7158f2d8b183831202a4559ae06d53d16..c6b9a23ce8796582d6e2f51= 21c30c2269975aa2d 100644 >>> --- a/img/app/Makefile >>> +++ b/img/app/Makefile >>> @@ -57,7 +57,7 @@ VM_FILES =3D \ >>> etc/wireplumber/wireplumber.conf.d/99_spectrum.conf \ >>> etc/xdg/xdg-desktop-portal/portals.conf >>>=20=20 >>> -VM_DIRS =3D dev run proc sys tmp \ >>> +VM_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 66abd1f388524c19cd3a1113415892d0d72e3f82..d566a4ac7b30f55338fe9b8= b6a94702686f6ddd1 100755 >>> --- a/scripts/make-erofs.sh >>> +++ b/scripts/make-erofs.sh >>> @@ -95,4 +95,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" >>=20 >> The idea here is reproducibility, right? Can the body mention that? > > Yes, it is. I will fix this in v2. > >> And can we limit it to just doing r-Xr-Xr-X for now, and then worry >> about the overlayfs stuff later if we need to? (This also means we >> don't have to add /var until we need it.) > > systemd-udevd needs /var to be mounted read-write. Without that, > its behavior (and that of all other systemd tools) is undefined > past a certain point in early boot. It does? That's surprising to me, since lots of initrds will run systemd-udevd and I suspect not have /var (such as the NixOS one, I think). Looking at systemd's build system, I only see three uses of localstatedir: polkitpkladir, systemdstatedir, and randomseeddir. As far as I can tell, none of these are used by systemd-udevd. >> I'd also like to stick to POSIX features for standard utilities where >> possible, which it should be here. (I know cp -T isn't POSIX. =F0=9F=A4= =AB) > > Per 'man 1 find', the find command I provided is POSIX except for > -execdir. However, -execdir is also documented as being provided > by BSD OSs. The documentation also warns against -exec, though > the race that -execdir blocks is irrelevant here. Yeah, exactly. Might as well use the POSIX one when it suffices. --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEARYKAB0WIQRV/neXydHjZma5XLJbRZGEIw/wogUCaM/uLgAKCRBbRZGEIw/w osUIAP98c8Y5G4bAoOExiTuNJdzSfSHEqkjOnVFp2kHTpesmmgD/fScAA4zgWl8s NWdERtwjR2vN+4N5w7R4xfIjd6hg7w4= =EKLP -----END PGP SIGNATURE----- --=-=-=--