mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2024-11-22 08:18:32 +00:00
Explicitly set ldconfig cache and config file
Since the `update-ldcache` hook uses the host's `ldconfig`, the default cache and config files configured on the host will be used. If those defaults differ from what nvidia-ctk expects it to be (/etc/ld.so.cache and /etc/ld.so.conf, respectively), then the hook will fail. This change makes the call to ldconfig explicit in which cache and config files are being used. Signed-off-by: Jared Baur <jaredbaur@fastmail.com>
This commit is contained in:
parent
838493b8b9
commit
d80657dd0a
@ -100,21 +100,27 @@ func (m command) run(c *cli.Context, cfg *options) error {
|
|||||||
args = append(args, "-r", containerRoot)
|
args = append(args, "-r", containerRoot)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !root(containerRoot).hasPath("/etc/ld.so.cache") {
|
if root(containerRoot).hasPath("/etc/ld.so.cache") {
|
||||||
|
args = append(args, "-C", "/etc/ld.so.cache")
|
||||||
|
} else {
|
||||||
m.logger.Debugf("No ld.so.cache found, skipping update")
|
m.logger.Debugf("No ld.so.cache found, skipping update")
|
||||||
args = append(args, "-N")
|
args = append(args, "-N")
|
||||||
}
|
}
|
||||||
|
|
||||||
folders := cfg.folders.Value()
|
folders := cfg.folders.Value()
|
||||||
if root(containerRoot).hasPath("/etc/ld.so.conf.d") {
|
if root(containerRoot).hasPath("/etc/ld.so.conf.d") {
|
||||||
err = m.createConfig(containerRoot, folders)
|
err := m.createConfig(containerRoot, folders)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to update ld.so.conf: %v", err)
|
return fmt.Errorf("failed to update ld.so.conf.d: %v", err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
args = append(args, folders...)
|
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")
|
||||||
|
|
||||||
//nolint:gosec // TODO: Can we harden this so that there is less risk of command injection
|
//nolint:gosec // TODO: Can we harden this so that there is less risk of command injection
|
||||||
return syscall.Exec(ldconfigPath, args, nil)
|
return syscall.Exec(ldconfigPath, args, nil)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user