diff -r fe7f5469cc2d -r f9f75acab23a components/isc-dhcp/isc-dhcp --- a/components/isc-dhcp/isc-dhcp Mon Jun 25 10:28:06 2012 -0700 +++ b/components/isc-dhcp/isc-dhcp Tue Jun 26 07:10:19 2012 -0700 @@ -78,6 +78,51 @@ return 0 } +# +# expand_prop "prop_name" "var_name" [ argflag ] +# +# prop_name FMRI property name +# var_name variable where result is stored; initialized +# to "" +# argflag The flag to be prepended to each property +# value; optional argument +# +# This function will retrieve the properties for "prop_name" via a call +# to get_prop(). It will split-up the property values; it assumes that +# the delimiter is whitespace. It will then prepend "argflag" to each +# property value. The results will be stored in "var_name" which is +# passed by reference. +# +# Return values: +# +# 0 Success +# 1 Failure +# +expand_prop() { + if [ $# -lt 2 ] || [ -z $2 ]; then + errlog "Internal error - expand_prop() has incorrect arguments" + return 1 + fi + + prop_name=$1 + typeset -n var_name=$2 + argflag="$3" + + prop_values="`get_prop $prop_name`" + if [ -z "$prop_values" ]; then + errlog "The property, \"${prop_name}\", is empty" + return 1 + fi + + var_name="" + for item in `IFS= ; set -- $prop_values; echo $@`; do + var_name="$var_name $argflag $item" + done + + return 0 +} + + get_dhcpd_options() { # get listen_ifname property value. LISTENIFNAMES="`get_prop listen_ifnames`" @@ -127,15 +172,12 @@ # If listen_ifnames property value is "e1000g01 iprb0" then the # command line option will look like "-i e1000g0 -i iprb0" # - LISTENIFNAMES="`get_prop listen_ifnames`" - IIFLIST="" - if [ ! -z "$LISTENIFNAMES" ]; then - IIFLIST="-i `echo $LISTENIFNAMES | sed -e 's/[ \t]/ -i /g'`" - fi + IIFLIST= + expand_prop listen_ifnames IIFLIST -i || return $? # # Get servers V4 property value - command line option will look - # like "1.2.3.5 4.5.6.7". + # like "1.2.3.5" "4.5.6.7". # # NOTE: By default server property value is empty. User must # first specify a server using svccfg/setprop command @@ -162,16 +204,8 @@ # first specify a server using svccfg/setprop command # before enabling service. # - RECVLINKS=`get_prop receive_query_links` - if [ -z "$RECVLINKS" ]; then - errlog 'Must specify at least one "receive_query_links" property value' - errlog "Exiting." - return 1 - fi - IRECVLINKS="" - if [ ! -z "$RECVLINKS" ]; then - IRECVLINKS="-l `echo $RECVLINKS | sed -e 's/[ \t]/ -l /g'`" - fi + IRECVLINKS= + expand_prop receive_query_links IRECVLINKS -l || return $? # # Get forwardlinks V6 property value and modify it: # Given forward_query_links property value is "1.2.3.4%bge0 bge2," @@ -182,16 +216,8 @@ # first specify a server using svccfg/setprop command # before enabling service. # - FWDLINKS=`get_prop forward_query_links` - if [ -z "$FWDLINKS" ]; then - errlog 'Must specify at least one "forward_query_links" property value' - errlog "Exiting" - return 1 - fi - IFWDLINKS="" - if [ ! -z "$FWDLINKS" ]; then - IFWDLINKS="-u `echo $FWDLINKS | sed -e 's/[ \t]/ -u /g'`" - fi + IFWDLINKS= + expand_prop forward_query_links IFWDLINKS -u || return $? export OPTIONS="$OPTIONS -6 $IRECVLINKS $IFWDLINKS" }