From fc7182d7bd7f311b94dba8f7b9ebfe8ca8d758a1 Mon Sep 17 00:00:00 2001 From: Gregory Kurtzer Date: Wed, 1 Sep 2021 19:23:13 -0700 Subject: [PATCH 1/3] Don't bind resolv.conf, copy on import --- internal/app/wwctl/container/exec/child/main.go | 5 ----- internal/app/wwctl/container/imprt/main.go | 8 +++++++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/internal/app/wwctl/container/exec/child/main.go b/internal/app/wwctl/container/exec/child/main.go index 7c002db1..0cb5b49a 100644 --- a/internal/app/wwctl/container/exec/child/main.go +++ b/internal/app/wwctl/container/exec/child/main.go @@ -11,7 +11,6 @@ import ( "syscall" "github.com/hpcng/warewulf/internal/pkg/container" - "github.com/hpcng/warewulf/internal/pkg/util" "github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/spf13/cobra" ) @@ -35,10 +34,6 @@ func CobraRunE(cmd *cobra.Command, args []string) error { syscall.Mount("", "/", "", syscall.MS_PRIVATE, "") syscall.Mount("/dev", path.Join(containerPath, "/dev"), "", syscall.MS_BIND, "") - if util.IsFile(path.Join(containerPath, "/etc/resolv.conf")) == true { - syscall.Mount("/etc/resolv.conf", path.Join(containerPath, "/etc/resolv.conf"), "", syscall.MS_BIND, "") - } - for _, b := range binds { var source string var dest string diff --git a/internal/app/wwctl/container/imprt/main.go b/internal/app/wwctl/container/imprt/main.go index 929404a4..fe6b27a6 100644 --- a/internal/app/wwctl/container/imprt/main.go +++ b/internal/app/wwctl/container/imprt/main.go @@ -121,8 +121,14 @@ func CobraRunE(cmd *cobra.Command, args []string) error { } } + fmt.Printf("Updating the container's /etc/resolv.conf\n") + err := util.CopyFile("/etc/resolv.conf", path.Join(container.RootFsDir(name), "/etc/resolv.conf")) + if err != nil { + wwlog.Printf(wwlog.WARN, "Could not copy /etc/resolv.conf into container: %s\n", err) + } + fmt.Printf("Building container: %s\n", name) - err := container.Build(name, true) + err = container.Build(name, true) if err != nil { wwlog.Printf(wwlog.ERROR, "Could not build container %s: %s\n", name, err) os.Exit(1) From 198791fb10c2b7455039c1fa731f6b6083fcafd1 Mon Sep 17 00:00:00 2001 From: Gregory Kurtzer Date: Wed, 1 Sep 2021 19:26:38 -0700 Subject: [PATCH 2/3] add default and sane path to `container exec` --- internal/app/wwctl/container/exec/child/main.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/app/wwctl/container/exec/child/main.go b/internal/app/wwctl/container/exec/child/main.go index 0cb5b49a..1e464fbd 100644 --- a/internal/app/wwctl/container/exec/child/main.go +++ b/internal/app/wwctl/container/exec/child/main.go @@ -62,6 +62,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error { ps1string := fmt.Sprintf("[%s] Warewulf> ", containerName) os.Setenv("PS1", ps1string) + os.Setenv("PATH", "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin") os.Setenv("HISTFILE", "/dev/null") err := syscall.Exec(args[1], args[1:], os.Environ()) From 50e6f0daf4ee4a6a69b29dcda10a8bd82c440134 Mon Sep 17 00:00:00 2001 From: Gregory Kurtzer Date: Wed, 1 Sep 2021 19:28:12 -0700 Subject: [PATCH 3/3] Format fix. --- internal/pkg/util/util.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/pkg/util/util.go b/internal/pkg/util/util.go index dad621b0..c2698ce4 100644 --- a/internal/pkg/util/util.go +++ b/internal/pkg/util/util.go @@ -111,7 +111,7 @@ func CopyFiles(source string, dest string) error { if err != nil { return err } - err = CopyUIDGID(source,dest) + err = CopyUIDGID(source, dest) if err != nil { return err }