pratyush chaudhary
pratyush chaudhary

Reputation: 39

error: ‘scmp_filter_ctx’ was not declared in this scope

I am getting compilation error:error: ‘scmp_filter_ctx’ was not declared in this scope.
I have declared a seccomp filter. scmp_filter_ctx ctx;

I have included the library #include <linux/seccomp.h> and already installed the library libseccomp-dev using 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);
}

Upvotes: 1

Views: 577

Answers (1)

pratyush chaudhary
pratyush chaudhary

Reputation: 39

I managed to solve this error using the following:

Replaced #include <linux/seccomp.h> with #include <seccomp.h> and while compiling, used g++ filename.cpp -lseccomp.

This worked for me.

Upvotes: 2

Related Questions