From 7f10f9404abc9e95998ead236180a2e5e7de1f80 Mon Sep 17 00:00:00 2001 From: Guillaume Nault Date: Mon, 28 Apr 2014 21:13:41 +0200 Subject: [PATCH] net-snmp: unshare file descriptors namespace Use unshare(CLONE_FILES) to create a local file descriptors namespace for the SNMP thread. This is similar to what was done in bf5340 'net-snmp: run snmp in "special" thread', but without calling clone() directly. So the net-snmp plugin keeps running in a regular pthread. Signed-off-by: Guillaume Nault --- accel-pppd/extra/net-snmp/agent.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/accel-pppd/extra/net-snmp/agent.c b/accel-pppd/extra/net-snmp/agent.c index cfeb763..9f8b1a7 100644 --- a/accel-pppd/extra/net-snmp/agent.c +++ b/accel-pppd/extra/net-snmp/agent.c @@ -1,5 +1,8 @@ +#include #include +#include #include +#include #include #include @@ -80,6 +83,14 @@ static void *snmp_thread(void *a) sigdelset(&set, 32); pthread_sigmask(SIG_BLOCK, &set, NULL); + if (unshare(CLONE_FILES) < 0) { + log_error("net-snmp: impossible to start SNMP thread:" + " unshare(CLONE_FILES) failed (%s)\n", + strerror(errno)); + + return NULL; + } + snmp_register_callback(SNMP_CALLBACK_LIBRARY, SNMP_CALLBACK_LOGGING, agent_log, NULL); snmp_disable_log(); snmp_enable_calllog(); -- GitLab