Respect the sortlist resolv.conf option
authorRoy Marples <roy@marples.name>
Wed, 10 Aug 2011 20:02:18 +0000 (20:02 +0000)
committerRoy Marples <roy@marples.name>
Wed, 10 Aug 2011 20:02:18 +0000 (20:02 +0000)
libc.in

diff --git a/libc.in b/libc.in
index 4c797e9067a97673d0a103ac464efb21c68fe5c5..5442c06831b517a8c8f9ac8a8d08b4f3e7ea4335 100644 (file)
--- a/libc.in
+++ b/libc.in
@@ -70,6 +70,7 @@ elif [ -d "$SYSCONFDIR"/resolvconf ]; then
                        search_domains="$(key_get_value "domain " "$base")"
                fi
                resolv_conf_options="$(key_get_value "options " "$base")"
+               resolv_conf_sortlist="$(key_get_value "sortlist " "$base")"
        fi
        if [ -f "$SYSCONFDIR"/resolv.conf.d/head ]; then
                resolv_conf_head="$(cat "${SYSCONFDIR}"/resolv.conf.d/head)"
@@ -140,6 +141,17 @@ case "${resolv_conf_passthrough:-NO}" in
                newconf="$newconf$NL"
        fi
 
+       # and any sortlists
+       opts="$resolv_conf_sortlist${resolv_conf_sortlist:+ }"
+       opts="$opts$($list_resolv | key_get_value "sortlist ")"
+       if [ -n "$opts" ]; then
+               newconf="${newconf}sortlist"
+               for opt in $(uniqify $opts); do
+                       newconf="${newconf} $opt"
+               done
+               newconf="$newconf$NL"
+       fi
+
        if [ -n "$resolv_conf_tail" ]; then
                newconf="$newconf$resolv_conf_tail$NL"
        fi