aboutsummaryrefslogtreecommitdiffstats
path: root/src/firejail/list.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/firejail/list.c')
-rw-r--r--src/firejail/list.c101
1 files changed, 0 insertions, 101 deletions
diff --git a/src/firejail/list.c b/src/firejail/list.c
deleted file mode 100644
index d093a1f85..000000000
--- a/src/firejail/list.c
+++ /dev/null
@@ -1,101 +0,0 @@
1/*
2 * Copyright (C) 2014-2016 Firejail Authors
3 *
4 * This file is part of firejail project
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19*/
20#include "firejail.h"
21#include <sys/types.h>
22#include <sys/stat.h>
23
24static void set_privileges(void) {
25 struct stat s;
26 if (stat("/proc/sys/kernel/grsecurity", &s) == 0) {
27 EUID_ROOT();
28
29 // elevate privileges
30 if (setreuid(0, 0))
31 errExit("setreuid");
32 if (setregid(0, 0))
33 errExit("setregid");
34 }
35 else
36 drop_privs(1);
37}
38
39static char *get_firemon_path(const char *cmd) {
40 assert(cmd);
41
42 // start the argv[0] program in a new sandbox
43 char *firemon;
44 if (asprintf(&firemon, "%s/bin/firemon %s", PREFIX, cmd) == -1)
45 errExit("asprintf");
46
47 return firemon;
48}
49
50void top(void) {
51 EUID_ASSERT();
52 drop_privs(1);
53 char *cmd = get_firemon_path("--top");
54
55 char *arg[4];
56 arg[0] = "bash";
57 arg[1] = "-c";
58 arg[2] = cmd;
59 arg[3] = NULL;
60 execvp("/bin/bash", arg);
61}
62
63void netstats(void) {
64 EUID_ASSERT();
65 set_privileges();
66 char *cmd = get_firemon_path("--netstats");
67
68 char *arg[4];
69 arg[0] = "bash";
70 arg[1] = "-c";
71 arg[2] = cmd;
72 arg[3] = NULL;
73 execvp("/bin/bash", arg);
74}
75
76void list(void) {
77 EUID_ASSERT();
78 drop_privs(1);
79 char *cmd = get_firemon_path("--list");
80
81 char *arg[4];
82 arg[0] = "bash";
83 arg[1] = "-c";
84 arg[2] = cmd;
85 arg[3] = NULL;
86 execvp("/bin/bash", arg);
87}
88
89void tree(void) {
90 EUID_ASSERT();
91 drop_privs(1);
92 char *cmd = get_firemon_path("--tree");
93
94 char *arg[4];
95 arg[0] = "bash";
96 arg[1] = "-c";
97 arg[2] = cmd;
98 arg[3] = NULL;
99 execvp("/bin/bash", arg);
100}
101