2005-01-30 Andrew J. Schorr <ajschorr@alumni.princeton.edu>

	* ripng_interface.c: (ripng_multicast_join) Save errno before calling
	  ripngd_privs.change.
diff --git a/ripngd/ChangeLog b/ripngd/ChangeLog
index dcd8ded..f4b6113 100644
--- a/ripngd/ChangeLog
+++ b/ripngd/ChangeLog
@@ -1,3 +1,8 @@
+2005-01-30 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
+
+	* ripng_interface.c: (ripng_multicast_join) Save errno before calling
+	  ripngd_privs.change.
+
 2005-01-04 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
 
 	* ripngd.c: (ripng_recv_packet) Use ZCMSG_FIRSTHDR instead of
diff --git a/ripngd/ripng_interface.c b/ripngd/ripng_interface.c
index fa00aab..bef7699 100644
--- a/ripngd/ripng_interface.c
+++ b/ripngd/ripng_interface.c
@@ -62,6 +62,7 @@
 {
   int ret;
   struct ipv6_mreq mreq;
+  int save_errno;
 
   if (if_is_up (ifp) && if_is_multicast (ifp)) {
     memset (&mreq, 0, sizeof (mreq));
@@ -78,11 +79,12 @@
 
     ret = setsockopt (ripng->sock, IPPROTO_IPV6, IPV6_JOIN_GROUP,
 		      (char *) &mreq, sizeof (mreq));
+    save_errno = errno;
 
     if (ripngd_privs.change (ZPRIVS_LOWER))
       zlog_err ("ripng_multicast_join: could not lower privs");
 
-    if (ret < 0 && errno == EADDRINUSE)
+    if (ret < 0 && save_errno == EADDRINUSE)
       {
 	/*
 	 * Group is already joined.  This occurs due to sloppy group
@@ -94,7 +96,8 @@
       }
 
     if (ret < 0)
-      zlog_warn ("can't setsockopt IPV6_JOIN_GROUP: %s", safe_strerror (errno));
+      zlog_warn ("can't setsockopt IPV6_JOIN_GROUP: %s",
+      		 safe_strerror (save_errno));
 
     if (IS_RIPNG_DEBUG_EVENT)
       zlog_debug ("RIPng %s join to all-rip-routers multicast group", ifp->name);