git: ad2ca1c5c179 - stable/15 - vmimage.subr: Sort METALOG before running makefs
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 15 Oct 2025 05:57:29 UTC
The branch stable/15 has been updated by cperciva: URL: https://cgit.FreeBSD.org/src/commit/?id=ad2ca1c5c17935d8601b3ee48f705e1e5ede57bc commit ad2ca1c5c17935d8601b3ee48f705e1e5ede57bc Author: Colin Percival <cperciva@FreeBSD.org> AuthorDate: 2025-10-12 04:32:29 +0000 Commit: Colin Percival <cperciva@FreeBSD.org> CommitDate: 2025-10-15 05:57:20 +0000 vmimage.subr: Sort METALOG before running makefs When creating VM images from pkgbase, the METALOG may not be in order; in particular, files may be listed before the directories which contain them. This causes makefs to create directories with 000 permissions. Interestingly, such VM images boot just fine, since root ignores those permissions; the first sign of trouble was sshd refusing logins with an error message which said absolutely nothing about /etc/ having incorrect permissions or being unable to read files inside it. Immediately prior to running makefs, sort the METALOG file. While we're here, uniquify as well; this does not guarantee that we do not have duplicate paths, but if there are duplicate paths with different settings something else has gone wrong and we don't really have any good way of solving the problem anyway. Reviewed by: ivy Hint from: imp MFC after: 3 days Sponsored by: https://www.patreon.com/cperciva Differential Revision: https://reviews.freebsd.org/D53046 (cherry picked from commit 0cc81b375ea43c7e853b109d00c72c8c3b3df993) --- release/tools/vmimage.subr | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/release/tools/vmimage.subr b/release/tools/vmimage.subr index 15c4dd53e70b..c3c917dcd642 100644 --- a/release/tools/vmimage.subr +++ b/release/tools/vmimage.subr @@ -290,6 +290,11 @@ buildfs() { cat ${DESTDIR}/METALOG.pkg >> ${DESTDIR}/METALOG fi + # Sort METALOG file; makefs produces directories with 000 permissions + # if their contents are seen before the directories themselves. + env -i LC_COLLATE=C sort -u ${DESTDIR}/METALOG > ${DESTDIR}/METALOG.sorted + mv ${DESTDIR}/METALOG.sorted ${DESTDIR}/METALOG + case "${VMFS}" in ufs) cd ${DESTDIR} && ${MAKEFS} ${MAKEFSARGS} -o label=rootfs -o version=2 -o softupdates=1 \