Skip to content

Commit d74117e

Browse files
committed
Comments addressed.
1 parent 577cc75 commit d74117e

File tree

5 files changed

+52
-44
lines changed

5 files changed

+52
-44
lines changed

docs/imagecustomizer/api/configuration/outputArtifacts.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ Supported values:
5555
- `shim` – Bootloader shim executable (`boot<arch>.efi`).
5656
- `systemd-boot` – Systemd-boot executable (`systemd-boot<arch>.efi`).
5757
- `verity-hash` – Verity hash files associated with dm-verity protected partitions.
58+
*Added in v0.16.*
5859

5960
The `output.artifacts` field must be used with the `output-artifacts` enabled in `previewFeatures`.
6061

@@ -64,9 +65,9 @@ Supported architectures for shim and systemd-boot include x64 and arm64,
6465
reflected in the `<arch>` portion of the filenames.
6566

6667
The `verity-hash` artifact will only be output if the corresponding Verity entry
67-
defines a `hashSignaturePath`. If the `hashSignaturePath` is not configured,
68-
Image Customizer will skip generating the hash file for that Verity device. For
69-
more details, see the [`verity`](./verity.md) documentation.
68+
defines a [`hashSignaturePath`](./verity.md#hashsignaturepath-string). If the
69+
`hashSignaturePath` is not configured, Image Customizer will skip generating the
70+
hash file for that Verity device. For more details, see the
71+
[`verity`](./verity.md) documentation.
7072

7173
Added in v0.14.
72-
`verity-hash` added in v0.16.

docs/imagecustomizer/api/configuration/verity.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -259,21 +259,21 @@ Specifies the path where the signed verity hash file should be injected into the
259259
image. This path is typically used by the `systemd-veritysetup` module to verify
260260
the verity hash against a signature at boot time.
261261

262-
- This path **must be located under the boot partition** for the current
263-
version. For example, if the boot partition is mounted at `/boot`, then
264-
`hashSignaturePath: /boot/root.hash.sig` will result in a destination of
265-
`/root.hash.sig` relative to the boot partition during injection.
262+
This path **must be located under the boot partition**. (This restriction may be
263+
lessened in the future.) For example, if the boot partition is mounted at
264+
`/boot`, then `hashSignaturePath: /boot/root.hash.sig` will result in a
265+
destination of `/root.hash.sig` relative to the boot partition during injection.
266266

267-
- When this field is specified, Prism will output the corresponding unsigned
268-
hash file (`verity-hash`) as an artifact if the
269-
[`output.artifacts`](./outputArtifacts.md) API is configured.
267+
When this field is specified, Image Customizer will output the corresponding unsigned hash
268+
file (`verity-hash`) as an artifact if the
269+
[`output.artifacts`](./outputArtifacts.md) API is configured.
270270

271-
- The generated `inject-files.yaml` will include an entry to inject the signed
272-
hash file to the specified path inside the boot partition.
271+
The generated `inject-files.yaml` will include an entry to inject the signed
272+
hash file to the specified path inside the boot partition.
273273

274274
If `hashSignaturePath` is not configured for a given Verity entry, the verity
275275
hash file will not be output even if `verity-hash` is listed in the
276-
`output.artifacts.items`. Only Verity entries with `hashSignaturePath` defined
277-
will produce a `verity-hash` artifact.
276+
[`output.artifacts.items`](./outputArtifacts.md#items-string). Only Verity
277+
entries with `hashSignaturePath` defined will produce a `verity-hash` artifact.
278278

279279
Added in v0.16.

toolkit/tools/imagecustomizerapi/verity.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,13 @@ func (v *Verity) IsValid() error {
101101
}
102102

103103
sigPath := filepath.Clean(v.HashSignaturePath)
104+
if sigPath != v.HashSignaturePath {
105+
return fmt.Errorf(
106+
"verity.hashSignaturePath (%s) is not normalized (cleaned path: %s). Please provide a canonical path",
107+
v.HashSignaturePath, sigPath,
108+
)
109+
}
110+
104111
if !strings.HasPrefix(sigPath, bootMountPoint+"/") {
105112
return fmt.Errorf(
106113
"verity.hashSignaturePath (%s) must be located under /boot mount point (%s)",

toolkit/tools/imagegen/installutils/installutils.go

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,6 @@ const (
105105

106106
// Configuration files related to boot behavior. Users should be able to read these files, and root should have RW access.
107107
bootUsrConfigFileMode = 0644
108-
109-
// Dracut module directory path for verity boot partition support.
110-
VerityMountBootPartitionModuleDir = "/usr/lib/dracut/modules.d/90mountbootpartition"
111-
// Standard permission mode for dracut module directories.
112-
DracutModuleDirMode = 0755
113-
// Standard permission mode for executable scripts in dracut modules.
114-
DracutModuleScriptFileMode = 0755
115108
)
116109

117110
// PackageList represents the list of packages to install into an image
@@ -2898,23 +2891,3 @@ func KernelPackages(config configuration.Config) []*pkgjson.PackageVer {
28982891
}
28992892
return packageList
29002893
}
2901-
2902-
func InstallVerityMountBootPartitionDracutModule(installRoot string) error {
2903-
targetDir := filepath.Join(installRoot, VerityMountBootPartitionModuleDir)
2904-
2905-
filesToInstall := map[string]string{
2906-
resources.VerityMountBootPartitionSetupFile: filepath.Join(targetDir, "module-setup.sh"),
2907-
resources.VerityMountBootPartitionGeneratorFile: filepath.Join(targetDir, "mountbootpartition-generator.sh"),
2908-
resources.VerityMountBootPartitionGenRulesFile: filepath.Join(targetDir, "mountbootpartition-genrules.sh"),
2909-
resources.VerityMountBootPartitionScriptFile: filepath.Join(targetDir, "mountbootpartition.sh"),
2910-
}
2911-
2912-
for src, dst := range filesToInstall {
2913-
err := file.CopyResourceFile(resources.ResourcesFS, src, dst, DracutModuleDirMode, DracutModuleScriptFileMode)
2914-
if err != nil {
2915-
return fmt.Errorf("failed to install verity dracut file (%s): %w", dst, err)
2916-
}
2917-
}
2918-
2919-
return nil
2920-
}

toolkit/tools/pkg/imagecustomizerlib/customizeverity.go

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import (
1111

1212
"github.com/microsoft/azurelinux/toolkit/tools/imagecustomizerapi"
1313
"github.com/microsoft/azurelinux/toolkit/tools/imagegen/diskutils"
14-
"github.com/microsoft/azurelinux/toolkit/tools/imagegen/installutils"
1514
"github.com/microsoft/azurelinux/toolkit/tools/internal/file"
1615
"github.com/microsoft/azurelinux/toolkit/tools/internal/logger"
16+
"github.com/microsoft/azurelinux/toolkit/tools/internal/resources"
1717
"github.com/microsoft/azurelinux/toolkit/tools/internal/safechroot"
1818
"github.com/microsoft/azurelinux/toolkit/tools/internal/sliceutils"
1919
)
@@ -22,6 +22,13 @@ const (
2222
systemdVerityDracutModule = "systemd-veritysetup"
2323
dmVerityDracutDriver = "dm-verity"
2424
mountBootPartModule = "mountbootpartition"
25+
26+
// Dracut module directory path for verity boot partition support.
27+
VerityMountBootPartitionModuleDir = "/usr/lib/dracut/modules.d/90mountbootpartition"
28+
// Standard permission mode for dracut module directories.
29+
DracutModuleDirMode = 0755
30+
// Standard permission mode for executable scripts in dracut modules.
31+
DracutModuleScriptFileMode = 0755
2532
)
2633

2734
func enableVerityPartition(verity []imagecustomizerapi.Verity, imageChroot *safechroot.Chroot,
@@ -126,7 +133,7 @@ func supportVerityHashSignature(verityList []imagecustomizerapi.Verity, imageChr
126133
return fmt.Errorf("failed to add dracut modules for verity hash signature support:\n%w", err)
127134
}
128135

129-
err = installutils.InstallVerityMountBootPartitionDracutModule(imageChroot.RootDir())
136+
err = InstallVerityMountBootPartitionDracutModule(imageChroot.RootDir())
130137
if err != nil {
131138
return fmt.Errorf("failed to install verity dracut scripts:\n%w", err)
132139
}
@@ -137,6 +144,26 @@ func supportVerityHashSignature(verityList []imagecustomizerapi.Verity, imageChr
137144
return nil
138145
}
139146

147+
func InstallVerityMountBootPartitionDracutModule(installRoot string) error {
148+
targetDir := filepath.Join(installRoot, VerityMountBootPartitionModuleDir)
149+
150+
filesToInstall := map[string]string{
151+
resources.VerityMountBootPartitionSetupFile: filepath.Join(targetDir, "module-setup.sh"),
152+
resources.VerityMountBootPartitionGeneratorFile: filepath.Join(targetDir, "mountbootpartition-generator.sh"),
153+
resources.VerityMountBootPartitionGenRulesFile: filepath.Join(targetDir, "mountbootpartition-genrules.sh"),
154+
resources.VerityMountBootPartitionScriptFile: filepath.Join(targetDir, "mountbootpartition.sh"),
155+
}
156+
157+
for src, dst := range filesToInstall {
158+
err := file.CopyResourceFile(resources.ResourcesFS, src, dst, DracutModuleDirMode, DracutModuleScriptFileMode)
159+
if err != nil {
160+
return fmt.Errorf("failed to install verity dracut file (%s): %w", dst, err)
161+
}
162+
}
163+
164+
return nil
165+
}
166+
140167
func updateGrubConfigForVerity(verityMetadata []verityDeviceMetadata, grubCfgFullPath string,
141168
partitions []diskutils.PartitionInfo, buildDir string, bootUuid string,
142169
) error {

0 commit comments

Comments
 (0)