1 Star 0 Fork 1

frank / memcached

forked from 苏小逝 / memcached 
加入 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
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/test_yx/memcached.git
git@gitee.com:test_yx/memcached.git
test_yx
memcached
memcached
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891