NetAuth: fix generation of manpages & completions on cross

This commit is contained in:
classabbyamp 2022-10-19 12:26:14 -04:00
parent 00a65ddcb0
commit 4b79f6106c
No known key found for this signature in database
GPG Key ID: 6BE0755918A4C7F5
2 changed files with 29 additions and 1 deletions

View File

@ -0,0 +1,28 @@
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.

View File

@ -1,7 +1,7 @@
# Template file for 'NetAuth'
pkgname=NetAuth
version=0.6.1
revision=2
revision=3
wrksrc=netauth-$version
build_style="go"
build_helper="qemu"