Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/nvidia-cdi-hook/chmod/chmod.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ func (m command) run(_ *cli.Command, cfg *config) error {
if err != nil {
return fmt.Errorf("failed to determined container root: %v", err)
}
if containerRoot == "" {
return fmt.Errorf("empty container root detected")
if containerRoot == "" || containerRoot == "/" {
return fmt.Errorf("invalid container root: %q", containerRoot)
}

paths := m.getPaths(containerRoot, cfg.paths, cfg.mode)
Expand Down
3 changes: 3 additions & 0 deletions cmd/nvidia-cdi-hook/create-symlinks/create-symlinks.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ func (m command) run(_ *cli.Command, cfg *config) error {
if err != nil {
return fmt.Errorf("failed to determined container root: %v", err)
}
if containerRoot == "" || containerRoot == "/" {
return fmt.Errorf("invalid container root: %q", containerRoot)
}

created := make(map[string]bool)
for _, l := range cfg.links {
Expand Down
3 changes: 3 additions & 0 deletions cmd/nvidia-cdi-hook/cudacompat/cudacompat.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ func (m command) run(_ *cli.Command, o *options) error {
if err != nil {
return fmt.Errorf("failed to determined container root: %w", err)
}
if containerRootDir == "" || containerRootDir == "/" {
return fmt.Errorf("invalid container root: %q", containerRootDir)
}

containerRoot, err := newRoot(containerRootDir)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ func run(_ context.Context, _ *cli.Command, cfg *options) error {
if err != nil {
return fmt.Errorf("failed to determined container root: %w", err)
}
if containerRootDirPath == "" || containerRootDirPath == "/" {
return fmt.Errorf("invalid container root: %q", containerRootDirPath)
}

containerRoot, err := os.OpenRoot(containerRootDirPath)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ func run(_ context.Context, _ *cli.Command, cfg *options, logger logger.Interfac
if err != nil {
return fmt.Errorf("failed to determine container root: %w", err)
}
if containerRootDirPath == "" || containerRootDirPath == "/" {
return fmt.Errorf("invalid container root: %q", containerRootDirPath)
}

containerRoot, err := os.OpenRoot(containerRootDirPath)
if err != nil {
Expand Down
5 changes: 4 additions & 1 deletion cmd/nvidia-cdi-hook/update-ldcache/update-ldcache.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,12 @@ func (m command) run(_ *cli.Command, cfg *options) error {
}

containerRootDir, err := s.GetContainerRoot()
if err != nil || containerRootDir == "" || containerRootDir == "/" {
if err != nil {
return fmt.Errorf("failed to determined container root: %v", err)
}
if containerRootDir == "" || containerRootDir == "/" {
return fmt.Errorf("invalid container root: %q", containerRootDir)
}

runner, err := ldconfig.NewRunner(
reexecUpdateLdCacheCommandName,
Expand Down
Loading