29 lines
1.0 KiB
Diff
29 lines
1.0 KiB
Diff
|
From b1d12b4b7956d25fd4b23a92d1683cc389d163a2 Mon Sep 17 00:00:00 2001
|
||
|
From: classabbyamp <dev@placeviolette.net>
|
||
|
Date: Wed, 19 Oct 2022 12:17:37 -0400
|
||
|
Subject: [PATCH] internal/ctl/root.go: only set the default entity if no error
|
||
|
|
||
|
when using qemu-user-static to run netauth in the xbps-src chroot on
|
||
|
cross (for generating completions/manpages), netauth segfaults because
|
||
|
it tries to access a field in a nil value after `user.Current()` errors.
|
||
|
This patch makes it so that the field is only accessed when it exists.
|
||
|
---
|
||
|
internal/ctl/root.go | 3 ++-
|
||
|
1 file changed, 2 insertions(+), 1 deletion(-)
|
||
|
|
||
|
diff --git a/internal/ctl/root.go b/internal/ctl/root.go
|
||
|
index b20c0d2..842815e 100644
|
||
|
--- a/internal/ctl/root.go
|
||
|
+++ b/internal/ctl/root.go
|
||
|
@@ -67,8 +67,9 @@ func onInit() {
|
||
|
user, err := user.Current()
|
||
|
if err != nil {
|
||
|
fmt.Println("Could not get default user:", err)
|
||
|
+ } else {
|
||
|
+ viper.SetDefault("entity", user.Username)
|
||
|
}
|
||
|
- viper.SetDefault("entity", user.Username)
|
||
|
}
|
||
|
|
||
|
// Execute serves as the entrypoint to the ctl package.
|