From 971d9e2118074ecd5069768a72664e373ce61692 Mon Sep 17 00:00:00 2001 From: Tobias Poschwatta Date: Fri, 2 Aug 2024 11:09:16 +0200 Subject: [PATCH] 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 --- CHANGELOG.md | 1 + internal/app/wwclient/root.go | 5 ++++- internal/pkg/config/root.go | 1 + internal/pkg/config/wwclient.go | 5 +++++ 4 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 internal/pkg/config/wwclient.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e00980f..3a6ca869 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Add multiple output formats (yaml & json) support. #447 - More aliases for many wwctl commands - Add support to render template using `host` or `$(uname -n)` as the value of `overlay show --render`. #623 +- Added option for wwclient port number ### Changed diff --git a/internal/app/wwclient/root.go b/internal/app/wwclient/root.go index 3f9c08b3..110d23be 100644 --- a/internal/app/wwclient/root.go +++ b/internal/app/wwclient/root.go @@ -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") diff --git a/internal/pkg/config/root.go b/internal/pkg/config/root.go index 89c6b944..50b2a134 100644 --- a/internal/pkg/config/root.go +++ b/internal/pkg/config/root.go @@ -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 } diff --git a/internal/pkg/config/wwclient.go b/internal/pkg/config/wwclient.go new file mode 100644 index 00000000..13993be6 --- /dev/null +++ b/internal/pkg/config/wwclient.go @@ -0,0 +1,5 @@ +package config + +type WWClientConf struct { + Port uint16 `yaml:"port" default:"0"` +}