From 01b9e3fd0d354d7d4c60b1c0240f269a4fd08990 Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Fri, 10 Aug 2018 18:36:43 +0200 Subject: *: use frr_elevate_privs() (1/2: coccinelle) Signed-off-by: David Lamparter --- ripngd/ripng_interface.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'ripngd/ripng_interface.c') diff --git a/ripngd/ripng_interface.c b/ripngd/ripng_interface.c index 006389302..ef324b001 100644 --- a/ripngd/ripng_interface.c +++ b/ripngd/ripng_interface.c @@ -72,19 +72,14 @@ static int ripng_multicast_join(struct interface *ifp) * While this is bogus, privs are available and easy to use * for this call as a workaround. */ - if (ripngd_privs.change(ZPRIVS_RAISE)) - flog_err( - LIB_ERR_PRIVILEGES, - "ripng_multicast_join: could not raise privs"); + frr_elevate_privs(&ripngd_privs) { - ret = setsockopt(ripng->sock, IPPROTO_IPV6, IPV6_JOIN_GROUP, - (char *)&mreq, sizeof(mreq)); - save_errno = errno; + ret = setsockopt(ripng->sock, IPPROTO_IPV6, + IPV6_JOIN_GROUP, + (char *)&mreq, sizeof(mreq)); + save_errno = errno; - if (ripngd_privs.change(ZPRIVS_LOWER)) - flog_err( - LIB_ERR_PRIVILEGES, - "ripng_multicast_join: could not lower privs"); + } if (ret < 0 && save_errno == EADDRINUSE) { /* -- cgit v1.2.3