summaryrefslogtreecommitdiffstats
path: root/net/freeradius3/patches/004-radtest-nas-name-from-hostname-env.patch
blob: 2b9634820516ecd880259a6916a41b9f7ccf8e0c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Alexandru Ardelean <alex@shruggie.ro>
Date: Wed, 3 Jun 2026 01:48:03 +0300
Subject: [PATCH] radtest: use $HOSTNAME for the NAS name when it is set

radtest derives the NAS name from `hostname` or `uname -n`, neither of
which is guaranteed to be present in a minimal image. Prefer the
$HOSTNAME environment variable when the shell exports it, and keep the
original command substitution as the fallback.

Signed-off-by: Alexandru Ardelean <alex@shruggie.ro>
---
--- a/src/main/radtest.in
+++ b/src/main/radtest.in
@@ -117,7 +117,12 @@ if [ "$7" ]
 then
 	nas=$7
 else
-	nas=`(hostname || uname -n) 2>/dev/null | sed 1q`
+	if [ -n "$HOSTNAME" ]
+	then
+		nas=$HOSTNAME
+	else
+		nas=`(hostname || uname -n) 2>/dev/null | sed 1q`
+	fi
 fi
 
 (