Page MenuHomeFreeBSD

vmimage.subr: Sort METALOG before running makefs
AcceptedPublic

Authored by cperciva on Sun, Oct 12, 5:20 AM.
Tags
None
Referenced Files
F131937632: D53046.id164032.diff
Sun, Oct 12, 8:33 AM
F131937553: D53046.id164031.diff
Sun, Oct 12, 8:33 AM
F131937518: D53046.id.diff
Sun, Oct 12, 8:32 AM
F131934339: D53046.diff
Sun, Oct 12, 8:01 AM
F131934308: D53046.diff
Sun, Oct 12, 8:01 AM

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 Skipped
Unit
Tests Skipped
Build Status
Buildable 67729
Build 64612: arc lint + arc unit

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.Sun, Oct 12, 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.