Add sandbox support to irssi

This commit is contained in:
namnamc 2015-10-26 18:52:05 -07:00
commit 18f7b4694c
9 changed files with 875 additions and 0 deletions

View file

@ -28,6 +28,7 @@
#include "settings.h"
#include "session.h"
#include "servers.h"
#include "sandbox.h"
#include "printtext.h"
#include "fe-common-core.h"
@ -74,11 +75,20 @@ void mainwindow_activity_deinit(void);
void mainwindows_layout_init(void);
void mainwindows_layout_deinit(void);
#ifdef HAVE_SECCOMP
void create_namespaces(void);
void drop_privileges(void);
void enforce_resource_limits(void);
void enforce_seccomp_sandbox(void);
#endif
void term_dummy_init(void);
void term_dummy_deinit(void);
static int dirty, full_redraw, dummy;
int sandbox = 0;
static GMainLoop *main_loop;
int quitting;
@ -292,6 +302,7 @@ int main(int argc, char **argv)
static GOptionEntry options[] = {
{ "dummy", 'd', 0, G_OPTION_ARG_NONE, &dummy, "Use the dummy terminal mode", NULL },
{ "version", 'v', 0, G_OPTION_ARG_NONE, &version, "Display irssi version", NULL },
{ "sandbox", 's', 0, G_OPTION_ARG_NONE, &sandbox, "Enable the sandbox", NULL },
{ NULL }
};
int loglev;
@ -307,6 +318,18 @@ int main(int argc, char **argv)
return 0;
}
if (sandbox) {
#ifdef HAVE_SECCOMP
create_namespaces();
drop_privileges();
enforce_resource_limits();
enable_seccomp_sandbox();
#else
fprintf(stderr, "This build does not support sandboxing\n");
return 1;
#endif
}
srand(time(NULL));
dummy = FALSE;