Merge pull request #1002 from elezar/improve-update-ldcache-args
Some checks failed
CI Pipeline / code-scanning (push) Has been cancelled
CI Pipeline / variables (push) Has been cancelled
CI Pipeline / golang (push) Has been cancelled
CI Pipeline / image (push) Has been cancelled
CI Pipeline / e2e-test (push) Has been cancelled

Fix update-ldcache arguments
This commit is contained in:
Evan Lezar 2025-03-20 13:19:25 +02:00 committed by GitHub
commit e33f15a128
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -109,14 +109,20 @@ func (m command) run(c *cli.Context, cfg *options) error {
}
containerRootDir, err := s.GetContainerRoot()
if err != nil {
if err != nil || containerRootDir == "" || containerRootDir == "/" {
return fmt.Errorf("failed to determined container root: %v", err)
}
ldconfigPath := m.resolveLDConfigPath(cfg.ldconfigPath)
args := []string{filepath.Base(ldconfigPath)}
if containerRootDir != "" {
args = append(args, "-r", containerRootDir)
args := []string{
filepath.Base(ldconfigPath),
// Run ldconfig in the container root directory on the host.
"-r", containerRootDir,
// Explicitly specify using /etc/ld.so.conf since the host's ldconfig may
// be configured to use a different config file by default.
// Note that since we apply the `-r {{ .containerRootDir }}` argument, /etc/ld.so.conf is
// in the container.
"-f", "/etc/ld.so.conf",
}
containerRoot := containerRoot(containerRootDir)
@ -138,10 +144,6 @@ func (m command) run(c *cli.Context, cfg *options) error {
args = append(args, folders...)
}
// Explicitly specify using /etc/ld.so.conf since the host's ldconfig may
// be configured to use a different config file by default.
args = append(args, "-f", "/etc/ld.so.conf")
return m.SafeExec(ldconfigPath, args, nil)
}