From 2d880aae76f19609dc0c0d1a5c56262bd5cbe3df Mon Sep 17 00:00:00 2001 From: Gregory Kurtzer Date: Wed, 26 Jan 2022 03:46:39 +0000 Subject: [PATCH] Properly support relative paths to the SYSCONFDIR --- internal/pkg/overlay/funcmap.go | 10 +++++++--- overlays/wwinit/etc/ssh/ssh_host_dsa_key.pub.ww | 2 +- overlays/wwinit/etc/ssh/ssh_host_dsa_key.ww | 2 +- overlays/wwinit/etc/ssh/ssh_host_ecdsa_key.pub.ww | 2 +- overlays/wwinit/etc/ssh/ssh_host_ecdsa_key.ww | 2 +- overlays/wwinit/etc/ssh/ssh_host_ed25519_key.pub.ww | 2 +- overlays/wwinit/etc/ssh/ssh_host_ed25519_key.ww | 2 +- overlays/wwinit/etc/ssh/ssh_host_rsa_key.pub.ww | 2 +- overlays/wwinit/etc/ssh/ssh_host_rsa_key.ww | 2 +- overlays/wwinit/etc/warewulf/warewulf.conf.ww | 2 +- 10 files changed, 16 insertions(+), 12 deletions(-) diff --git a/internal/pkg/overlay/funcmap.go b/internal/pkg/overlay/funcmap.go index 4bb4c118..b3279264 100644 --- a/internal/pkg/overlay/funcmap.go +++ b/internal/pkg/overlay/funcmap.go @@ -5,14 +5,18 @@ import ( "path" "strings" + "github.com/hpcng/warewulf/internal/pkg/buildconfig" "github.com/hpcng/warewulf/internal/pkg/container" "github.com/hpcng/warewulf/internal/pkg/util" "github.com/hpcng/warewulf/internal/pkg/wwlog" ) -func templateFileInclude(path string) string { - wwlog.Printf(wwlog.DEBUG, "Including file into template: %s\n", path) - content, err := ioutil.ReadFile(path) +func templateFileInclude(inc string) string { + if !strings.HasPrefix(inc, "/") { + inc = path.Join(buildconfig.SYSCONFDIR(), "warewulf", inc) + } + wwlog.Printf(wwlog.DEBUG, "Including file into template: %s\n", inc) + content, err := ioutil.ReadFile(inc) if err != nil { wwlog.Printf(wwlog.VERBOSE, "Could not include file into template: %s\n", err) } diff --git a/overlays/wwinit/etc/ssh/ssh_host_dsa_key.pub.ww b/overlays/wwinit/etc/ssh/ssh_host_dsa_key.pub.ww index 4bb82192..25b4ab26 100644 --- a/overlays/wwinit/etc/ssh/ssh_host_dsa_key.pub.ww +++ b/overlays/wwinit/etc/ssh/ssh_host_dsa_key.pub.ww @@ -1 +1 @@ -{{Include "/etc/warewulf/keys/ssh_host_dsa_key.pub"}} +{{Include "keys/ssh_host_dsa_key.pub"}} diff --git a/overlays/wwinit/etc/ssh/ssh_host_dsa_key.ww b/overlays/wwinit/etc/ssh/ssh_host_dsa_key.ww index 581f48f4..82ab4701 100644 --- a/overlays/wwinit/etc/ssh/ssh_host_dsa_key.ww +++ b/overlays/wwinit/etc/ssh/ssh_host_dsa_key.ww @@ -1 +1 @@ -{{Include "/etc/warewulf/keys/ssh_host_dsa_key"}} +{{Include "keys/ssh_host_dsa_key"}} diff --git a/overlays/wwinit/etc/ssh/ssh_host_ecdsa_key.pub.ww b/overlays/wwinit/etc/ssh/ssh_host_ecdsa_key.pub.ww index b6d9aa89..4229b16e 100644 --- a/overlays/wwinit/etc/ssh/ssh_host_ecdsa_key.pub.ww +++ b/overlays/wwinit/etc/ssh/ssh_host_ecdsa_key.pub.ww @@ -1 +1 @@ -{{Include "/etc/warewulf/keys/ssh_host_ecdsa_key.pub"}} +{{Include "keys/ssh_host_ecdsa_key.pub"}} diff --git a/overlays/wwinit/etc/ssh/ssh_host_ecdsa_key.ww b/overlays/wwinit/etc/ssh/ssh_host_ecdsa_key.ww index fbf8934c..a65e0b82 100644 --- a/overlays/wwinit/etc/ssh/ssh_host_ecdsa_key.ww +++ b/overlays/wwinit/etc/ssh/ssh_host_ecdsa_key.ww @@ -1 +1 @@ -{{Include "/etc/warewulf/keys/ssh_host_ecdsa_key"}} +{{Include "keys/ssh_host_ecdsa_key"}} diff --git a/overlays/wwinit/etc/ssh/ssh_host_ed25519_key.pub.ww b/overlays/wwinit/etc/ssh/ssh_host_ed25519_key.pub.ww index 76dbcfdb..de6364f4 100644 --- a/overlays/wwinit/etc/ssh/ssh_host_ed25519_key.pub.ww +++ b/overlays/wwinit/etc/ssh/ssh_host_ed25519_key.pub.ww @@ -1 +1 @@ -{{Include "/etc/warewulf/keys/ssh_host_ed25519_key.pub"}} +{{Include "keys/ssh_host_ed25519_key.pub"}} diff --git a/overlays/wwinit/etc/ssh/ssh_host_ed25519_key.ww b/overlays/wwinit/etc/ssh/ssh_host_ed25519_key.ww index e6dec541..a3c2674c 100644 --- a/overlays/wwinit/etc/ssh/ssh_host_ed25519_key.ww +++ b/overlays/wwinit/etc/ssh/ssh_host_ed25519_key.ww @@ -1 +1 @@ -{{Include "/etc/warewulf/keys/ssh_host_ed25519_key"}} +{{Include "keys/ssh_host_ed25519_key"}} diff --git a/overlays/wwinit/etc/ssh/ssh_host_rsa_key.pub.ww b/overlays/wwinit/etc/ssh/ssh_host_rsa_key.pub.ww index d5b09fa8..db06bb4b 100644 --- a/overlays/wwinit/etc/ssh/ssh_host_rsa_key.pub.ww +++ b/overlays/wwinit/etc/ssh/ssh_host_rsa_key.pub.ww @@ -1 +1 @@ -{{Include "/etc/warewulf/keys/ssh_host_rsa_key.pub"}} +{{Include "keys/ssh_host_rsa_key.pub"}} diff --git a/overlays/wwinit/etc/ssh/ssh_host_rsa_key.ww b/overlays/wwinit/etc/ssh/ssh_host_rsa_key.ww index feffaad5..877d0601 100644 --- a/overlays/wwinit/etc/ssh/ssh_host_rsa_key.ww +++ b/overlays/wwinit/etc/ssh/ssh_host_rsa_key.ww @@ -1 +1 @@ -{{Include "/etc/warewulf/keys/ssh_host_rsa_key"}} +{{Include "keys/ssh_host_rsa_key"}} diff --git a/overlays/wwinit/etc/warewulf/warewulf.conf.ww b/overlays/wwinit/etc/warewulf/warewulf.conf.ww index df0e916e..e1fba08c 100644 --- a/overlays/wwinit/etc/warewulf/warewulf.conf.ww +++ b/overlays/wwinit/etc/warewulf/warewulf.conf.ww @@ -1 +1 @@ -{{Include "/etc/warewulf/warewulf.conf"}} +{{Include "warewulf.conf"}}