Merge pull request #422 from mslacken/fix_syncuid

syncucer will only write witrh syncuser switch
This commit is contained in:
Christian Goll
2022-05-12 11:59:00 +02:00
committed by GitHub
5 changed files with 9 additions and 8 deletions

View File

@@ -130,8 +130,8 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
wwlog.Printf(wwlog.WARN, "Could not copy /etc/resolv.conf into container: %s\n", err) wwlog.Printf(wwlog.WARN, "Could not copy /etc/resolv.conf into container: %s\n", err)
} }
err = container.SyncUids(name, !NoSyncUser) err = container.SyncUids(name, !SyncUser)
if err != nil && !NoSyncUser { if err != nil && !SyncUser {
wwlog.Printf(wwlog.ERROR, "Error in user sync, fix error and run 'syncuser' manually: %s\n", err) wwlog.Printf(wwlog.ERROR, "Error in user sync, fix error and run 'syncuser' manually: %s\n", err)
os.Exit(1) os.Exit(1)
} }

View File

@@ -24,7 +24,7 @@ Imported containers are used to create bootable VNFS images.`,
SetUpdate bool SetUpdate bool
SetBuild bool SetBuild bool
SetDefault bool SetDefault bool
NoSyncUser bool SyncUser bool
) )
func init() { func init() {
@@ -32,7 +32,7 @@ func init() {
baseCmd.PersistentFlags().BoolVarP(&SetUpdate, "update", "u", false, "Update and overwrite an existing container") 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().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(&SetDefault, "setdefault", false, "Set this container for the default profile")
baseCmd.PersistentFlags().BoolVar(&NoSyncUser, "nosyncuser", false, "Don't synchronize uis/gods from host to container") baseCmd.PersistentFlags().BoolVar(&SyncUser, "syncuser", false, "Synchronize uis/gods from host to container")
} }
// GetRootCommand returns the root cobra.Command for the application. // GetRootCommand returns the root cobra.Command for the application.

View File

@@ -14,7 +14,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
if !container.ValidName(containerName) { if !container.ValidName(containerName) {
return fmt.Errorf("%s is not a valid container", containerName) return fmt.Errorf("%s is not a valid container", containerName)
} }
err := container.SyncUids(containerName, noSyncUser) err := container.SyncUids(containerName, !write)
if err != nil { if err != nil {
wwlog.Printf(wwlog.ERROR, "Error in synchronize: %s\n", err) wwlog.Printf(wwlog.ERROR, "Error in synchronize: %s\n", err)
os.Exit(1) os.Exit(1)

View File

@@ -24,11 +24,11 @@ uid/gid collision is detected. File ownerships are also changed.`,
Args: cobra.MinimumNArgs(1), Args: cobra.MinimumNArgs(1),
} }
noSyncUser bool write bool
) )
func init() { func init() {
baseCmd.PersistentFlags().BoolVar(&noSyncUser, "nosyncuser", false, "Don't synchronize uis/gods just check") baseCmd.PersistentFlags().BoolVar(&write, "write", false, "Synchronize uis/gids and write files in container")
} }
// GetRootCommand returns the root cobra.Command for the application. // GetRootCommand returns the root cobra.Command for the application.

View File

@@ -100,7 +100,8 @@ func SyncUids(containerName string, showOnly bool) error {
*/ */
} }
if !showOnly { if showOnly {
wwlog.Printf(wwlog.INFO, "uid./gid not synced, run \nwwctl container syncuser --write %s\nto synchronize uid/gids.\n", containerName)
return nil return nil
} }
// create list of files which need changed ownerships in order to change them later what // create list of files which need changed ownerships in order to change them later what