summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2024-09-03 17:55:56 +0200
committerSimon Rettberg2024-09-03 17:55:56 +0200
commitaf28803d095014d6f11bfc6facb41b17d442b094 (patch)
tree81705a64bfad4a92f35ad7069b2461b75d6a772d
parentUpdate dracut patch; make failing patches fatal (diff)
downloadsystemd-init-af28803d095014d6f11bfc6facb41b17d442b094.tar.gz
systemd-init-af28803d095014d6f11bfc6facb41b17d442b094.tar.xz
systemd-init-af28803d095014d6f11bfc6facb41b17d442b094.zip
[slx-network] Also sanitize host/domain from KCL
-rwxr-xr-xmodules.d/slx-network/hooks/s3-parse-network-kcl.sh29
1 files changed, 20 insertions, 9 deletions
diff --git a/modules.d/slx-network/hooks/s3-parse-network-kcl.sh b/modules.d/slx-network/hooks/s3-parse-network-kcl.sh
index 123d2d03..37dc7814 100755
--- a/modules.d/slx-network/hooks/s3-parse-network-kcl.sh
+++ b/modules.d/slx-network/hooks/s3-parse-network-kcl.sh
@@ -28,15 +28,25 @@ parse_kcl_ip() {
# parse new style 'ipv4.*=...' parameters
parse_kcl_ipv4() {
+ local param
for param in "ip" "router" "dns" "hostname" "domain" "search" "if" "ntpsrv" "subnet"; do
local current="$(getarg ipv4.${param}=)"
- echo "KCL '$param'='$current'"
+ echo "ipv4.'$param'='$current'"
[ -z "$current" ] && continue
declare -g "${param}=${current}"
done
}
parse_kcl() {
+ # backwards compat for old style hostname/dns/domain
+ local conf
+ for conf in hostname dns domain; do
+ conf_value="$(getarg ${conf}=)"
+ if [ -n "$conf_value" ]; then
+ echo "legacy '$conf'='$conf_value'"
+ declare -g "${conf}=${conf_value}"
+ fi
+ done
# we assume (and we should) that both variants contain the
# same information if they are present simultaneously.
parse_kcl_ip
@@ -59,13 +69,13 @@ parse_kcl() {
# Bridged the boot interface?
grep -wqE 'bridged' /proc/cmdline && declare -g bridged="y"
- # backwards compat for old style hostname/dns/domain
- for conf in hostname dns domain; do
- conf_value="$(getarg ${conf}=)"
- if [ -n "$conf_value" ]; then
- declare -g "${conf}=${conf_value}"
- fi
- done
+ # Sanitize
+ if [[ $hostname = *.* ]]; then
+ [ -z "$domain" ] && domain="${hostname#*.}"
+ hostname="${hostname%%.*}"
+ echo "Fixed up to '$hostname' and '$domain'"
+ fi
+ domain="${domain%% *}"
}
save_network_config() {
@@ -81,7 +91,8 @@ save_network_config() {
SLX_PXE_NETIF='$bootif_name'
SLX_PXE_DNS='${dns//,/ }'
SLX_PXE_HOSTNAME='$hostname'
- SLX_PXE_DOMAIN='${search//,/ }'
+ SLX_PXE_DOMAIN='${domain}'
+ SLX_PXE_SEARCH='${search//,/ }'
SLX_PXE_NTP='${ntpsrv//,/ }'
SLX_BRIDGE='${bridged:+${bridge_name}}'
SLX_VLAN_ID='$vlan'