summaryrefslogtreecommitdiff
path: root/accel-pppd/extra/net-snmp
diff options
context:
space:
mode:
authorGuillaume Nault <g.nault@alphalink.fr>2014-04-28 21:13:41 +0200
committerDmitry Kozlov <xeb@mail.ru>2014-04-29 09:50:13 +0400
commit7f10f9404abc9e95998ead236180a2e5e7de1f80 (patch)
treee0642919c0fe0450e4566cd6ebd8638e778b133a /accel-pppd/extra/net-snmp
parent6644c1fee5dfe332a8c303bda85effe501f88524 (diff)
downloadaccel-ppp-7f10f9404abc9e95998ead236180a2e5e7de1f80.tar.gz
accel-ppp-7f10f9404abc9e95998ead236180a2e5e7de1f80.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>
Diffstat (limited to 'accel-pppd/extra/net-snmp')
-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 cfeb7639..9f8b1a74 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>
@@ -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();