Add option for wwclient port number

With this change, you can specify a port number for wwclient.
If

  wwclient:
    port: NUMBER

is specified in warewulf.conf, wwclient will bind to the specified local
port NUMBER. If no port is specified, wwclient will use any available
port, or port 987 if secure is true.

Port 987 is in the default port range used by the Linux NFS client
(665-1023, see linux/include/linux/sunrpc/xprtsock.h). Changing
the port can avoid failures when port 987 is already in use.

Signed-off-by: Tobias Poschwatta <poschwatta@zib.de>
This commit is contained in:
Tobias Poschwatta
2024-08-02 11:09:16 +02:00
parent dc7edfdb60
commit 971d9e2118
4 changed files with 11 additions and 1 deletions

View File

@@ -98,7 +98,10 @@ func CobraRunE(cmd *cobra.Command, args []string) (err error) {
}
localTCPAddr := net.TCPAddr{}
if conf.Warewulf.Secure {
if conf.WWClient != nil && conf.WWClient.Port > 0 {
localTCPAddr.Port = int(conf.WWClient.Port)
wwlog.Info("Running from configured port %d", conf.WWClient.Port)
} else if conf.Warewulf.Secure {
// Setup local port to something privileged (<1024)
localTCPAddr.Port = 987
wwlog.Info("Running from trusted port")

View File

@@ -41,6 +41,7 @@ type RootConf struct {
SSH *SSHConf `yaml:"ssh,omitempty"`
MountsContainer []*MountEntry `yaml:"container mounts" default:"[{\"source\": \"/etc/resolv.conf\", \"dest\": \"/etc/resolv.conf\"}]"`
Paths *BuildConfig `yaml:"paths"`
WWClient *WWClientConf `yaml:"wwclient"`
warewulfconf string
}

View File

@@ -0,0 +1,5 @@
package config
type WWClientConf struct {
Port uint16 `yaml:"port" default:"0"`
}