Merge pull request #1358 from JasonYangShadow/fix/1344

Add --syncuser flag to wwctl shell
This commit is contained in:
Jonathon Anderson
2024-09-23 11:32:30 -06:00
committed by GitHub
4 changed files with 9 additions and 6 deletions

View File

@@ -46,9 +46,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## v4.5.8, unreleased
### Added
- Added `--syncuser` flag to `wwctl container shell`. #1358
### Changed
- Interleave tmpfs across all available NUMA nodes. #1347, #1348
- Syncuser watches for changes in mtime rather than ctime. #1358
### Fixed

View File

@@ -166,7 +166,7 @@ func getTime(path string) time.Time {
return time.Time{}
} else {
unixStat := fileStat.Sys().(*syscall.Stat_t)
return time.Unix(int64(unixStat.Ctim.Sec), int64(unixStat.Ctim.Nsec))
return time.Unix(int64(unixStat.Mtim.Sec), int64(unixStat.Mtim.Nsec))
}
}

View File

@@ -22,11 +22,6 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
wwlog.Error("Unknown Warewulf container: %s", containerName)
os.Exit(1)
}
/*
for _, b := range binds {
allargs = append(allargs, "--bind", b)
}
*/
shellName := os.Getenv("SHELL")
if !container.ValidSource(containerName) {
wwlog.Error("Unknown Warewulf container: %s", containerName)
@@ -49,5 +44,6 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
wwlog.Debug("Calling exec with args: %s", allargs)
cntexec.SetBinds(binds)
cntexec.SetNode(nodeName)
cntexec.SyncUser = syncUser
return cntexec.CobraRunE(cmd, allargs)
}

View File

@@ -25,6 +25,7 @@ var (
}
binds []string
nodeName string
syncUser bool
)
func init() {
@@ -33,6 +34,7 @@ Bind a local path which must exist into the container. If destination is not
set, uses the same path as source. "ro" binds read-only. "copy" temporarily
copies the file into the container.`)
baseCmd.PersistentFlags().StringVarP(&nodeName, "node", "n", "", "Create a read only view of the container for the given node")
baseCmd.PersistentFlags().BoolVar(&syncUser, "syncuser", false, "Synchronize UIDs/GIDs from host to container")
}
// GetRootCommand returns the root cobra.Command for the application.