2004-05-11 Paul Jakma <paul@dishone.st>

        * Makefile.am: support for IOCTL_METHOD, as per Sowmini's patch.
        * if_ioctl_solaris.c: Fixup some erroneous privilege changes and
          add privs.h header.
        * ioctl_solaris.c: ditto
diff --git a/zebra/ChangeLog b/zebra/ChangeLog
index 8381cf3..d453aea 100644
--- a/zebra/ChangeLog
+++ b/zebra/ChangeLog
@@ -1,7 +1,10 @@
 2004-05-11 Paul Jakma <paul@dishone.st>
 
 	* Makefile.am: support for IOCTL_METHOD, as per Sowmini's patch.
-
+	* if_ioctl_solaris.c: Fixup some erroneous privilege changes and
+	  add privs.h header.
+	* ioctl_solaris.c: ditto
+	 
 2004-05-09 Paul Jakma <paul@dishone.st>
 
 	* zserv.c: (zsend_route_multipath) Set the nexthop_num
diff --git a/zebra/if_ioctl_solaris.c b/zebra/if_ioctl_solaris.c
index b07580c..9441abe 100644
--- a/zebra/if_ioctl_solaris.c
+++ b/zebra/if_ioctl_solaris.c
@@ -29,13 +29,14 @@
 #include "connected.h"
 #include "memory.h"
 #include "log.h"
+#include "privs.h"
 
 #include "zebra/interface.h"
 
 void lifreq_set_name (struct lifreq *, struct interface *);
 static int if_get_addr (struct interface *, struct sockaddr *);
 static void interface_info_ioctl (struct interface *);
-
+extern struct zebra_privs_t zserv_privs;
 
 int
 interface_list_ioctl (int af)
@@ -161,9 +162,6 @@
 
   lifreq_set_name (&lifreq, ifp);
 
-  if (zserv_privs.change(ZPRIVS_RAISE))
-    zlog (NULL, LOG_ERR, "Can't raise privileges");
-
   if (ifp->flags & IFF_IPV4)
     ret = AF_IOCTL (AF_INET, SIOCGLIFINDEX, (caddr_t) & lifreq);
   else if (ifp->flags & IFF_IPV6)
@@ -171,9 +169,6 @@
   else
     ret = -1;
 
