提交 7f10f940 编写于 作者: G Guillaume Nault 提交者: Dmitry Kozlov

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: NGuillaume Nault <g.nault@alphalink.fr>
上级 6644c1fe
#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();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册