Allow public_interfaces config variable to override private interface markings.
authorRoy Marples <roy@marples.name>
Tue, 29 Nov 2016 11:21:43 +0000 (11:21 +0000)
committerRoy Marples <roy@marples.name>
Tue, 29 Nov 2016 11:21:43 +0000 (11:21 +0000)
resolvconf.8.in
resolvconf.conf.5.in
resolvconf.in

index db136f393675e494354ff1917a83e5d3dc8c5117..fa00582976d8db5c437cac60ebfb3912f009c26a 100644 (file)
@@ -22,7 +22,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd July 8, 2016
+.Dd November 29, 2016
 .Dt RESOLVCONF 8
 .Os
 .Sh NAME
@@ -108,7 +108,7 @@ See
 .Xr resolvconf.conf 5
 for how to configure
 .Nm
-to use a local name server.
+to use a local name server and how to remove the private marking.
 .Pp
 .Nm
 can mark an interfaces
index 7b410abbe5e9e657265564eb6bcd74b92a47d472..16b79ec222c0cd2924f0d1dee06268b81a0feb9a 100644 (file)
@@ -22,7 +22,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd April 28, 2016
+.Dd November 29, 2016
 .Dt RESOLVCONF.CONF 5
 .Os
 .Sh NAME
@@ -102,6 +102,11 @@ Requires a local nameserver other than libc.
 This is equivalent to the
 .Nm resolvconf -p
 option.
+.It Sy public_interfaces
+Force these interface to be public, overriding the private marking.
+This is handy when 3rd party integrations force the
+.Nm resolvconf -p
+option and you want to disable it easily.
 .It Sy replace
 Is a space separated list of replacement keywords.
 The syntax is this:
index b4439d6ee520178d0d8834f4eb7a530ab9fc1e6c..c555b341624bcf47359e64517198309ab6bb847e 100644 (file)
@@ -136,6 +136,34 @@ strip_trailing_dots()
        printf "\n"
 }
 
+private_iface()
+{
+       local p
+
+       # Allow expansion
+       cd "$IFACEDIR"
+
+       # Public interfaces override private ones.
+       for p in $public_interfaces; do
+               case "$iface" in
+               "$p"|"$p":*) return 1;;
+               esac
+       done
+
+       if [ -e "$PRIVATEDIR/$iface" ]; then
+               return 0
+       fi
+       
+       for p in $private_interfaces; do
+               case "$iface" in
+               "$p"|"$p":*) return 0;;
+               esac
+       done
+
+       # Not a private interface
+       return 1
+}
+
 # Parse resolv.conf's and make variables
 # for domain name servers, search name servers and global nameservers
 parse_resolv()
@@ -151,20 +179,10 @@ parse_resolv()
                        if ${new}; then
                                iface="${line#\# resolv.conf from *}"
                                new=false
-                               if [ -e "$PRIVATEDIR/$iface" ]; then
+                               if private_iface "$iface"; then
                                        private=true
                                else
-                                       # Allow expansion
-                                       cd "$IFACEDIR"
                                        private=false
-                                       for p in $private_interfaces; do
-                                               case "$iface" in
-                                               "$p"|"$p":*)
-                                                       private=true
-                                                       break
-                                                       ;;
-                                               esac
-                                       done
                                fi
                        fi
                        ;;