Merge pull request #415 from gmkurtzer/minor_fixups_for_4.3.0

Minor fix ups for 4.3.0
This commit is contained in:
Gregory M. Kurtzer
2022-05-03 22:24:44 -07:00
committed by GitHub
5 changed files with 11 additions and 9 deletions

View File

@@ -69,7 +69,7 @@ TFTPDIR ?= /var/lib/tftpboot
# Warewulf directory paths
VARLIST += WWCLIENTDIR WWCONFIGDIR WWPROVISIONDIR WWOVERLAYDIR WWCHROOTDIR WWTFTPDIR WWDOCDIR WWDATADIR
WWCONFIGDIR := $(SYSCONFDIR)/$(WAREWULF)
WWPROVISIONDIR := $(LOCALSTATEDIR)/$(WAREWULF)
WWPROVISIONDIR := $(SRVDIR)/$(WAREWULF)
WWOVERLAYDIR := $(LOCALSTATEDIR)/$(WAREWULF)/overlays
WWCHROOTDIR := $(LOCALSTATEDIR)/$(WAREWULF)/chroots
WWTFTPDIR := $(TFTPDIR)/$(WAREWULF)

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.

View File

@@ -248,7 +248,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting HW address to: %s\n", n.Id.Get(), SetNetName, SetHwaddr)
n.NetDevs[SetNetName].Hwaddr.Set(strings.ToLower(SetHwaddr))
n.NetDevs[SetNetName].Hwaddr.Set(SetHwaddr)
}
if SetType != "" {

View File

@@ -1,6 +1,7 @@
package warewulfd
import (
"strings"
"sync"
"github.com/pkg/errors"
@@ -32,7 +33,8 @@ func LoadNodeDB() error {
for _, n := range nodes {
for _, netdev := range n.NetDevs {
TmpMap[netdev.Hwaddr.Get()] = n
hwaddr := strings.ToLower(netdev.Hwaddr.Get())
TmpMap[hwaddr] = n
}
}