summaryrefslogtreecommitdiffstats
path: root/hooks
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2017-06-16 08:51:46 +0100
committerRoy Marples <roy@marples.name>2017-06-16 08:51:46 +0100
commit75c085753c3ab542e79a05a4874e178dbb5cf53c (patch)
tree96d3af70664519e48f5c9c689b0540f24c06331f /hooks
parent965011f3c8fefe10f7f7b7d6227d572e7c0a795c (diff)
downloaddhcpcd-75c085753c3ab542e79a05a4874e178dbb5cf53c.tar.xz
Revert "RFC2181 section 11 says a DNS label can be pretty much anything."
This reverts commit 6da580eefb0d94d1b377303e84af821556ab33b0.
Diffstat (limited to 'hooks')
-rw-r--r--hooks/dhcpcd-run-hooks.in9
1 files changed, 7 insertions, 2 deletions
diff --git a/hooks/dhcpcd-run-hooks.in b/hooks/dhcpcd-run-hooks.in
index 6c37bde6..076ffb2b 100644
--- a/hooks/dhcpcd-run-hooks.in
+++ b/hooks/dhcpcd-run-hooks.in
@@ -198,7 +198,8 @@ syslog()
fi
}
-# Check for a valid domain name as per RFC2181 section 11
+# Check for a valid domain name as per RFC1123 with the exception of
+# allowing - and _ as they seem to be widely used.
valid_domainname()
{
local name="$1" label
@@ -208,7 +209,11 @@ valid_domainname()
while [ -n "$name" ]; do
label="${name%%.*}"
[ -z "$label" -o ${#label} -gt 63 ] && return 1
- [ "$label" = "$name" ] && return 0
+ case "$label" in
+ -*|_*|*-|*_) return 1;;
+ *[![:alnum:]_-]*) return 1;;
+ "$name") return 0;;
+ esac
name="${name#*.}"
done
return 0