我得到的编译错误:error: ‘scmp_filter_ctx’ was not declared in this scope
。
我已经声明了一个过滤器的Seccomp。 scmp_filter_ctx ctx;
我已经包括图书馆#include <linux/seccomp.h>
并已经安装使用libseccomp-dev
库sudo apt-get install libseccomp-dev
。
#include <stdlib.h>
#include <fcntl.h>
#include <sys/shm.h>
#include <unistd.h>
#include <sys/un.h>
#include <sys/wait.h>
#include <linux/seccomp.h>
#include <sys/prctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <bits/stdc++.h>
void create_sandbox(){
scmp_filter_ctx ctx;
ctx = seccomp_init(SCMP_ACT_KILL); // default action: kill
seccomp_load(ctx);
}
我设法用下面来解决这个错误:
与#include <linux/seccomp.h>
并在编译取代#include <seccomp.h>
,使用g++ filename.cpp -lseccomp
。
这为我工作。