disable ping when smartdns run as non-root user

This commit is contained in:
Nick Peng
2019-10-27 16:51:11 +08:00
parent 64abad4077
commit fb3b0a7245
3 changed files with 48 additions and 0 deletions

View File

@@ -7,6 +7,7 @@
#include <errno.h>
#include <fcntl.h>
#include <linux/netlink.h>
#include <linux/capability.h>
#include <openssl/crypto.h>
#include <openssl/ssl.h>
#include <pthread.h>
@@ -17,6 +18,7 @@
#include <time.h>
#include <unistd.h>
#include <inttypes.h>
#include <sys/prctl.h>
#define TMP_BUFF_LEN_32 32
@@ -920,3 +922,14 @@ void get_compiled_time(struct tm *tm)
tm->tm_min = min;
tm->tm_sec = sec;
}
int has_network_raw_cap(void)
{
int fd = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);
if (fd < 0) {
return 0;
}
close(fd);
return 1;
}