From 3575132db195f8a986b7bf327417885877079d2e Mon Sep 17 00:00:00 2001 From: Timothy Middelkoop Date: Tue, 27 Feb 2024 19:43:13 +0000 Subject: [PATCH] Get wwid from interface not /proc/cmdline when wwid=[interface] is specified Signed-off-by: Timothy Middelkoop --- internal/app/wwclient/root.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/internal/app/wwclient/root.go b/internal/app/wwclient/root.go index 539d1dc8..3ea04dd2 100644 --- a/internal/app/wwclient/root.go +++ b/internal/app/wwclient/root.go @@ -141,6 +141,20 @@ func CobraRunE(cmd *cobra.Command, args []string) (err error) { } wwid := strings.Split(wwid_tmp[1], " ")[0] + wwid = strings.TrimSuffix(wwid, "\n") + + // Dereference wwid from [interface] for cases that cannot have /proc/cmdline set by bootloader + if string(wwid[0]) == "[" { + iface := wwid[1:len(wwid)-1] + wwid_tmp, err := os.ReadFile(fmt.Sprintf("/sys/class/net/%s/address", iface)) + if err != nil { + wwlog.Error("'wwid' cannot be dereferenced from /sys/class/net", iface) + os.Exit(1) + } + wwid = strings.TrimSuffix(string(wwid_tmp), "\n") + wwlog.Info("Dereferencing wwid from [%s] to %s", iface, wwid) + } + duration := 300 if conf.Warewulf.UpdateInterval > 0 {