Don't do SyncUids by default always

This commit is contained in:
Gregory Kurtzer
2022-05-03 21:52:13 -07:00
parent c95c518dde
commit 60b586b69a
2 changed files with 6 additions and 6 deletions

View File

@@ -78,7 +78,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
unixStat = fileStat.Sys().(*syscall.Stat_t)
syncuids := false
if passwdTime.Before(time.Unix(int64(unixStat.Ctim.Sec), int64(unixStat.Ctim.Nsec))) {
if NoSyncUser {
if !SyncUser {
wwlog.Printf(wwlog.WARN, "/etc/passwd has been modified, maybe you want to run syncuser\n")
}
syncuids = true
@@ -87,13 +87,13 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
fileStat, _ = os.Stat(path.Join(containerPath, "/etc/group"))
unixStat = fileStat.Sys().(*syscall.Stat_t)
if groupTime.Before(time.Unix(int64(unixStat.Ctim.Sec), int64(unixStat.Ctim.Nsec))) {
if NoSyncUser {
if !SyncUser {
wwlog.Printf(wwlog.WARN, "/etc/group has been modified, maybe you want to run syncuser\n")
}
syncuids = true
}
wwlog.Printf(wwlog.DEBUG, "group: %v\n", time.Unix(int64(unixStat.Ctim.Sec), int64(unixStat.Ctim.Nsec)))
if syncuids && !NoSyncUser {
if syncuids && SyncUser {
err = container.SyncUids(containerName, true)
if err != nil {
wwlog.Printf(wwlog.ERROR, "Error in user sync, fix error and run 'syncuser' manually, but trying to build container: %s\n", err)

View File

@@ -25,14 +25,14 @@ var (
},
FParseErrWhitelist: cobra.FParseErrWhitelist{UnknownFlags: true},
}
NoSyncUser bool
binds []string
SyncUser bool
binds []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(&NoSyncUser, "nosyncuser", false, "Don't synchronize uis/gods from host to container")
baseCmd.PersistentFlags().BoolVar(&SyncUser, "syncuser", false, "Synchronize UIDs/GIDs from host to container")
}
// GetRootCommand returns the root cobra.Command for the application.