Merge isisd into the Quagga's framework:
- add privs support
- use misc quagga's definitions
- make it compile"able"
- fix segfault cases related to hostname()
- add debug isis xxx command
This patch has been approved by Paul Jakma.
diff --git a/isisd/isis_network.c b/isisd/isis_network.c
index d22f3dd..c10aeeb 100644
--- a/isisd/isis_network.c
+++ b/isisd/isis_network.c
@@ -42,6 +42,10 @@
#include "isisd/isis_circuit.h"
#include "isisd/isis_network.h"
+#include "privs.h"
+
+extern struct zebra_privs_t isisd_privs;
+
/*
* On linux we can use the packet(7) sockets, in other OSs we have to do with
* Berkley Packet Filter (BPF). Please tell me if you can think of a better
@@ -297,28 +301,39 @@
{
int retval = ISIS_OK;
+ if ( isisd_privs.change (ZPRIVS_RAISE) )
+ zlog_err ("%s: could not raise privs, %s", __func__,
+ strerror (errno) );
#ifdef GNU_LINUX
retval = open_packet_socket (circuit);
#else
retval = open_bpf_dev (circuit);
#endif
-
- if (retval == ISIS_OK) {
- if (circuit->circ_type == CIRCUIT_T_BROADCAST) {
- circuit->tx = isis_send_pdu_bcast;
- circuit->rx = isis_recv_pdu_bcast;
- }
- else if (circuit->circ_type == CIRCUIT_T_P2P) {
- circuit->tx = isis_send_pdu_p2p;
- circuit->rx = isis_recv_pdu_p2p;
- }
- else {
- zlog_warn ("isis_sock_init(): unknown circuit type");
- retval = ISIS_WARNING;
- }
+
+ if (retval != ISIS_OK) {
+ zlog_warn("%s: could not initialize the socket",
+ __func__);
+ goto end;
}
-
+
+ if (circuit->circ_type == CIRCUIT_T_BROADCAST) {
+ circuit->tx = isis_send_pdu_bcast;
+ circuit->rx = isis_recv_pdu_bcast;
+ } else if (circuit->circ_type == CIRCUIT_T_P2P) {
+ circuit->tx = isis_send_pdu_p2p;
+ circuit->rx = isis_recv_pdu_p2p;
+ } else {
+ zlog_warn ("isis_sock_init(): unknown circuit type");
+ retval = ISIS_WARNING;
+ goto end;
+ }
+
+end:
+ if ( isisd_privs.change (ZPRIVS_LOWER) )
+ zlog_err ("%s: could not lower privs, %s", __func__,
+ strerror (errno) );
+
return retval;
}