]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
resolv.conf: Uniquify contents
authorRoy Marples <roy@marples.name>
Wed, 1 Apr 2020 12:22:15 +0000 (13:22 +0100)
committerRoy Marples <roy@marples.name>
Wed, 1 Apr 2020 12:22:15 +0000 (13:22 +0100)
We might have >1 router that broadcasts the same DNS information.
While resolvconf(8) can easily take care of uniqifying the data,
not all systems have this nice tool so do the job here as well.

hooks/20-resolv.conf

index 422d815a44f04089c09ba7c421d11d4476d7c497..03e846fa2d50ed5b264196f0c45614091a258de0 100644 (file)
@@ -42,7 +42,7 @@ build_resolv_conf()
                # Build the nameserver list
                srvs=$(cd "$resolv_conf_dir"; \
                        key_get_value "nameserver " ${interfaces})
-               for x in $(uniqify ${srvs}); do
+               for x in $(uniqify $srvs); do
                        servers="${servers}nameserver $x$NL"
                done
        fi
@@ -152,6 +152,7 @@ add_resolv_conf()
                fi
        fi
        if [ -n "$new_domain_search" ]; then
+               new_domain_search=$(uniqify $new_domain_search)
                if valid_domainname_list $new_domain_search; then
                        conf="${conf}search $new_domain_search$NL"
                elif ! $warn; then
@@ -159,6 +160,7 @@ add_resolv_conf()
                            "$new_domain_search"
                fi
        fi
+       new_domain_name_servers=$(uniqify $new_domain_name_servers)
        for x in ${new_domain_name_servers}; do
                conf="${conf}nameserver $x$NL"
        done