From 893b3c1824106b10bb3f16d7fde6123ca3acd350 Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Fri, 24 Nov 2023 11:03:51 +0100 Subject: [PATCH] Fix incorrect ldconfig path Signed-off-by: Evan Lezar --- cmd/nvidia-ctk/hook/update-ldcache/update-ldcache.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmd/nvidia-ctk/hook/update-ldcache/update-ldcache.go b/cmd/nvidia-ctk/hook/update-ldcache/update-ldcache.go index 45855efc..934b7b3f 100644 --- a/cmd/nvidia-ctk/hook/update-ldcache/update-ldcache.go +++ b/cmd/nvidia-ctk/hook/update-ldcache/update-ldcache.go @@ -20,6 +20,7 @@ import ( "fmt" "os" "path/filepath" + "strings" "syscall" "github.com/NVIDIA/nvidia-container-toolkit/internal/config" @@ -107,7 +108,7 @@ func (m command) run(c *cli.Context, cfg *options) error { } //nolint:gosec // TODO: Can we harden this so that there is less risk of command injection - return syscall.Exec(args[0], args, nil) + return syscall.Exec(ldconfigPath, args, nil) } type root string @@ -124,7 +125,7 @@ func (r root) hasPath(path string) bool { // On systems such as Ubuntu where `/sbin/ldconfig` is a wrapper around // /sbin/ldconfig.real, the latter is returned. func (m command) resolveLDConfigPath(path string) string { - return config.NormalizeLDConfigPath("@" + path) + return strings.TrimPrefix(config.NormalizeLDConfigPath("@"+path), "@") } // createConfig creates (or updates) /etc/ld.so.conf.d/nvcr-.conf in the container