ext-sources/gnome-system-tools-network-admin.ksh
changeset 13388 949d08fbd0ea
parent 13261 f957c6ffbda4
child 13776 895a6b9270c5
--- a/ext-sources/gnome-system-tools-network-admin.ksh	Wed Sep 03 12:35:36 2008 +0000
+++ b/ext-sources/gnome-system-tools-network-admin.ksh	Wed Sep 03 13:12:32 2008 +0000
@@ -8,6 +8,9 @@
 BASEDIR=${0%/bin/*}
 BASEDIR=${BASEDIR:-/usr} 
 
+PATH=/usr/sbin:/sbin:${BASEDIR}/sbin:${PATH}
+export PATH
+
 zenity=$BASEDIR/bin/zenity
 
 NET_PHYSICAL_SVC=svc:/network/physical
@@ -55,12 +58,12 @@
 
     # Try svcadm directly, use might have sufficient auths.
     switch_completed=false
-    if svcadm disable "${NET_PHYSICAL_SVC}:${to_disable}"; then
-        if svcadm enable "${NET_PHYSICAL_SVC}:${to_enable}"; then
+    if pfexec -P all svcadm disable "${NET_PHYSICAL_SVC}:${to_disable}" 2>/dev/null; then
+        if pfexec -P all svcadm enable "${NET_PHYSICAL_SVC}:${to_enable}" 2>/dev/null; then
             switch_completed=true
         else 
-            # Restore to previous state
-            svcadm enable "${NET_PHYSICAL_SVC}:${to_disable}"
+            # Restore to previous state.
+            pfexec -P all svcadm enable "${NET_PHYSICAL_SVC}:${to_disable}" 2>/dev/null
         fi
     fi
 
@@ -83,19 +86,26 @@
     fi
 
     #Check to see if we successfully completed all tasks.
-    if isRunningNWAM; then
-        if [ "${to_enable}" = "nwam" ]; then
-            return 0
+
+    if [ "${to_enable}" = "nwam" ]; then
+        sleep 3 # Give SMF time to start NWAM
+        if isRunningNWAM; then
+            rval=0
         else
-            return 1
+            # If NWAM is not running then we failed.
+            rval=1
         fi
     else
-        if [ "${to_enable}" = "default" ]; then
-            return 0
+        # NWAM should be disabled in this case.
+        if isRunningNWAM; then
+            # If NWAM still running we failed.
+            rval=1
         else
-            return 1
+            rval=0
         fi
     fi
+
+    return $rval
 }
 
 # SUN_BRANDING
@@ -197,8 +207,8 @@
 
     if [ "$ALTMODE" = "MANUAL" ]; then
         if [ $response_code -eq 0 ]; then   # Switch to Manual
-            if set_network_physical default; then
-                echo exec ${BASEDIR}/lib/network-admin ${1+"$@"}
+            if set_network_physical manual; then
+                exec ${BASEDIR}/lib/network-admin ${1+"$@"}
             else
                 $zenity --error --title="${TITLE}" --text="${ERROR_MSG}"
             fi
@@ -207,13 +217,13 @@
         fi
     elif [ "$ALTMODE" = "AUTO" ]; then
         if [ $response_code -eq 0 ]; then   # Switch to Auto
-            if set_network_physical nwam; then
+            if set_network_physical auto; then
                 :
             else
                 $zenity --error --title="${TITLE}" --text="${ERROR_MSG}"
             fi
         else
-            echo exec ${BASEDIR}/lib/network-admin ${1+"$@"}
+            exec ${BASEDIR}/lib/network-admin ${1+"$@"}
         fi
     fi
 fi