diff options
author | David Lamparter <equinox@opensourcerouting.org> | 2018-08-10 18:36:43 +0200 |
---|---|---|
committer | Quentin Young <qlyoung@cumulusnetworks.com> | 2018-08-14 22:02:05 +0200 |
commit | 01b9e3fd0d354d7d4c60b1c0240f269a4fd08990 (patch) | |
tree | 7758a10d2c803e86348e04e908f73b63c0048b96 /ldpd/socket.c | |
parent | lib: add frr_elevate_privs() wrapper (diff) | |
download | frr-01b9e3fd0d354d7d4c60b1c0240f269a4fd08990.tar.xz frr-01b9e3fd0d354d7d4c60b1c0240f269a4fd08990.zip |
*: use frr_elevate_privs() (1/2: coccinelle)
Signed-off-by: David Lamparter <equinox@diac24.net>
Diffstat (limited to 'ldpd/socket.c')
-rw-r--r-- | ldpd/socket.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/ldpd/socket.c b/ldpd/socket.c index aefa3461a..1cdef8372 100644 --- a/ldpd/socket.c +++ b/ldpd/socket.c @@ -262,17 +262,13 @@ int sock_set_bindany(int fd, int enable) { #ifdef HAVE_SO_BINDANY - if (ldpd_privs.change(ZPRIVS_RAISE)) - log_warn("%s: could not raise privs", __func__); - if (setsockopt(fd, SOL_SOCKET, SO_BINDANY, &enable, - sizeof(int)) < 0) { - if (ldpd_privs.change(ZPRIVS_LOWER)) - log_warn("%s: could not lower privs", __func__); - log_warn("%s: error setting SO_BINDANY", __func__); - return (-1); + frr_elevate_privs(&ldpd_privs) { + if (setsockopt(fd, SOL_SOCKET, SO_BINDANY, &enable, + sizeof(int)) < 0) { + log_warn("%s: error setting SO_BINDANY", __func__); + return (-1); + } } - if (ldpd_privs.change(ZPRIVS_LOWER)) - log_warn("%s: could not lower privs", __func__); return (0); #elif defined(HAVE_IP_FREEBIND) if (setsockopt(fd, IPPROTO_IP, IP_FREEBIND, &enable, sizeof(int)) < 0) { |