diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/firemon/firemon.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/src/firemon/firemon.c b/src/firemon/firemon.c index f89196f21..1f3fdd578 100644 --- a/src/firemon/firemon.c +++ b/src/firemon/firemon.c | |||
@@ -52,15 +52,35 @@ static void my_handler(int s){ | |||
52 | exit(0); | 52 | exit(0); |
53 | } | 53 | } |
54 | 54 | ||
55 | // find the first child process for the specified pid | 55 | // find the second child process for the specified pid |
56 | // return -1 if not found | 56 | // return -1 if not found |
57 | // | ||
58 | // Example: | ||
59 | //14776:netblue:/usr/bin/firejail /usr/bin/transmission-qt | ||
60 | // 14777:netblue:/usr/bin/firejail /usr/bin/transmission-qt | ||
61 | // 14792:netblue:/usr/bin/transmission-qt | ||
62 | // We need 14792, the first real sandboxed process | ||
57 | int find_child(int id) { | 63 | int find_child(int id) { |
58 | int i; | 64 | int i; |
65 | int first_child = -1; | ||
66 | |||
67 | // find the first child | ||
59 | for (i = 0; i < max_pids; i++) { | 68 | for (i = 0; i < max_pids; i++) { |
60 | if (pids[i].level == 2 && pids[i].parent == id) | 69 | if (pids[i].level == 2 && pids[i].parent == id) { |
61 | return i; | 70 | first_child = i; |
71 | break; | ||
72 | } | ||
62 | } | 73 | } |
63 | 74 | ||
75 | if (first_child == -1) | ||
76 | return -1; | ||
77 | |||
78 | // find the second child | ||
79 | for (i = 0; i < max_pids; i++) { | ||
80 | if (pids[i].level == 3 && pids[i].parent == first_child) | ||
81 | return i; | ||
82 | } | ||
83 | |||
64 | return -1; | 84 | return -1; |
65 | } | 85 | } |
66 | 86 | ||