]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
RFC2181 section 11 says a DNS label can be pretty much anything.
authorRoy Marples <roy@marples.name>
Tue, 13 Jun 2017 21:01:58 +0000 (22:01 +0100)
committerRoy Marples <roy@marples.name>
Tue, 13 Jun 2017 21:02:55 +0000 (22:02 +0100)
So just test overall length and label length.

Thanks to Robert Elz.

hooks/dhcpcd-run-hooks.in

index 076ffb2b81dd49dbaafd51e09967a397fe9d6031..6c37bde65b037502918ef2e14a75be954bc91b38 100644 (file)
@@ -198,8 +198,7 @@ syslog()
        fi
 }
 
-# Check for a valid domain name as per RFC1123 with the exception of
-# allowing - and _ as they seem to be widely used.
+# Check for a valid domain name as per RFC2181 section 11
 valid_domainname()
 {
        local name="$1" label
@@ -209,11 +208,7 @@ valid_domainname()
        while [ -n "$name" ]; do
                label="${name%%.*}"
                [ -z "$label" -o ${#label} -gt 63 ] && return 1
-               case "$label" in
-               -*|_*|*-|*_)            return 1;;
-               *[![:alnum:]_-]*)       return 1;;
-               "$name")                return 0;;
-               esac
+               [ "$label" = "$name" ] && return 0
                name="${name#*.}"
        done
        return 0