Merge pull request #853 from mslacken/fixBuildNoNetwork
fix SIGSEV if build host has no network
This commit is contained in:
@@ -43,12 +43,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
- The primary hostname and warewulf server fqdn are now the canonical name in
|
||||
`/etc/hosts`
|
||||
|
||||
- Refactored `profile add` command to make it alike `node add`. #658 #659
|
||||
|
||||
- The ifcfg ONBOOT parameter is no longer statically `true`, so unconfigured
|
||||
interfaces may not be enabled by default. (#644)
|
||||
|
||||
- Write log messages to stderr rather than stdout. #768
|
||||
- new subcommand `wwctl genconf` is available with following subcommands:
|
||||
* `completions` which will create the files used for bash-completion. Also
|
||||
fish an zsh completions can be generated
|
||||
@@ -58,19 +56,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
* `warwulfconf print` which will print the used `warewulf.conf`. If there is no valid
|
||||
`warewulf.conf` a valid configuration is provided, prefilled with default values
|
||||
and an IP configuration derived from the network configuration of the host
|
||||
|
||||
- All paths can now be configured in `warewulf.conf`, check the paths section of of
|
||||
`wwctl --emptyconf genconfig warewulfconf print` for the available paths.
|
||||
|
||||
- Added experimental dnsmasq support.
|
||||
|
||||
- fix SIGSEV when build host has no network #907
|
||||
- Check for formal correct IP and MAC addresses for command line options and
|
||||
when reading in the configurations
|
||||
- Added template to create genders database
|
||||
- Write log messages to stderr rather than stdout. #768
|
||||
- Updates to Makefile for clarity, notably removing genconfig and replacing
|
||||
test-it with test. #890
|
||||
|
||||
- realy reboot also without systemd
|
||||
- Specify primary network device per-node rather than per-netdev
|
||||
- refactored output `wwctl node/profile list` so that `-a` will only show all the
|
||||
|
||||
@@ -26,4 +26,5 @@
|
||||
* Brian Phan <bphan@ciq.com>
|
||||
* Jeffrey Frey @jtfrey
|
||||
* Xu Yang(Jason Yang) <jasonyangshadow@gmail.com> @JasonYangShadow
|
||||
* Matt Jolly <Kangie@footclan.ninja> @Kangie
|
||||
* Arnaud LECOMTE <contact@arnaud-lcm.com>
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
// DHCP, TFTP and NFS services that Warewulf manages.
|
||||
package config
|
||||
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
@@ -20,10 +19,8 @@ import (
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
|
||||
var cachedConf RootConf
|
||||
|
||||
|
||||
// RootConf is the main Warewulf configuration structure. It stores
|
||||
// some information about the Warewulf server locally, and has
|
||||
// [WarewulfConf], [DHCPConf], [TFTPConf], and [NFSConf] sub-sections.
|
||||
@@ -43,13 +40,12 @@ type RootConf struct {
|
||||
MountsContainer []*MountEntry `yaml:"container mounts" default:"[{\"source\": \"/etc/resolv.conf\", \"dest\": \"/etc/resolv.conf\"}]"`
|
||||
Paths *BuildConfig `yaml:"paths"`
|
||||
|
||||
fromFile bool
|
||||
fromFile bool
|
||||
}
|
||||
|
||||
|
||||
// New caches and returns a new [RootConf] initialized with empty
|
||||
// values, clearing replacing any previously cached value.
|
||||
func New() (*RootConf) {
|
||||
func New() *RootConf {
|
||||
cachedConf = RootConf{}
|
||||
cachedConf.fromFile = false
|
||||
cachedConf.Warewulf = new(WarewulfConf)
|
||||
@@ -63,10 +59,9 @@ func New() (*RootConf) {
|
||||
return &cachedConf
|
||||
}
|
||||
|
||||
|
||||
// Get returns a previously cached [RootConf] if it exists, or returns
|
||||
// a new RootConf.
|
||||
func Get() (*RootConf) {
|
||||
func Get() *RootConf {
|
||||
// NOTE: This function can be called before any log level is set
|
||||
// so using wwlog.Verbose or wwlog.Debug won't work
|
||||
if reflect.ValueOf(cachedConf).IsZero() {
|
||||
@@ -75,10 +70,9 @@ func Get() (*RootConf) {
|
||||
return &cachedConf
|
||||
}
|
||||
|
||||
|
||||
// Read populates [RootConf] with the values from a configuration
|
||||
// file.
|
||||
func (conf *RootConf) Read(confFileName string) (error) {
|
||||
func (conf *RootConf) Read(confFileName string) error {
|
||||
wwlog.Debug("Reading warewulf.conf from: %s", confFileName)
|
||||
if data, err := os.ReadFile(confFileName); err != nil {
|
||||
return err
|
||||
@@ -90,9 +84,8 @@ func (conf *RootConf) Read(confFileName string) (error) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Parse populates [RootConf] with the values from a yaml document.
|
||||
func (conf *RootConf) Parse(data []byte) (error) {
|
||||
func (conf *RootConf) Parse(data []byte) error {
|
||||
// ipxe binaries are merged not overwritten, store defaults separate
|
||||
defIpxe := make(map[string]string)
|
||||
for k, v := range conf.TFTP.IpxeBinaries {
|
||||
@@ -108,7 +101,6 @@ func (conf *RootConf) Parse(data []byte) (error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
// SetDynamicDefaults populates [RootConf] with plausible defaults for
|
||||
// the runtime environment.
|
||||
func (conf *RootConf) SetDynamicDefaults() (err error) {
|
||||
@@ -119,12 +111,16 @@ func (conf *RootConf) SetDynamicDefaults() (err error) {
|
||||
|
||||
if conf.Ipaddr == "" {
|
||||
wwlog.Verbose("Configuration has no valid network, going to dynamic values")
|
||||
conn, _ := net.Dial("udp", "8.8.8.8:80")
|
||||
defer conn.Close()
|
||||
ipaddr = conn.LocalAddr().(*net.UDPAddr).IP
|
||||
mask = ipaddr.DefaultMask()
|
||||
sz, _ := mask.Size()
|
||||
conf.Ipaddr = ipaddr.String() + fmt.Sprintf("/%d", sz)
|
||||
conn, err := net.Dial("udp", "8.8.8.8:80")
|
||||
if err == nil {
|
||||
defer conn.Close()
|
||||
ipaddr = conn.LocalAddr().(*net.UDPAddr).IP
|
||||
mask = ipaddr.DefaultMask()
|
||||
sz, _ := mask.Size()
|
||||
conf.Ipaddr = ipaddr.String() + fmt.Sprintf("/%d", sz)
|
||||
} else {
|
||||
conf.Ipaddr = "192.168.1.1/24"
|
||||
}
|
||||
}
|
||||
_, network, err = net.ParseCIDR(conf.Ipaddr)
|
||||
if err == nil {
|
||||
@@ -175,7 +171,6 @@ func (conf *RootConf) SetDynamicDefaults() (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
// InitializedFromFile returns true if [RootConf] memory was read from
|
||||
// a file, or false otherwise.
|
||||
func (conf *RootConf) InitializedFromFile() bool {
|
||||
|
||||
Reference in New Issue
Block a user