From 10d60ad1ca677a298902beb83387363bb863fd68 Mon Sep 17 00:00:00 2001 From: gdt Date: Tue, 23 Dec 2003 17:34:39 +0000 Subject: 2003-12-23 Krzysztof Oledzki * bgp_network.c: drop privs on error cases (from [quagga-dev 438]) --- bgpd/ChangeLog | 4 ++++ bgpd/bgp_network.c | 23 +++++++++++++---------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/bgpd/ChangeLog b/bgpd/ChangeLog index c97dbcef..428c2b93 100644 --- a/bgpd/ChangeLog +++ b/bgpd/ChangeLog @@ -1,3 +1,7 @@ +2003-12-23 Krzysztof Oledzki + + * bgp_network.c: drop privs on error cases + 2003-08-11 kunihiro ai_addr, ainfo->ai_addrlen); + en = errno; + if (bgpd_privs.change (ZPRIVS_LOWER) ) + zlog_err ("bgp_bind_address: could not lower privs"); + if (ret < 0) { - zlog_err ("bind: %s", strerror (errno)); - close (sock); + zlog_err ("bind: %s", strerror (en)); + close(sock); continue; } - if (bgpd_privs.change (ZPRIVS_LOWER) ) - zlog_err ("bgp_bind_address: could not lower privs"); - ret = listen (sock, 3); if (ret < 0) { @@ -381,16 +382,18 @@ bgp_socket (struct bgp *bgp, unsigned short port) zlog_err ("bgp_socket: could not raise privs"); ret = bind (sock, (struct sockaddr *) &sin, socklen); + en = errno; + + if (bgpd_privs.change (ZPRIVS_LOWER) ) + zlog_err ("bgp_socket: could not lower privs"); + if (ret < 0) { - zlog_err ("bind: %s", strerror (errno)); + zlog_err ("bind: %s", strerror (en)); close (sock); return ret; } - if (bgpd_privs.change (ZPRIVS_LOWER) ) - zlog_err ("bgp_socket: could not lower privs"); - ret = listen (sock, 3); if (ret < 0) { -- cgit v1.2.1