From: Roy Marples Date: Fri, 16 Jun 2017 07:51:46 +0000 (+0100) Subject: Revert "RFC2181 section 11 says a DNS label can be pretty much anything." X-Git-Tag: v7.0.0-rc2~46 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c7eabb1bb46a3cf16144c36651879071e2903eca;p=thirdparty%2Fdhcpcd.git Revert "RFC2181 section 11 says a DNS label can be pretty much anything." This reverts commit 6da580eefb0d94d1b377303e84af821556ab33b0. --- 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