Skip to content

Commit 8732341

Browse files
mvo5ondrejbudai
authored andcommitted
bib: fix anaconda-iso mTLS key extraction
There was a (subtle) bug in the ibcli version of the mTLS key exaction. It was happening too late, i.e. when the bootc container was already unmounted. This commit moves the extraction into the `Depsolve` function which is run while the container is mounted which means we can extract the mTLS config. Note that this was not discovered earlier because we lack and end-to-end test for RHEL based bootc images :(
1 parent 3289abb commit 8732341

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

cmd/image-builder/bib_main.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ func bibManifestFromCobra(cmd *cobra.Command, args []string, pbar progress.Progr
155155
if useLibrepo {
156156
rpmDownloader = osbuild.RpmDownloaderLibrepo
157157
}
158+
var mTLS *mTLSConfig
158159
mg, err := manifestgen.New(repos, &manifestgen.Options{
159160
Cachedir: rpmCacheRoot,
160161
// XXX: hack to skip repo loading for the bootc image.
@@ -168,6 +169,15 @@ func bibManifestFromCobra(cmd *cobra.Command, args []string, pbar progress.Progr
168169
RpmDownloader: rpmDownloader,
169170
Depsolve: func(solver *depsolvednf.Solver, cacheDir string, depsolveWarningsOutput io.Writer, packageSets map[string][]rpmmd.PackageSet, d distro.Distro, arch string) (map[string]depsolvednf.DepsolveResult, error) {
170171
depsolveResult, err = manifestgen.DefaultDepsolve(solver, cacheDir, depsolveWarningsOutput, packageSets, d, arch)
172+
// extracting needs to happen while container is mounted
173+
depsolvedRepos := make(map[string][]rpmmd.RepoConfig)
174+
for k, v := range depsolveResult {
175+
depsolvedRepos[k] = v.Repos
176+
}
177+
mTLS, err = extractTLSKeys(depsolvedRepos)
178+
if err != nil {
179+
return nil, err
180+
}
171181
return depsolveResult, err
172182
},
173183
// this turns (blueprint validation) warnings into
@@ -187,15 +197,6 @@ func bibManifestFromCobra(cmd *cobra.Command, args []string, pbar progress.Progr
187197
return nil, nil, err
188198
}
189199

190-
depsolvedRepos := make(map[string][]rpmmd.RepoConfig)
191-
for k, v := range depsolveResult {
192-
depsolvedRepos[k] = v.Repos
193-
}
194-
mTLS, err := extractTLSKeys(depsolvedRepos)
195-
if err != nil {
196-
return nil, nil, err
197-
}
198-
199200
return manifest, mTLS, nil
200201
}
201202

0 commit comments

Comments
 (0)