summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorajs <ajs>2005-01-29 17:07:40 +0000
committerajs <ajs>2005-01-29 17:07:40 +0000
commit4460e7a4cf3dadcd9f06e4b519ba7be2cc936c0a (patch)
tree5755c13aeffb151d56a886868e623d186ca9a0a0
parent4be019d5530e21c9e54e41e46a57ab071b9b11ae (diff)
2005-01-29 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* if_ioctl_solaris.c: (interface_list_ioctl) Save errno before calling zserv_privs.change. * ioctl{,_solaris}.c: (if_ioctl,if_ioctl_ipv6) Save errno before calling zserv_privs.change. * ipforward_solaris.c: (solaris_nd) Save errno before calling zserv_privs.change. * irdp_main.c: (irdp_sock_init) Save errno before calling zserv_privs.change. [backport candidate]
-rw-r--r--zebra/ChangeLog11
-rw-r--r--zebra/if_ioctl_solaris.c4
-rw-r--r--zebra/ioctl.c23
-rw-r--r--zebra/ioctl_solaris.c22
-rw-r--r--zebra/ipforward_solaris.c4
-rw-r--r--zebra/irdp_main.c4
6 files changed, 36 insertions, 32 deletions
diff --git a/zebra/ChangeLog b/zebra/ChangeLog
index a7286f9d..0ebe7052 100644
--- a/zebra/ChangeLog
+++ b/zebra/ChangeLog
@@ -1,5 +1,16 @@
2005-01-29 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
+ * if_ioctl_solaris.c: (interface_list_ioctl) Save errno before calling
+ zserv_privs.change.
+ * ioctl{,_solaris}.c: (if_ioctl,if_ioctl_ipv6) Save errno before calling
+ zserv_privs.change.
+ * ipforward_solaris.c: (solaris_nd) Save errno before calling
+ zserv_privs.change.
+ * irdp_main.c: (irdp_sock_init) Save errno before calling
+ zserv_privs.change.
+
+2005-01-29 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
+
* rt_netlink.c: (netlink_socket,netlink_request,netlink_parse_info,
netlink_talk) Save errno before calling zserv_privs.change.
diff --git a/zebra/if_ioctl_solaris.c b/zebra/if_ioctl_solaris.c
index 1cbf555e..38ac5a71 100644
--- a/zebra/if_ioctl_solaris.c
+++ b/zebra/if_ioctl_solaris.c
@@ -50,6 +50,7 @@ interface_list_ioctl (int af)
struct lifconf lifconf;
struct interface *ifp;
int n;
+ int save_errno;
size_t needed, lastneeded = 0;
char *buf = NULL;
@@ -72,6 +73,7 @@ calculate_lifc_len: /* must hold privileges to enter here */
lifn.lifn_family = af;
lifn.lifn_flags = 0;
ret = ioctl (sock, SIOCGLIFNUM, &lifn);
+ save_errno = errno;
if (zserv_privs.change(ZPRIVS_LOWER))
zlog (NULL, LOG_ERR, "Can't lower privileges");
@@ -79,7 +81,7 @@ calculate_lifc_len: /* must hold privileges to enter here */
if (ret < 0)
{
zlog_warn ("interface_list_ioctl: SIOCGLIFNUM failed %s",
- safe_strerror (errno));
+ safe_strerror (save_errno));
close (sock);
return -1;
}
diff --git a/zebra/ioctl.c b/zebra/ioctl.c
index eca0e769..e28d359e 100644
--- a/zebra/ioctl.c
+++ b/zebra/ioctl.c
@@ -46,8 +46,8 @@ int
if_ioctl (u_long request, caddr_t buffer)
{
int sock;
- int ret = 0;
- int err = 0;
+ int ret;
+ int err;
if (zserv_privs.change(ZPRIVS_RAISE))
zlog (NULL, LOG_ERR, "Can't raise privileges");
@@ -59,13 +59,10 @@ if_ioctl (u_long request, caddr_t buffer)
perror ("socket");
exit (1);
}
- ret = ioctl (sock, request, buffer);
+ if ((ret = ioctl (sock, request, buffer)) < 0)
+ err = errno;
if (zserv_privs.change(ZPRIVS_LOWER))
zlog (NULL, LOG_ERR, "Can't lower privileges");
- if (ret < 0)
- {
- err = errno;
- }
close (sock);
if (ret < 0)
@@ -81,8 +78,8 @@ int
if_ioctl_ipv6 (u_long request, caddr_t buffer)
{
int sock;
- int ret = 0;
- int err = 0;
+ int ret;
+ int err;
if (zserv_privs.change(ZPRIVS_RAISE))
zlog (NULL, LOG_ERR, "Can't raise privileges");
@@ -95,14 +92,10 @@ if_ioctl_ipv6 (u_long request, caddr_t buffer)
exit (1);
}
- ret = ioctl (sock, request, buffer);
+ if ((ret = ioctl (sock, request, buffer)) < 0)
+ err = errno;
if (zserv_privs.change(ZPRIVS_LOWER))
zlog (NULL, LOG_ERR, "Can't lower privileges");
-
- if (ret < 0)
- {
- err = errno;
- }
close (sock);
if (ret < 0)
diff --git a/zebra/ioctl_solaris.c b/zebra/ioctl_solaris.c
index 8ebd0f41..5ec327ac 100644
--- a/zebra/ioctl_solaris.c
+++ b/zebra/ioctl_solaris.c
@@ -46,8 +46,8 @@ int
if_ioctl (u_long request, caddr_t buffer)
{
int sock;
- int ret = 0;
- int err = 0;
+ int ret;
+ int err;
if (zserv_privs.change(ZPRIVS_RAISE))
zlog (NULL, LOG_ERR, "Can't raise privileges");
@@ -61,15 +61,12 @@ if_ioctl (u_long request, caddr_t buffer)
exit (1);
}
- ret = ioctl (sock, request, buffer);
+ if ((ret = ioctl (sock, request, buffer)) < 0)
+ err = errno;
if (zserv_privs.change(ZPRIVS_LOWER))
zlog (NULL, LOG_ERR, "Can't lower privileges");
- if (ret < 0)
- {
- err = errno;
- }
close (sock);
if (ret < 0)
@@ -86,8 +83,8 @@ if_ioctl_ipv6 (u_long request, caddr_t buffer)
{
#ifdef HAVE_IPV6
int sock;
- int ret = 0;
- int err = 0;
+ int ret;
+ int err;
if (zserv_privs.change(ZPRIVS_RAISE))
zlog (NULL, LOG_ERR, "Can't raise privileges");
@@ -101,15 +98,12 @@ if_ioctl_ipv6 (u_long request, caddr_t buffer)
exit (1);
}
- ret = ioctl (sock, request, buffer);
+ if ((ret = ioctl (sock, request, buffer)) < 0)
+ err = errno;
if (zserv_privs.change(ZPRIVS_LOWER))
zlog (NULL, LOG_ERR, "Can't lower privileges");
- if (ret < 0)
- {
- err = errno;
- }
close (sock);
if (ret < 0)
diff --git a/zebra/ipforward_solaris.c b/zebra/ipforward_solaris.c
index 2eaf3416..3ad2c400 100644
--- a/zebra/ipforward_solaris.c
+++ b/zebra/ipforward_solaris.c
@@ -87,10 +87,12 @@ solaris_nd(const int cmd, const char* parameter, const int value)
}
if (ioctl (fd, I_STR, &strioctl) < 0)
{
+ int save_errno = errno;
if ( zserv_privs.change (ZPRIVS_LOWER) )
zlog_err ("solaris_nd: Can't lower privileges");
close (fd);
- zlog_warn("ioctl I_STR failed on device %s - %s", device,safe_strerror(errno));
+ zlog_warn("ioctl I_STR failed on device %s - %s",
+ device, safe_strerror(save_errno));
return -1;
}
close(fd);
diff --git a/zebra/irdp_main.c b/zebra/irdp_main.c
index 8c164486..0db2a54d 100644
--- a/zebra/irdp_main.c
+++ b/zebra/irdp_main.c
@@ -101,19 +101,21 @@ int
irdp_sock_init (void)
{
int ret, i;
+ int save_errno;
if ( zserv_privs.change (ZPRIVS_RAISE) )
zlog_err ("irdp_sock_init: could not raise privs, %s",
safe_strerror (errno) );
irdp_sock = socket (AF_INET, SOCK_RAW, IPPROTO_ICMP);
+ save_errno = errno;
if ( zserv_privs.change (ZPRIVS_LOWER) )
zlog_err ("irdp_sock_init: could not lower privs, %s",
safe_strerror (errno) );
if (irdp_sock < 0) {
- zlog_warn ("IRDP: can't create irdp socket %s", safe_strerror(errno));
+ zlog_warn ("IRDP: can't create irdp socket %s", safe_strerror(save_errno));
return irdp_sock;
};