-  if (zserv_privs.change(ZPRIVS_LOWER))
-    zlog (NULL, LOG_ERR, "Can't lower privileges");
-
   if (ret < 0)
     {
       zlog_warn ("SIOCGLIFINDEX(%s) failed", ifp->name);
@@ -221,13 +216,7 @@
 
   if (ifp->flags & IFF_POINTOPOINT)
     {
-      if (zserv_privs.change(ZPRIVS_RAISE))
-        zlog (NULL, LOG_ERR, "Can't raise privileges");      
-
       ret = AF_IOCTL (af, SIOCGLIFDSTADDR, (caddr_t) & lifreq);
-
-      if (zserv_privs.change(ZPRIVS_LOWER))
-        zlog (NULL, LOG_ERR, "Can't lower privileges");
         
       if (ret < 0)
         {
diff --git a/zebra/ioctl_solaris.c b/zebra/ioctl_solaris.c
index 2fdffc6..805a9ca 100644
--- a/zebra/ioctl_solaris.c
+++ b/zebra/ioctl_solaris.c
@@ -27,10 +27,12 @@
 #include "prefix.h"
 #include "ioctl.h"
 #include "log.h"
+#include "privs.h"
 
 #include "zebra/rib.h"
 #include "zebra/rt.h"
 
+extern struct zebra_privs_t zserv_privs;
 
 /* clear and set interface name string */
 void
@@ -130,18 +132,12 @@
 
   lifreq_set_name (&lifreq, ifp);
 
-  if (zserv_privs.change(ZPRIVS_RAISE))
-    zlog (NULL, LOG_ERR, "Can't raise privileges");
-    
   if (ifp->flags & IFF_IPV4)
     ret = AF_IOCTL (AF_INET, SIOCGLIFMETRIC, (caddr_t) & lifreq);
   else if (ifp->flags & IFF_IPV6)
     ret = AF_IOCTL (AF_INET6, SIOCGLIFMETRIC, (caddr_t) & lifreq);
   else
     ret = -1;
-
-  if (zserv_privs.change(ZPRIVS_LOWER))
-    zlog (NULL, LOG_ERR, "Can't lower privileges");
     
   if (ret < 0)
     return;
@@ -159,9 +155,6 @@
   struct lifreq lifreq;
   int ret;
   
-  if (zserv_privs.change(ZPRIVS_RAISE))
-    zlog (NULL, LOG_ERR, "Can't raise privileges");
-  
   if (ifp->flags & IFF_IPV4)
     {
       lifreq_set_name (&lifreq, ifp);
@@ -180,7 +173,6 @@
 
 
   if ((ifp->flags & IFF_IPV6) == 0)
-    goto out;
 
   lifreq_set_name (&lifreq, ifp);
   ret = AF_IOCTL (AF_INET6, SIOCGLIFMTU, (caddr_t) & lifreq);
@@ -193,10 +185,6 @@
     {
       ifp->mtu6 = lifreq.lifr_metric;
     }
-
-out:
-   if (zserv_privs.change(ZPRIVS_LOWER))
-     zlog (NULL, LOG_ERR, "Can't lower privileges");
 }
 
 /* Set up interface's address, netmask (and broadcast? ).
@@ -241,7 +229,7 @@
       memcpy (&ifreq.ifr_broadaddr, &broad, sizeof (struct sockaddr_in));
       ret = if_ioctl (SIOCSIFBRDADDR, (caddr_t) & ifreq);
       if (ret < 0)
-        goto out;
+        return ret;
     }
 
   mask.sin_family = p->family;
@@ -249,7 +237,7 @@
   memcpy (&mask, &ifreq.ifr_addr, sizeof (mask));
 #else
   memcpy (&ifreq.ifr_netmask, &mask, sizeof (struct sockaddr_in));
-#endif /* SUNOS5 */
+#endif /* SUNOS_5 */
   ret = if_ioctl (SIOCSIFNETMASK, (caddr_t) & ifreq);
 
   return ((ret < 0) ? ret : 0);
@@ -293,13 +281,7 @@
     {
       lifreq_set_name (&lifreq, ifp);
       
-      if (zserv_privs.change(ZPRIVS_RAISE))
-        zlog (NULL, LOG_ERR, "Can't raise privileges");
-      
       ret = AF_IOCTL (AF_INET, SIOCGLIFFLAGS, (caddr_t) & lifreq);
-      
-      if (zserv_privs.change(ZPRIVS_LOWER))
-        zlog (NULL, LOG_ERR, "Can't lower privileges");
 
       flags4 = (lifreq.lifr_flags & 0xffffffff);
       if (!(flags4 & IFF_UP))
@@ -310,13 +292,7 @@
     {
       lifreq_set_name (&lifreq, ifp);
       
-      if (zserv_privs.change(ZPRIVS_RAISE))
-        zlog (NULL, LOG_ERR, "Can't raise privileges");      
-      
       ret = AF_IOCTL (AF_INET6, SIOCGLIFFLAGS, (caddr_t) & lifreq);
-      
-      if (zserv_privs.change(ZPRIVS_LOWER))
-        zlog (NULL, LOG_ERR, "Can't lower privileges");
               
       flags6 = (lifreq.lifr_flags & 0xffffffff);
       if (!(flags6 & IFF_UP))
@@ -338,9 +314,6 @@
   lifreq.lifr_flags = ifp->flags;
   lifreq.lifr_flags |= flags;
 
-  if (zserv_privs.change(ZPRIVS_RAISE))
-    zlog (NULL, LOG_ERR, "Can't raise privileges");
-
   if (ifp->flags & IFF_IPV4)
     ret = AF_IOCTL (AF_INET, SIOCSLIFFLAGS, (caddr_t) & lifreq);
   else if (ifp->flags & IFF_IPV6)
@@ -353,9 +326,8 @@
                strerror (errno));
   else
     ret = 0;
-
-  if (zserv_privs.change(ZPRIVS_LOWER))
-    zlog (NULL, LOG_ERR, "Can't lower privileges");
+    
+  return ret;
 }
 
 /* Unset interface's flag. */
@@ -370,9 +342,6 @@
   lifreq.lifr_flags = ifp->flags;
   lifreq.lifr_flags &= ~flags;
 
-  if (zserv_privs.change(ZPRIVS_RAISE))
-    zlog (NULL, LOG_ERR, "Can't raise privileges");
-
   if (ifp->flags & IFF_IPV4)
     ret = AF_IOCTL (AF_INET, SIOCSLIFFLAGS, (caddr_t) & lifreq);
   else if (ifp->flags & IFF_IPV6)
@@ -385,8 +354,7 @@
   else
     ret = 0;
   
-  if (zserv_privs.change(ZPRIVS_LOWER))
-    zlog (NULL, LOG_ERR, "Can't lower privileges");
+  return ret;
 }
 
 #ifdef HAVE_IPV6