Page MenuHomeFreeBSD

vmimage.subr: Sort METALOG before running makefs
ClosedPublic

Authored by cperciva on Oct 12 2025, 5:20 AM.
Tags
None
Referenced Files
F137708376: D53046.diff
Tue, Nov 25, 2:03 AM
Unknown Object (File)
Sun, Nov 23, 4:20 AM
Unknown Object (File)
Sun, Nov 23, 1:11 AM
Unknown Object (File)
Fri, Nov 21, 5:34 AM
Unknown Object (File)
Wed, Nov 19, 6:38 AM
Unknown Object (File)
Tue, Nov 18, 8:28 PM
Unknown Object (File)
Mon, Nov 17, 7:41 AM
Unknown Object (File)
Sat, Nov 15, 11:00 PM

Details

Summary

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.

Hint from: imp
MFC after: 3 days
Sponsored by: https://www.patreon.com/cperciva

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Add -u which got lost when I committed the wrong patch.

i feel like this is really an issue in makefs: if it doesn't know the permissions for a directory, it should fail with an error, since 0 permissions is almost certainly going to be wrong. ideally, it would sort the METALOG itself to handle cases like this, although i don't know if that breaks anything else.

but this seems fine to fix the build, and might end up being the right way to do it anyway.

This revision is now accepted and ready to land.Oct 12 2025, 6:19 AM

I used awk to omit first arg same as last. I think the -u is likely useless.

Makefs has a lot of issues....

This is what we did for NO_ROOT NanoBSD images.
Beware of double slashes in the METALOG. Though they are not invalid per se, consider the following excerpt:

./base/aaa type=dir
./base//aaa/bbb type=dir

If sorted, it would turn out:

./base//aaa/bbb type=dir
./base/aaa type=dir

Apparently missing the ./base/aaa directory in the specification.

I've not hit the // issue. When does it happen?

In D53046#1212029, @imp wrote:

I've not hit the // issue. When does it happen?

Used to happen: D48779, D48778, and D47722.

I wondet if we can fix install...

I just checked and we don't have any double-slash issues in the METALOG files for 15.0-BETA1 so I'm inclined to not worry about it right now.

And I agree that makefs should probably take care of this; I'll make a note to ensure it's fixed for a future release so workarounds like this aren't necessary.

i feel like this is really an issue in makefs

Yeah, I think it's reasonable for makefs to reject a METALOG failing to specify directories before their contents