Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-6]: src Pull up following revision(s) (requested by gendalia in t...



details:   https://anonhg.NetBSD.org/src/rev/dd7fe28a3916
branches:  netbsd-6
changeset: 774051:dd7fe28a3916
user:      riz <riz%NetBSD.org@localhost>
date:      Mon May 07 03:16:44 2012 +0000

description:
Pull up following revision(s) (requested by gendalia in ticket #211):
        share/man/man5/route.conf.5: revision 1.4
        etc/rc.d/staticroute: revision 1.6
Add the ability for staticroute to evaluate lines from /etc/route.conf
as shell script fragments, add example to the route.conf man page of
evaluating variables.
Remove route.conf man page statement that staticroute is enabled in
rc.conf since that's incorrect.
Wrap the staticroute while in parens, per <apb> & <christos>, and
quote all the arguments for the evals.

diffstat:

 etc/rc.d/staticroute        |  15 +++++++++------
 share/man/man5/route.conf.5 |  22 ++++++++++++++++------
 2 files changed, 25 insertions(+), 12 deletions(-)

diffs (96 lines):

diff -r 962ea3b5a64d -r dd7fe28a3916 etc/rc.d/staticroute
--- a/etc/rc.d/staticroute      Mon May 07 03:15:12 2012 +0000
+++ b/etc/rc.d/staticroute      Mon May 07 03:16:44 2012 +0000
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: staticroute,v 1.5 2009/10/07 08:06:11 tron Exp $
+# $NetBSD: staticroute,v 1.5.8.1 2012/05/07 03:16:45 riz Exp $
 #
 
 # PROVIDE: staticroute
@@ -20,26 +20,29 @@
 
        if [ -s /etc/route.conf ]; then
                echo "$1 static routes."
-               while read args; do
+               ( while read args; do
                        [ -z "$args" ] && continue
                        case "$args" in
                        "#"*)
                                ;;
                        "+"*)
                                if [ $2 = "add" ]; then
-                                       eval ${args#*+} || retval=1
+                                       eval "${args#*+}" || retval=1
                                fi
                                ;;
                        "-"*)
                                if [ $2 = "delete" ]; then
-                                       eval ${args#*-} || retval=1
+                                       eval "${args#*-}" || retval=1
                                fi
                                ;;
+                       "!"*)
+                               eval "${args#*!}" || retval=1
+                               ;;
                        *)
-                               route -q $2 -$args || retval=1
+                               eval "route -q $2 -$args" || retval=1
                                ;;
                        esac
-               done < /etc/route.conf
+               done < /etc/route.conf )
        fi
 
        return $retval
diff -r 962ea3b5a64d -r dd7fe28a3916 share/man/man5/route.conf.5
--- a/share/man/man5/route.conf.5       Mon May 07 03:15:12 2012 +0000
+++ b/share/man/man5/route.conf.5       Mon May 07 03:16:44 2012 +0000
@@ -1,4 +1,4 @@
-.\"        $NetBSD: route.conf.5,v 1.3 2008/05/08 15:34:39 wiz Exp $
+.\"        $NetBSD: route.conf.5,v 1.3.20.1 2012/05/07 03:16:44 riz Exp $
 .\"
 .\" Copyright (c) 2004 Thomas Klausner
 .\" All rights reserved.
@@ -23,7 +23,7 @@
 .\" INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd June 24, 2004
+.Dd May 1, 2012
 .Dt ROUTE.CONF 5
 .Os
 .Sh NAME
@@ -46,6 +46,9 @@
 while lines starting with a minus sign
 .Pq Sq \-
 are run during system shutdown.
+If a line starts with a
+.Sq \&! ,
+the rest of the line will get evaluated as a shell script fragment.
 All other lines are passed to
 .Xr route 8 .
 During start-up, they are passed behind a
@@ -66,10 +69,17 @@
 .Nm .
 .El
 .Sh EXAMPLES
-In this example, if the
-.Pa staticroute
-script is enabled in
-.Xr rc.conf 5 ,
+In this example, the interface for the desired routing changes is set,
+the IP address on that interface is determined, and a route is added
+during startup, or deleted during system shutdown.
+.Bd -literal -offset indent 
+# Set interface and determine current IP address for added route.
+!ifname=bnx0
+!ipaddr=$(/sbin/ifconfig ${ifname} | awk '$1 == "inet" {print $2}')
+net 10.10.1 -interface ${ipaddr}
+.Ed
+.Pp
+In this example,
 IP forwarding is turned on during
 start-up, and a static route added for 192.168.2.0.
 During system shutdown, the route is removed



Home | Main Index | Thread Index | Old Index