support for libcap-ng

fixes #405
This commit is contained in:
Thomas Bernard 2020-05-07 00:10:49 +02:00
parent adb6f6fad0
commit 194566a5bd
No known key found for this signature in database
GPG Key ID: 0FF11B67A5C0863C
1 changed files with 14 additions and 0 deletions

View File

@ -47,6 +47,9 @@
#ifdef HAS_LIBCAP #ifdef HAS_LIBCAP
#include <sys/capability.h> #include <sys/capability.h>
#endif #endif
#ifdef HAS_LIBCAP_NG
#include <cap-ng.h>
#endif
/* unix sockets */ /* unix sockets */
#ifdef USE_MINIUPNPDCTL #ifdef USE_MINIUPNPDCTL
@ -2371,6 +2374,17 @@ main(int argc, char * * argv)
} }
} }
#endif /* HAS_LIBCAP */ #endif /* HAS_LIBCAP */
#ifdef HAS_LIBCAP_NG
capng_setpid(getpid());
capng_clear(CAPNG_SELECT_BOTH);
if (capng_updatev(CAPNG_ADD, CAPNG_EFFECTIVE|CAPNG_PERMITTED, CAP_NET_BROADCAST, CAP_NET_ADMIN, CAP_NET_RAW, -1) < 0) {
syslog(LOG_ERR, "capng_updatev() failed");
} else {
if (capng_apply(CAPNG_SELECT_BOTH) < 0) {
syslog(LOG_ERR, "capng_apply() failed");
}
}
#endif /* HAS_LIBCAP_NG */
/* main loop */ /* main loop */
while(!quitting) while(!quitting)