Skip to content

Commit

Permalink
fix --join for sandboxes with xdg-dbuss-proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
netblue30 committed Aug 22, 2020
1 parent 2c76948 commit dbab21a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/firejail/join.c
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ pid_t switch_to_child(pid_t pid) {
exit(1);
}
EUID_USER();

if (strcmp(comm, "firejail") == 0) {
if (find_child(pid, &rv) == 1) {
fprintf(stderr, "Error: no valid sandbox\n");
Expand Down
1 change: 0 additions & 1 deletion src/firejail/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,6 @@ 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
9 changes: 7 additions & 2 deletions src/firejail/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -647,8 +647,13 @@ int find_child(pid_t parent, pid_t *child) {
fprintf(stderr, "Error: cannot read /proc file\n");
exit(1);
}
if (parent == atoi(ptr))
*child = pid;
if (parent == atoi(ptr)) {
// we don't want /usr/bin/xdg-dbus-proxy!
char *cmdline = pid_proc_cmdline(pid);
if (strncmp(cmdline, XDG_DBUS_PROXY_PATH, strlen(XDG_DBUS_PROXY_PATH)) != 0)
*child = pid;
free(cmdline);
}
break; // stop reading the file
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/firemon/firemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,11 @@ int find_child(int id) {
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)
if (strncmp(cmdline, XDG_DBUS_PROXY_PATH, strlen(XDG_DBUS_PROXY_PATH)) == 0) {
free(cmdline);
continue;

}
free(cmdline);
first_child = i;
break;
}
Expand Down

0 comments on commit dbab21a

Please sign in to comment.