Skip to content

Commit

Permalink
firemon fix for xdg-bus-proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
netblue30 committed Aug 22, 2020
1 parent c64ce29 commit 2c76948
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/firejail/dbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#define DBUS_USER_PROXY_SOCKET_FORMAT DBUS_USER_DIR_FORMAT "/%d-user"
#define DBUS_SYSTEM_PROXY_SOCKET_FORMAT DBUS_USER_DIR_FORMAT "/%d-system"
#define DBUS_MAX_NAME_LENGTH 255
#define XDG_DBUS_PROXY_PATH "/usr/bin/xdg-dbus-proxy"
// moved to include/common.h - #define XDG_DBUS_PROXY_PATH "/usr/bin/xdg-dbus-proxy"

static pid_t dbus_proxy_pid = 0;
static int dbus_proxy_status_fd = -1;
Expand Down
1 change: 1 addition & 0 deletions src/firejail/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,7 @@ static void run_cmd_and_exit(int i, int argc, char **argv) {
if (checkcfg(CFG_SECCOMP)) {
// print seccomp filter for a sandbox specified by pid or by name
pid_t pid = require_pid(argv[i] + 17);
printf("pid %d\n", pid);
protocol_print_filter(pid);
}
else
Expand Down
7 changes: 6 additions & 1 deletion src/firemon/firemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ int find_child(int id) {
// find the first child
for (i = 0; i < max_pids; i++) {
if (pids[i].level == 2 && pids[i].parent == id) {
// skip /usr/bin/xdg-dbus-proxy (started by firejail for dbus filtering)
char *cmdline = pid_proc_cmdline(i);
if (strncmp(cmdline, XDG_DBUS_PROXY_PATH, strlen(XDG_DBUS_PROXY_PATH)) == 0)
continue;

first_child = i;
break;
}
Expand All @@ -78,7 +83,7 @@ int find_child(int id) {
if (first_child == -1)
return -1;

// find the second child
// find the second-level child
for (i = 0; i < max_pids; i++) {
if (pids[i].level == 3 && pids[i].parent == first_child)
return i;
Expand Down
4 changes: 4 additions & 0 deletions src/include/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
#include <ctype.h>
#include <assert.h>

// dbus proxy path used by firejail and firemon
#define XDG_DBUS_PROXY_PATH "/usr/bin/xdg-dbus-proxy"


#define errExit(msg) do { char msgout[500]; snprintf(msgout, 500, "Error %s: %s:%d %s", msg, __FILE__, __LINE__, __FUNCTION__); perror(msgout); exit(1);} while (0)

// check if processes run with dumpable flag set
Expand Down

0 comments on commit 2c76948

Please sign in to comment.