1 Star 0 Fork 1

boeib / memcached-memcached-master

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
openbsd_priv.c 921 Bytes
一键复制 编辑 原始数据 按行查看 历史
dormando 提交于 2019-08-28 15:48 . seccomp: compile fixes for obsd/fbsd
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "memcached.h"
/*
* this section of code will drop all (OpenBSD) privileges including
* those normally granted to all userland process (basic privileges). The
* effect of this is that after running this code, the process will not able
* to fork(), exec(), etc. See pledge(2) for more information.
*/
void drop_privileges() {
extern char *__progname;
if (settings.socketpath != NULL) {
if (pledge("stdio unix", NULL) == -1) {
fprintf(stderr, "%s: pledge: %s\n", __progname, strerror(errno));
exit(EXIT_FAILURE);
}
} else {
if (pledge("stdio inet", NULL) == -1) {
fprintf(stderr, "%s: pledge: %s\n", __progname, strerror(errno));
exit(EXIT_FAILURE);
}
}
}
void setup_privilege_violations_handler(void) {
// not needed
}
1
https://gitee.com/dearbub/memcached-memcached-master.git
git@gitee.com:dearbub/memcached-memcached-master.git
dearbub
memcached-memcached-master
memcached-memcached-master
master

搜索帮助