summaryrefslogtreecommitdiffstats
path: root/zebra/ioctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'zebra/ioctl.c')
-rw-r--r--zebra/ioctl.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/zebra/ioctl.c b/zebra/ioctl.c
index 3e5d1d2fb..f8e7f22b6 100644
--- a/zebra/ioctl.c
+++ b/zebra/ioctl.c
@@ -27,10 +27,13 @@
#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
ifreq_set_name (struct ifreq *ifreq, struct interface *ifp)
@@ -46,14 +49,19 @@ if_ioctl (u_long request, caddr_t buffer)
int ret = 0;
int err = 0;
+ if (zserv_privs.change(ZPRIVS_RAISE))
+ zlog (NULL, LOG_ERR, "Can't raise privileges");
sock = socket (AF_INET, SOCK_DGRAM, 0);
if (sock < 0)
{
+ if (zserv_privs.change(ZPRIVS_LOWER))
+ zlog (NULL, LOG_ERR, "Can't lower privileges");
perror ("socket");
exit (1);
}
-
ret = ioctl (sock, request, buffer);
+ if (zserv_privs.change(ZPRIVS_LOWER))
+ zlog (NULL, LOG_ERR, "Can't lower privileges");
if (ret < 0)
{
err = errno;
@@ -76,14 +84,21 @@ if_ioctl_ipv6 (u_long request, caddr_t buffer)
int ret = 0;
int err = 0;
+ if (zserv_privs.change(ZPRIVS_RAISE))
+ zlog (NULL, LOG_ERR, "Can't raise privileges");
sock = socket (AF_INET6, SOCK_DGRAM, 0);
if (sock < 0)
{
+ if (zserv_privs.change(ZPRIVS_LOWER))
+ zlog (NULL, LOG_ERR, "Can't lower privileges");
perror ("socket");
exit (1);
}
ret = ioctl (sock, request, buffer);
+ if (zserv_privs.change(ZPRIVS_LOWER))
+ zlog (NULL, LOG_ERR, "Can't lower privileges");
+
if (ret < 0)
{
err = errno;