From 80687f9475148a844b86e20f075fa12286695b4a Mon Sep 17 00:00:00 2001 From: Christian Goll Date: Fri, 3 Feb 2023 15:15:41 +0100 Subject: [PATCH] removed mounts.conf and check of env shell --- internal/app/wwctl/container/exec/child/main.go | 3 +-- internal/app/wwctl/container/shell/main.go | 16 +++++++++++++++- mounts.conf | 8 -------- 3 files changed, 16 insertions(+), 11 deletions(-) delete mode 100644 mounts.conf diff --git a/internal/app/wwctl/container/exec/child/main.go b/internal/app/wwctl/container/exec/child/main.go index a6bbc152..b7bff3b6 100644 --- a/internal/app/wwctl/container/exec/child/main.go +++ b/internal/app/wwctl/container/exec/child/main.go @@ -148,8 +148,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error { for _, mntPnt := range mountPts { err = syscall.Mount(mntPnt.Source, path.Join(containerPath, mntPnt.Dest), "", syscall.MS_BIND, "") if err != nil { - fmt.Printf("BIND ERROR: %s\n", err) - wwlog.Warn("Couldn't mount %s to %s", mntPnt.Source, mntPnt.Dest) + wwlog.Warn("Couldn't mount %s to %s: %s", mntPnt.Source, mntPnt.Dest, err) } else if mntPnt.ReadOnly { err = syscall.Mount(mntPnt.Source, path.Join(containerPath, mntPnt.Dest), "", syscall.MS_REMOUNT|syscall.MS_RDONLY|syscall.MS_BIND, "") if err != nil { diff --git a/internal/app/wwctl/container/shell/main.go b/internal/app/wwctl/container/shell/main.go index 415aa046..b7c3fbde 100644 --- a/internal/app/wwctl/container/shell/main.go +++ b/internal/app/wwctl/container/shell/main.go @@ -5,6 +5,7 @@ package shell import ( "os" + "path" cntexec "github.com/hpcng/warewulf/internal/app/wwctl/container/exec" "github.com/hpcng/warewulf/internal/pkg/container" @@ -27,8 +28,21 @@ func CobraRunE(cmd *cobra.Command, args []string) error { } */ shellName := os.Getenv("SHELL") + if !container.ValidSource(containerName) { + wwlog.Error("Unknown Warewulf container: %s", containerName) + os.Exit(1) + } + var shells []string if shellName == "" { - shellName = "/usr/bin/bash" + shells = append(shells, "/bin/bash") + } else { + shells = append(shells, shellName, "/bin/bash") + } + for _, s := range shells { + if _, err := os.Stat(path.Join(container.RootFsDir(containerName), s)); err == nil { + shellName = s + break + } } args = append(args, shellName) allargs = append(allargs, args...) diff --git a/mounts.conf b/mounts.conf deleted file mode 100644 index 96319276..00000000 --- a/mounts.conf +++ /dev/null @@ -1,8 +0,0 @@ -Mount Points: -- Dest: /etc/SUSEConnect - Source: /etc/SUSEConnect -- Dest: /etc/SUSEConnect - Source: /etc/SUSEConnect -- Dest: /etc/SUSEConnect - Source: /etc/SUSEConnect -