Add syncuser to wwctl container shell and switch to mtime
Signed-off-by: xu yang <xyang@ciq.com>
This commit is contained in:
committed by
Jonathon Anderson
parent
43b298f3aa
commit
0b3eace403
@@ -124,6 +124,10 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
}
|
||||
|
||||
// getting syncuser from cmd, e.g., shell comamnd will call exec command and passing --syncuser
|
||||
if syncUserFlag, err := cmd.Flags().GetBool("syncuser"); err == nil {
|
||||
SyncUser = SyncUser || syncUserFlag
|
||||
}
|
||||
userdbChanged := false
|
||||
if !beforePasswdTime.IsZero() {
|
||||
afterPasswdTime := getTime(path.Join(containerPath, "/etc/passwd"))
|
||||
@@ -166,7 +170,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))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user