From dc6db3d565f4bf8b3bd5f11149be65d43750d0b0 Mon Sep 17 00:00:00 2001 From: Christian Goll Date: Tue, 6 Feb 2024 16:50:21 +0100 Subject: [PATCH 1/3] using the right overlay directory and remove it Signed-off-by: Christian Goll --- CHANGELOG.md | 1 + .../app/wwctl/container/exec/child/main.go | 10 ++++++-- .../app/wwctl/container/exec/child/root.go | 7 ++++-- internal/app/wwctl/container/exec/main.go | 24 +++++++------------ internal/app/wwctl/container/exec/root.go | 10 ++++---- 5 files changed, 27 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b44547f22..4edb4d07f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -59,6 +59,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Fix the issue that warewulf.conf parse does not support CIDR format. #1130 - Reduce the number of times syncuser walks the container file system. #1209 - Create ssh key also when calling `wwctl configure --all` #1250 +- Remove the temporary overlay dir. #1180 ### Security diff --git a/internal/app/wwctl/container/exec/child/main.go b/internal/app/wwctl/container/exec/child/main.go index 57cf7192c..bf4095081 100644 --- a/internal/app/wwctl/container/exec/child/main.go +++ b/internal/app/wwctl/container/exec/child/main.go @@ -21,6 +21,8 @@ import ( "github.com/warewulf/warewulf/internal/pkg/wwlog" ) +const exitEval = `$(VALU="$?" ; if [ $VALU == 0 ]; then echo write; else echo discard; fi)` + func CobraRunE(cmd *cobra.Command, args []string) (err error) { if os.Getpid() != 1 { wwlog.Error("PID is not 1: %d", os.Getpid()) @@ -34,11 +36,13 @@ func CobraRunE(cmd *cobra.Command, args []string) (err error) { os.Exit(1) } conf := warewulfconf.Get() + if overlayDir == "" { + overlayDir = path.Join(conf.Paths.WWChrootdir, "overlays") + } mountPts := conf.MountsContainer mountPts = append(container.InitMountPnts(binds), mountPts...) // check for valid mount points lowerObjects := checkMountPoints(containerName, mountPts) - overlayDir := conf.Paths.WWChrootdir + "/overlays" // need to create a overlay, where the lower layer contains // the missing mount points wwlog.Verbose("for ephermal mount use tempdir %s", overlayDir) @@ -46,6 +50,7 @@ func CobraRunE(cmd *cobra.Command, args []string) (err error) { _ = os.MkdirAll(path.Join(overlayDir, "work"), os.ModePerm) _ = os.MkdirAll(path.Join(overlayDir, "lower"), os.ModePerm) _ = os.MkdirAll(path.Join(overlayDir, "nodeoverlay"), os.ModePerm) + // handle all lower object, have some extra logic if the object is a file for _, obj := range lowerObjects { newFile := "" if !strings.HasSuffix(obj, "/") { @@ -65,11 +70,12 @@ func CobraRunE(cmd *cobra.Command, args []string) (err error) { } } containerPath := container.RootFsDir(containerName) + // running in a private PID space, so also make / private, so that nothing gets out from here err = syscall.Mount("", "/", "", syscall.MS_PRIVATE|syscall.MS_REC, "") if err != nil { return errors.Wrap(err, "failed to mount") } - ps1Str := fmt.Sprintf("[%s] Warewulf> ", containerName) + ps1Str := fmt.Sprintf("[%s|%s] Warewulf> ", exitEval, containerName) if len(lowerObjects) != 0 && nodename == "" { options := fmt.Sprintf("lowerdir=%s,upperdir=%s,workdir=%s", path.Join(overlayDir, "lower"), containerPath, path.Join(overlayDir, "work")) diff --git a/internal/app/wwctl/container/exec/child/root.go b/internal/app/wwctl/container/exec/child/root.go index ad807a6fd..ab72086d4 100644 --- a/internal/app/wwctl/container/exec/child/root.go +++ b/internal/app/wwctl/container/exec/child/root.go @@ -13,13 +13,16 @@ var ( Args: cobra.MinimumNArgs(1), FParseErrWhitelist: cobra.FParseErrWhitelist{UnknownFlags: true}, } - binds []string - nodename string + binds []string + nodename string + overlayDir string ) func init() { baseCmd.Flags().StringVarP(&nodename, "node", "n", "", "create ro overlay for given node") baseCmd.Flags().StringArrayVarP(&binds, "bind", "b", []string{}, "bind points") + baseCmd.Flags().StringVar(&overlayDir, "overlaydir", "", "overlayDir") + } // GetRootCommand returns the root cobra.Command for the application. diff --git a/internal/app/wwctl/container/exec/main.go b/internal/app/wwctl/container/exec/main.go index 44e11e9f5..80140a675 100644 --- a/internal/app/wwctl/container/exec/main.go +++ b/internal/app/wwctl/container/exec/main.go @@ -12,6 +12,7 @@ import ( "time" "github.com/spf13/cobra" + warewulfconf "github.com/warewulf/warewulf/internal/pkg/config" "github.com/warewulf/warewulf/internal/pkg/container" "github.com/warewulf/warewulf/internal/pkg/util" "github.com/warewulf/warewulf/internal/pkg/wwlog" @@ -20,15 +21,15 @@ import ( /* fork off a process with a new PID space */ -func runContainedCmd(args []string) error { - var err error - if tempDir == "" { - tempDir, err = os.MkdirTemp(os.TempDir(), "overlay") +func runContainedCmd(args []string) (err error) { + if overlayDir == "" { + conf := warewulfconf.Get() + overlayDir, err = os.MkdirTemp(conf.Paths.WWChrootdir, "overlays-") if err != nil { wwlog.Warn("couldn't create temp dir for overlay", err) } defer func() { - err = os.RemoveAll(tempDir) + err = os.RemoveAll(overlayDir) if err != nil { wwlog.Warn("Couldn't remove temp dir for ephermal mounts:", err) } @@ -36,7 +37,7 @@ func runContainedCmd(args []string) error { } logStr := fmt.Sprint(wwlog.GetLogLevel()) wwlog.Verbose("Running contained command: %s", args[1:]) - c := exec.Command("/proc/self/exe", append([]string{"--loglevel", logStr, "--tempdir", tempDir, "container", "exec", "__child"}, args...)...) + c := exec.Command("/proc/self/exe", append([]string{"--loglevel", logStr, "--overlaydir", overlayDir, "container", "exec", "__child"}, args...)...) c.SysProcAttr = &syscall.SysProcAttr{ Cloneflags: syscall.CLONE_NEWUTS | syscall.CLONE_NEWPID | syscall.CLONE_NEWNS, @@ -45,16 +46,7 @@ func runContainedCmd(args []string) error { c.Stdout = os.Stdout c.Stderr = os.Stderr - if err := c.Run(); err != nil { - fmt.Printf("Command exited non-zero, not rebuilding/updating VNFS image\n") - // defer is not called before os.Exit(0) - err = os.RemoveAll(tempDir) - if err != nil { - wwlog.Warn("Couldn't remove temp dir for ephermal mounts:", err) - } - os.Exit(0) - } - return nil + return c.Run() } func CobraRunE(cmd *cobra.Command, args []string) error { diff --git a/internal/app/wwctl/container/exec/root.go b/internal/app/wwctl/container/exec/root.go index a59b42c11..f68fa6202 100644 --- a/internal/app/wwctl/container/exec/root.go +++ b/internal/app/wwctl/container/exec/root.go @@ -25,17 +25,17 @@ var ( }, FParseErrWhitelist: cobra.FParseErrWhitelist{UnknownFlags: true}, } - SyncUser bool - binds []string - tempDir string - nodeName string + SyncUser bool + binds []string + overlayDir string + nodeName string ) func init() { baseCmd.AddCommand(child.GetCommand()) baseCmd.PersistentFlags().StringArrayVarP(&binds, "bind", "b", []string{}, "Bind a local path into the container (must exist)") baseCmd.PersistentFlags().BoolVar(&SyncUser, "syncuser", false, "Synchronize UIDs/GIDs from host to container") - baseCmd.PersistentFlags().StringVar(&tempDir, "tempdir", "", "Use tempdir for constructing the overlay fs (only used if mount points don't exist in container)") + baseCmd.PersistentFlags().StringVar(&overlayDir, "overlaydir", "", "Use tempdir for constructing the overlay fs (only used if mount points don't exist in container)") baseCmd.PersistentFlags().StringVarP(&nodeName, "node", "n", "", "Create a read only view of the container for the given node") } From 0eba83795004d033ad1cd64d16321d99bf8131fb Mon Sep 17 00:00:00 2001 From: Christian Goll Date: Tue, 6 Feb 2024 12:25:14 +0100 Subject: [PATCH 2/3] use warewulf.conf from parent on child The directories for the overlays needed for the bind mount are now created under conf.Paths.WWChrootdir/$CONTAINERNAME with the pattern $CONTAINERNAME-run-xxxxxx. This pattern can be used as lock, so that there can't be congruent shell/exec calls to the same container. Signed-off-by: Christian Goll --- CHANGELOG.md | 5 ++++ .../app/wwctl/container/exec/child/main.go | 2 +- internal/app/wwctl/container/exec/main.go | 30 ++++++++++--------- internal/pkg/config/root.go | 12 +++++--- internal/pkg/config/root_test.go | 1 + 5 files changed, 31 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4edb4d07f..ebc2196d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -60,6 +60,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Reduce the number of times syncuser walks the container file system. #1209 - Create ssh key also when calling `wwctl configure --all` #1250 - Remove the temporary overlay dir. #1180 +- Remove the temporary overlayfs dir and create them besides rootfs #1180 ### Security @@ -71,6 +72,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Allow specification of the ssh-keys to be to be created. #1185 +### Changed + +- The command `wwctl container exec` locks now this container during execution. #830 + ### Fixed - Fix nightly release build failure issue. #1195 diff --git a/internal/app/wwctl/container/exec/child/main.go b/internal/app/wwctl/container/exec/child/main.go index bf4095081..3052faa2b 100644 --- a/internal/app/wwctl/container/exec/child/main.go +++ b/internal/app/wwctl/container/exec/child/main.go @@ -21,7 +21,7 @@ import ( "github.com/warewulf/warewulf/internal/pkg/wwlog" ) -const exitEval = `$(VALU="$?" ; if [ $VALU == 0 ]; then echo write; else echo discard; fi)` +const exitEval = `$(VALU="$?" ; if [ $VALU == 0 ]; then echo create new image; else echo no new image; fi)` func CobraRunE(cmd *cobra.Command, args []string) (err error) { if os.Getpid() != 1 { diff --git a/internal/app/wwctl/container/exec/main.go b/internal/app/wwctl/container/exec/main.go index 80140a675..8f16120ef 100644 --- a/internal/app/wwctl/container/exec/main.go +++ b/internal/app/wwctl/container/exec/main.go @@ -4,15 +4,18 @@ package exec import ( + "errors" "fmt" "os" "os/exec" "path" + "path/filepath" "syscall" "time" - "github.com/spf13/cobra" warewulfconf "github.com/warewulf/warewulf/internal/pkg/config" + + "github.com/spf13/cobra" "github.com/warewulf/warewulf/internal/pkg/container" "github.com/warewulf/warewulf/internal/pkg/util" "github.com/warewulf/warewulf/internal/pkg/wwlog" @@ -22,22 +25,21 @@ import ( fork off a process with a new PID space */ func runContainedCmd(args []string) (err error) { - if overlayDir == "" { - conf := warewulfconf.Get() - overlayDir, err = os.MkdirTemp(conf.Paths.WWChrootdir, "overlays-") - if err != nil { - wwlog.Warn("couldn't create temp dir for overlay", err) - } - defer func() { - err = os.RemoveAll(overlayDir) - if err != nil { - wwlog.Warn("Couldn't remove temp dir for ephermal mounts:", err) - } - }() + conf := warewulfconf.Get() + if matches, _ := filepath.Glob(path.Join(conf.Paths.WWChrootdir, args[0], args[0]) + "-run-*"); len(matches) > 0 { + return fmt.Errorf("found lock directories for container: %v", matches) + } + overlayDir, err = os.MkdirTemp(path.Join(conf.Paths.WWChrootdir, args[0]), args[0]+"-run-") + if err != nil { + wwlog.Warn("couldn't create temp dir for overlay", err) } + defer func() { + err = errors.Join(os.RemoveAll(overlayDir), err) + }() + logStr := fmt.Sprint(wwlog.GetLogLevel()) wwlog.Verbose("Running contained command: %s", args[1:]) - c := exec.Command("/proc/self/exe", append([]string{"--loglevel", logStr, "--overlaydir", overlayDir, "container", "exec", "__child"}, args...)...) + c := exec.Command("/proc/self/exe", append([]string{"--warewulfconf", conf.GetWarewulfConf(), "--loglevel", logStr, "--overlaydir", overlayDir, "container", "exec", "__child"}, args...)...) c.SysProcAttr = &syscall.SysProcAttr{ Cloneflags: syscall.CLONE_NEWUTS | syscall.CLONE_NEWPID | syscall.CLONE_NEWNS, diff --git a/internal/pkg/config/root.go b/internal/pkg/config/root.go index c24e84e7e..89c6b944c 100644 --- a/internal/pkg/config/root.go +++ b/internal/pkg/config/root.go @@ -42,14 +42,14 @@ type RootConf struct { MountsContainer []*MountEntry `yaml:"container mounts" default:"[{\"source\": \"/etc/resolv.conf\", \"dest\": \"/etc/resolv.conf\"}]"` Paths *BuildConfig `yaml:"paths"` - fromFile bool + warewulfconf string } // New caches and returns a new [RootConf] initialized with empty // values, clearing replacing any previously cached value. func New() *RootConf { cachedConf = RootConf{} - cachedConf.fromFile = false + cachedConf.warewulfconf = "" cachedConf.Warewulf = new(WarewulfConf) cachedConf.DHCP = new(DHCPConf) cachedConf.TFTP = new(TFTPConf) @@ -77,12 +77,12 @@ func Get() *RootConf { // file. func (conf *RootConf) Read(confFileName string) error { wwlog.Debug("Reading warewulf.conf from: %s", confFileName) + conf.warewulfconf = confFileName if data, err := os.ReadFile(confFileName); err != nil { return err } else if err := conf.Parse(data); err != nil { return err } else { - conf.fromFile = true return nil } } @@ -200,5 +200,9 @@ func (conf *RootConf) SetDynamicDefaults() (err error) { // InitializedFromFile returns true if [RootConf] memory was read from // a file, or false otherwise. func (conf *RootConf) InitializedFromFile() bool { - return conf.fromFile + return conf.warewulfconf != "" +} + +func (conf *RootConf) GetWarewulfConf() string { + return conf.warewulfconf } diff --git a/internal/pkg/config/root_test.go b/internal/pkg/config/root_test.go index 7cf0812c0..4511e47de 100644 --- a/internal/pkg/config/root_test.go +++ b/internal/pkg/config/root_test.go @@ -67,6 +67,7 @@ func TestInitializedFromFile(t *testing.T) { assert.False(t, conf.InitializedFromFile()) assert.NoError(t, conf.Read(tempWarewulfConf.Name())) assert.True(t, conf.InitializedFromFile()) + assert.Equal(t, conf.GetWarewulfConf(), tempWarewulfConf.Name()) } func TestExampleRootConf(t *testing.T) { From 2c5e079d336d8abf87c52e13e9321c473d8c8eb9 Mon Sep 17 00:00:00 2001 From: Jonathon Anderson Date: Thu, 6 Jun 2024 16:59:48 -0400 Subject: [PATCH 3/3] Refactor overlayDir to container.RunDir() Signed-off-by: Jonathon Anderson --- .../app/wwctl/container/exec/child/main.go | 41 ++++++++++--------- .../app/wwctl/container/exec/child/root.go | 7 +--- internal/app/wwctl/container/exec/main.go | 22 +++++----- internal/app/wwctl/container/exec/root.go | 8 ++-- internal/pkg/container/config.go | 4 ++ 5 files changed, 42 insertions(+), 40 deletions(-) diff --git a/internal/app/wwctl/container/exec/child/main.go b/internal/app/wwctl/container/exec/child/main.go index 3052faa2b..62d09a201 100644 --- a/internal/app/wwctl/container/exec/child/main.go +++ b/internal/app/wwctl/container/exec/child/main.go @@ -21,8 +21,6 @@ import ( "github.com/warewulf/warewulf/internal/pkg/wwlog" ) -const exitEval = `$(VALU="$?" ; if [ $VALU == 0 ]; then echo create new image; else echo no new image; fi)` - func CobraRunE(cmd *cobra.Command, args []string) (err error) { if os.Getpid() != 1 { wwlog.Error("PID is not 1: %d", os.Getpid()) @@ -36,8 +34,9 @@ func CobraRunE(cmd *cobra.Command, args []string) (err error) { os.Exit(1) } conf := warewulfconf.Get() - if overlayDir == "" { - overlayDir = path.Join(conf.Paths.WWChrootdir, "overlays") + runDir := container.RunDir(containerName) + if _, err := os.Stat(runDir); os.IsNotExist(err) { + return errors.Wrap(err, "container run directory does not exist") } mountPts := conf.MountsContainer mountPts = append(container.InitMountPnts(binds), mountPts...) @@ -45,11 +44,16 @@ func CobraRunE(cmd *cobra.Command, args []string) (err error) { lowerObjects := checkMountPoints(containerName, mountPts) // need to create a overlay, where the lower layer contains // the missing mount points - wwlog.Verbose("for ephermal mount use tempdir %s", overlayDir) - // ignore errors as we are doomed if a tmp dir couldn't be written - _ = os.MkdirAll(path.Join(overlayDir, "work"), os.ModePerm) - _ = os.MkdirAll(path.Join(overlayDir, "lower"), os.ModePerm) - _ = os.MkdirAll(path.Join(overlayDir, "nodeoverlay"), os.ModePerm) + wwlog.Verbose("for ephermal mount use tempdir %s", runDir) + if err = os.Mkdir(path.Join(runDir, "work"), os.ModePerm); err != nil { + return err + } + if err = os.Mkdir(path.Join(runDir, "lower"), os.ModePerm); err != nil { + return err + } + if err = os.Mkdir(path.Join(runDir, "nodeoverlay"), os.ModePerm); err != nil { + return err + } // handle all lower object, have some extra logic if the object is a file for _, obj := range lowerObjects { newFile := "" @@ -57,12 +61,12 @@ func CobraRunE(cmd *cobra.Command, args []string) (err error) { newFile = filepath.Base(obj) obj = filepath.Dir(obj) } - err = os.MkdirAll(filepath.Join(overlayDir, "lower", obj), os.ModePerm) + err = os.Mkdir(filepath.Join(runDir, "lower", obj), os.ModePerm) if err != nil { wwlog.Warn("couldn't create directory for mounts: %s", err) } if newFile != "" { - desc, err := os.Create(filepath.Join(overlayDir, "lower", obj, newFile)) + desc, err := os.Create(filepath.Join(runDir, "lower", obj, newFile)) if err != nil { wwlog.Warn("couldn't create directory for mounts: %s", err) } @@ -75,10 +79,10 @@ func CobraRunE(cmd *cobra.Command, args []string) (err error) { if err != nil { return errors.Wrap(err, "failed to mount") } - ps1Str := fmt.Sprintf("[%s|%s] Warewulf> ", exitEval, containerName) + ps1Str := fmt.Sprintf("[%s] Warewulf> ", containerName) if len(lowerObjects) != 0 && nodename == "" { options := fmt.Sprintf("lowerdir=%s,upperdir=%s,workdir=%s", - path.Join(overlayDir, "lower"), containerPath, path.Join(overlayDir, "work")) + path.Join(runDir, "lower"), containerPath, path.Join(runDir, "work")) wwlog.Debug("overlay options: %s", options) err = syscall.Mount("overlay", containerPath, "overlay", 0, options) if err != nil { @@ -103,13 +107,13 @@ func CobraRunE(cmd *cobra.Command, args []string) (err error) { } overlays := nodes[0].SystemOverlay.GetSlice() overlays = append(overlays, nodes[0].RuntimeOverlay.GetSlice()...) - err = overlay.BuildOverlayIndir(nodes[0], overlays, path.Join(overlayDir, "nodeoverlay")) + err = overlay.BuildOverlayIndir(nodes[0], overlays, path.Join(runDir, "nodeoverlay")) if err != nil { wwlog.Error("Could not build overlay: %s", err) os.Exit(1) } options := fmt.Sprintf("lowerdir=%s:%s:%s", - path.Join(overlayDir, "lower"), containerPath, path.Join(overlayDir, "nodeoverlay")) + path.Join(runDir, "lower"), containerPath, path.Join(runDir, "nodeoverlay")) wwlog.Debug("overlay options: %s", options) err = syscall.Mount("overlay", containerPath, "overlay", 0, options) if err != nil { @@ -171,11 +175,8 @@ func CobraRunE(cmd *cobra.Command, args []string) (err error) { os.Setenv("PATH", "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin") os.Setenv("HISTFILE", "/dev/null") - _ = syscall.Exec(args[1], args[1:], os.Environ()) - /* - Exec replaces the actual program, so nothing to do here afterwards - */ - return nil + wwlog.Debug("Exec: %s %s", args[1], args[1:]) + return syscall.Exec(args[1], args[1:], os.Environ()) } /* diff --git a/internal/app/wwctl/container/exec/child/root.go b/internal/app/wwctl/container/exec/child/root.go index ab72086d4..ad807a6fd 100644 --- a/internal/app/wwctl/container/exec/child/root.go +++ b/internal/app/wwctl/container/exec/child/root.go @@ -13,16 +13,13 @@ var ( Args: cobra.MinimumNArgs(1), FParseErrWhitelist: cobra.FParseErrWhitelist{UnknownFlags: true}, } - binds []string - nodename string - overlayDir string + binds []string + nodename string ) func init() { baseCmd.Flags().StringVarP(&nodename, "node", "n", "", "create ro overlay for given node") baseCmd.Flags().StringArrayVarP(&binds, "bind", "b", []string{}, "bind points") - baseCmd.Flags().StringVar(&overlayDir, "overlaydir", "", "overlayDir") - } // GetRootCommand returns the root cobra.Command for the application. diff --git a/internal/app/wwctl/container/exec/main.go b/internal/app/wwctl/container/exec/main.go index 8f16120ef..4de99940e 100644 --- a/internal/app/wwctl/container/exec/main.go +++ b/internal/app/wwctl/container/exec/main.go @@ -9,7 +9,6 @@ import ( "os" "os/exec" "path" - "path/filepath" "syscall" "time" @@ -26,20 +25,23 @@ fork off a process with a new PID space */ func runContainedCmd(args []string) (err error) { conf := warewulfconf.Get() - if matches, _ := filepath.Glob(path.Join(conf.Paths.WWChrootdir, args[0], args[0]) + "-run-*"); len(matches) > 0 { - return fmt.Errorf("found lock directories for container: %v", matches) - } - overlayDir, err = os.MkdirTemp(path.Join(conf.Paths.WWChrootdir, args[0]), args[0]+"-run-") - if err != nil { - wwlog.Warn("couldn't create temp dir for overlay", err) + containerName := args[0] + runDir := container.RunDir(containerName) + if err := os.Mkdir(runDir, 0750); err != nil { + if _, existerr := os.Stat(runDir); !os.IsNotExist(existerr) { + return errors.New("run directory already exists: another container command may already be running") + } else { + return fmt.Errorf("unable to create run directory: %w", err) + } } defer func() { - err = errors.Join(os.RemoveAll(overlayDir), err) + if err := errors.Join(os.RemoveAll(runDir), err); err != nil { + wwlog.Error("error removing run directory: %w", err) + } }() - logStr := fmt.Sprint(wwlog.GetLogLevel()) wwlog.Verbose("Running contained command: %s", args[1:]) - c := exec.Command("/proc/self/exe", append([]string{"--warewulfconf", conf.GetWarewulfConf(), "--loglevel", logStr, "--overlaydir", overlayDir, "container", "exec", "__child"}, args...)...) + c := exec.Command("/proc/self/exe", append([]string{"--warewulfconf", conf.GetWarewulfConf(), "--loglevel", logStr, "container", "exec", "__child"}, args...)...) c.SysProcAttr = &syscall.SysProcAttr{ Cloneflags: syscall.CLONE_NEWUTS | syscall.CLONE_NEWPID | syscall.CLONE_NEWNS, diff --git a/internal/app/wwctl/container/exec/root.go b/internal/app/wwctl/container/exec/root.go index f68fa6202..4b74c941b 100644 --- a/internal/app/wwctl/container/exec/root.go +++ b/internal/app/wwctl/container/exec/root.go @@ -25,17 +25,15 @@ var ( }, FParseErrWhitelist: cobra.FParseErrWhitelist{UnknownFlags: true}, } - SyncUser bool - binds []string - overlayDir string - nodeName string + SyncUser bool + binds []string + nodeName string ) func init() { baseCmd.AddCommand(child.GetCommand()) baseCmd.PersistentFlags().StringArrayVarP(&binds, "bind", "b", []string{}, "Bind a local path into the container (must exist)") baseCmd.PersistentFlags().BoolVar(&SyncUser, "syncuser", false, "Synchronize UIDs/GIDs from host to container") - baseCmd.PersistentFlags().StringVar(&overlayDir, "overlaydir", "", "Use tempdir for constructing the overlay fs (only used if mount points don't exist in container)") baseCmd.PersistentFlags().StringVarP(&nodeName, "node", "n", "", "Create a read only view of the container for the given node") } diff --git a/internal/pkg/container/config.go b/internal/pkg/container/config.go index 902827eaf..afbd3b40b 100644 --- a/internal/pkg/container/config.go +++ b/internal/pkg/container/config.go @@ -33,6 +33,10 @@ func RootFsDir(name string) string { return path.Join(SourceDir(name), "rootfs") } +func RunDir(name string) string { + return path.Join(SourceDir(name), "run") +} + func ImageParentDir() string { conf := warewulfconf.Get() return path.Join(conf.Paths.WWProvisiondir, "container/")