Skip to content

Image Customizer: Fix special directories and partition customization.#7043

Merged
cwize1 merged 1 commit intomicrosoft:mainfrom
cwize1:user/chrisgun/SpecialDirs
Jan 18, 2024
Merged

Image Customizer: Fix special directories and partition customization.#7043
cwize1 merged 1 commit intomicrosoft:mainfrom
cwize1:user/chrisgun/SpecialDirs

Conversation

@cwize1
Copy link
Copy Markdown
Contributor

@cwize1 cwize1 commented Dec 18, 2023

Merge Checklist

All boxes should be checked before merging the PR (just tick any boxes which don't apply to this PR)

  • The toolchain has been rebuilt successfully (or no changes were made to it)
  • The toolchain/worker package manifests are up-to-date
  • Any updated packages successfully build (or no packages were changed)
  • Packages depending on static components modified in this PR (Golang, *-static subpackages, etc.) have had their Release tag incremented.
  • Package tests (%check section) have been verified with RUN_CHECK=y for existing SPEC files, or added to new SPEC files
  • All package sources are available
  • cgmanifest files are up-to-date and sorted (./cgmanifest.json, ./toolkit/scripts/toolchain/cgmanifest.json, .github/workflows/cgmanifest.json)
  • LICENSE-MAP files are up-to-date (./SPECS/LICENSES-AND-NOTICES/data/licenses.json, ./SPECS/LICENSES-AND-NOTICES/LICENSES-MAP.md, ./SPECS/LICENSES-AND-NOTICES/LICENSE-EXCEPTIONS.PHOTON)
  • All source files have up-to-date hashes in the *.signatures.json files
  • sudo make go-tidy-all and sudo make go-test-coverage pass
  • Documentation has been updated to match any changes to the build system
  • Ready to merge

Summary

Currently, the safechroot.Chroot class will auto-mount a bunch of the special directories (e.g. /dev, /proc, etc.). This is done (presumably) to permit more Linux utils to be runnable under the chroot.

However, when the image customizer tool is doing file-copy based partition customization, it has to make sure it avoids copying the contents of the special directories to avoiding messing up the host system. Currently, this is done by just explictly excluding the special directories from the copy operation. However, this can result in problems. For example, a directory not being created (e.g. /tmp) or a mount directory not receiving the correct extended attributes (e.g. SELinux).

This change adds an initialization option to safechroot.Chroot to set whether or not the special-directories are mounted. This allows the partition customization to do just a straight file-copy.

Change Log
  • Image Customizer: Fix special directories and partition customization.
Does this affect the toolchain?

NO

Test Methodology
  • Manually ran image customizer.
  • Ran existing UTs.

@cwize1 cwize1 requested a review from a team as a code owner December 18, 2023 20:02
@microsoft-github-policy-service microsoft-github-policy-service Bot added the main PR Destined for main label Dec 18, 2023
Comment thread toolkit/tools/pkg/imagecustomizerlib/imageutils.go
@cwize1 cwize1 force-pushed the user/chrisgun/SpecialDirs branch from b1fc75d to 73faa3b Compare January 17, 2024 19:53
@cwize1 cwize1 requested a review from a team as a code owner January 17, 2024 19:53
Currently, the `safechroot.Chroot` class will auto-mount a bunch of the
special directories (e.g. /dev, /proc, etc.). This is done (presumably)
to permit more Linux utils to be runnable under the chroot.

However, when the image customizer tool is doing file-copy based
partition customization, it has to make sure it avoids copying the
contents of the special directories to avoiding messing up the host
system. Currently, this is done by just explictly excluding the special
directories from the copy operation. However, this can result in
problems. For example, a directory not being created (e.g. /tmp) or a
mount directory not receiving the correct extended attributes (e.g.
SELinux).

This change adds an initialization option to `safechroot.Chroot` to set
whether or not the special-directories are mounted. This allows the
partition customization to do just a straight file-copy.
@cwize1 cwize1 force-pushed the user/chrisgun/SpecialDirs branch from 73faa3b to 6557e62 Compare January 18, 2024 00:14
@cwize1 cwize1 merged commit 98d0c1f into microsoft:main Jan 18, 2024
Xiaohong-Deng pushed a commit to Xiaohong-Deng/azurelinux that referenced this pull request Nov 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

main PR Destined for main

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants