will always run syncuids on exec and import
This commit is contained in:
committed by
Christian Goll
parent
7f1636c9a9
commit
db2dcbfbe2
@@ -78,16 +78,26 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
fileStat, _ = os.Stat(path.Join(containerPath, "/etc/passwd"))
|
||||
unixStat = fileStat.Sys().(*syscall.Stat_t)
|
||||
syncuids := false
|
||||
if passwdTime.Before(time.Unix(int64(unixStat.Ctim.Sec), int64(unixStat.Ctim.Nsec))) {
|
||||
wwlog.Printf(wwlog.WARN, "/etc/passwd has been modified, maybe you want to run syncuser\n")
|
||||
if NoSyncUser {
|
||||
wwlog.Printf(wwlog.WARN, "/etc/passwd has been modified, maybe you want to run syncuser\n")
|
||||
}
|
||||
syncuids = true
|
||||
}
|
||||
wwlog.Printf(wwlog.DEBUG, "passwd: %v\n", time.Unix(int64(unixStat.Ctim.Sec), int64(unixStat.Ctim.Nsec)))
|
||||
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))) {
|
||||
wwlog.Printf(wwlog.WARN, "/etc/group has been modified, maybe you want to run syncuser\n")
|
||||
if NoSyncUser {
|
||||
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 {
|
||||
container.SyncUids(containerName, true)
|
||||
}
|
||||
|
||||
fmt.Printf("Rebuilding container...\n")
|
||||
err = container.Build(containerName, false)
|
||||
|
||||
@@ -25,12 +25,14 @@ var (
|
||||
},
|
||||
FParseErrWhitelist: cobra.FParseErrWhitelist{UnknownFlags: true},
|
||||
}
|
||||
binds []string
|
||||
NoSyncUser 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")
|
||||
}
|
||||
|
||||
// GetRootCommand returns the root cobra.Command for the application.
|
||||
|
||||
@@ -129,8 +129,8 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
wwlog.Printf(wwlog.WARN, "Could not copy /etc/resolv.conf into container: %s\n", err)
|
||||
}
|
||||
|
||||
err = container.SyncUids(name, SyncUser)
|
||||
if err != nil && SyncUser {
|
||||
err = container.SyncUids(name, !NoSyncUser)
|
||||
if err != nil && !NoSyncUser {
|
||||
wwlog.Printf(wwlog.ERROR, "Error in user sync, fix error and run 'syncuser' manually: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ Imported containers are used to create bootable VNFS images.`,
|
||||
SetUpdate bool
|
||||
SetBuild bool
|
||||
SetDefault bool
|
||||
SyncUser bool
|
||||
NoSyncUser bool
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -26,7 +26,7 @@ func init() {
|
||||
baseCmd.PersistentFlags().BoolVarP(&SetUpdate, "update", "u", false, "Update and overwrite an existing container")
|
||||
baseCmd.PersistentFlags().BoolVarP(&SetBuild, "build", "b", false, "Build container when after pulling")
|
||||
baseCmd.PersistentFlags().BoolVar(&SetDefault, "setdefault", false, "Set this container for the default profile")
|
||||
baseCmd.PersistentFlags().BoolVar(&SyncUser, "syncuser", false, "Don't synchronize uis/gods from host to container")
|
||||
baseCmd.PersistentFlags().BoolVar(&NoSyncUser, "nosyncuser", false, "Don't synchronize uis/gods from host to container")
|
||||
}
|
||||
|
||||
// GetRootCommand returns the root cobra.Command for the application.
|
||||
|
||||
Reference in New Issue
Block a user