diff options
Diffstat (limited to 'zebra/ipforward_solaris.c')
| -rw-r--r-- | zebra/ipforward_solaris.c | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/zebra/ipforward_solaris.c b/zebra/ipforward_solaris.c index 123cf1bd08..b06baa04a9 100644 --- a/zebra/ipforward_solaris.c +++ b/zebra/ipforward_solaris.c @@ -25,6 +25,7 @@ #include "log.h" #include "prefix.h" +#include "lib_errors.h" #include "privs.h" #include "zebra/ipforward.h" @@ -69,10 +70,10 @@ static int solaris_nd(const int cmd, const char *parameter, const int value) else if (cmd == ND_GET) snprintf(nd_buf, ND_BUFFER_SIZE, "%s", parameter); else { - zlog_err( - "internal error - inappropriate command given to " - "solaris_nd()%s:%d", - __FILE__, __LINE__); + flog_err_sys(LIB_ERR_SYSTEM_CALL, + "internal error - inappropriate command given to " + "solaris_nd()%s:%d", + __FILE__, __LINE__); return -1; } @@ -81,27 +82,21 @@ static int solaris_nd(const int cmd, const char *parameter, const int value) strioctl.ic_len = ND_BUFFER_SIZE; strioctl.ic_dp = nd_buf; - if (zserv_privs.change(ZPRIVS_RAISE)) - zlog_err("solaris_nd: Can't raise privileges"); - if ((fd = open(device, O_RDWR)) < 0) { - zlog_warn("failed to open device %s - %s", device, - safe_strerror(errno)); - if (zserv_privs.change(ZPRIVS_LOWER)) - zlog_err("solaris_nd: Can't lower privileges"); - return -1; - } - 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"); + frr_elevate_privs(&zserv_privs) { + if ((fd = open(device, O_RDWR)) < 0) { + zlog_warn("failed to open device %s - %s", device, + safe_strerror(errno)); + return -1; + } + if (ioctl(fd, I_STR, &strioctl) < 0) { + close(fd); + zlog_warn("ioctl I_STR failed on device %s - %s", + device, + safe_strerror(errno)); + return -1; + } close(fd); - zlog_warn("ioctl I_STR failed on device %s - %s", device, - safe_strerror(save_errno)); - return -1; } - close(fd); - if (zserv_privs.change(ZPRIVS_LOWER)) - zlog_err("solaris_nd: Can't lower privileges"); if (cmd == ND_GET) { errno = 0; |
