summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Nault <g.nault@alphalink.fr>2014-04-28 21:16:09 +0200
committerDmitry Kozlov <xeb@mail.ru>2014-04-29 09:51:08 +0400
commit71df100daf6e995d0a356dc096836df9f38f8d8d (patch)
tree014bfe3975f2ab3e27bc1da3a840c47098092dc7
parentf9ef39d9e4e1b18bf21697598f543d7e5b288297 (diff)
downloadaccel-ppp-71df100daf6e995d0a356dc096836df9f38f8d8d.tar.gz
accel-ppp-71df100daf6e995d0a356dc096836df9f38f8d8d.zip
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 <g.nault@alphalink.fr>
-rw-r--r--accel-pppd/extra/net-snmp/agent.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/accel-pppd/extra/net-snmp/agent.c b/accel-pppd/extra/net-snmp/agent.c
index 7e06a79..da866ab 100644
--- a/accel-pppd/extra/net-snmp/agent.c
+++ b/accel-pppd/extra/net-snmp/agent.c
@@ -1,5 +1,8 @@
+#include <errno.h>
#include <pthread.h>
+#include <sched.h>
#include <signal.h>
+#include <string.h>
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
@@ -79,6 +82,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();