[GH-ISSUE #4646] private-bin throws fopen: Permission denied after latest related commits #2738

Closed
opened 2026-05-05 09:24:13 -06:00 by gitea-mirror · 6 comments
Owner

Originally created by @ghost on GitHub (Oct 27, 2021).
Original GitHub issue: https://github.com/netblue30/firejail/issues/4646

Profiles with private-bin recently started to throw fopen: Permission denied for me with firejail built from git:

$ firejail --ignore=quiet --private-bin=bash
Reading profile /etc/firejail/default.profile
Reading profile /etc/firejail/disable-common.inc
Reading profile /etc/firejail/disable-common.local
Reading profile /etc/firejail/disable-programs.inc
Reading profile /etc/firejail/disable-programs.local

** Note: you can use --noprofile to disable default.profile **

Parent pid 3823180, child pid 3823200
fopen: Permission denied
1 program installed in 23.09 ms
Child process initialized in 778.53 ms

Compare that to:

$ firejail --ignore=quiet
Reading profile /etc/firejail/default.profile
Reading profile /etc/firejail/disable-common.inc
Reading profile /etc/firejail/disable-common.local
Reading profile /etc/firejail/disable-programs.inc
Reading profile /etc/firejail/disable-programs.local

** Note: you can use --noprofile to disable default.profile **

Parent pid 3828120, child pid 3828125
Child process initialized in 342.88 ms

Bisecting points to these commits:

7f0b5ddd88
ee1d5d7c8c
98df98e998

@smitsohu Any insights on why this could be happening?

Originally created by @ghost on GitHub (Oct 27, 2021). Original GitHub issue: https://github.com/netblue30/firejail/issues/4646 Profiles with `private-bin` recently started to throw `fopen: Permission denied` for me with firejail built from git: ``` $ firejail --ignore=quiet --private-bin=bash Reading profile /etc/firejail/default.profile Reading profile /etc/firejail/disable-common.inc Reading profile /etc/firejail/disable-common.local Reading profile /etc/firejail/disable-programs.inc Reading profile /etc/firejail/disable-programs.local ** Note: you can use --noprofile to disable default.profile ** Parent pid 3823180, child pid 3823200 fopen: Permission denied 1 program installed in 23.09 ms Child process initialized in 778.53 ms ``` Compare that to: ``` $ firejail --ignore=quiet Reading profile /etc/firejail/default.profile Reading profile /etc/firejail/disable-common.inc Reading profile /etc/firejail/disable-common.local Reading profile /etc/firejail/disable-programs.inc Reading profile /etc/firejail/disable-programs.local ** Note: you can use --noprofile to disable default.profile ** Parent pid 3828120, child pid 3828125 Child process initialized in 342.88 ms ``` Bisecting points to these commits: https://github.com/netblue30/firejail/commit/7f0b5ddd8881c5276138b061109ab48eb5165201 https://github.com/netblue30/firejail/commit/ee1d5d7c8cb2f7b3ab81125168881040f5d17d48 https://github.com/netblue30/firejail/commit/98df98e9987357f893cdd1b0f5c9aa8d93ae8d23 @smitsohu Any insights on why this could be happening?
Author
Owner

@rusty-snake commented on GitHub (Oct 27, 2021):

Minimal STR: firejail --noprofile --private-bin=true true

Snipped from --debug:

Copying files in the new bin directory
Checking /usr/local/bin/true
Checking /usr/bin/true
sbox run: /run/firejail/lib/fcopy /usr/bin/true /run/firejail/mnt/bin 
Relabeling /run/firejail/mnt/bin/true as /usr/bin/true (system_u:object_r:bin_t:s0)
fopen: Permission denied
Mount-bind /run/firejail/mnt/bin on top of /usr/local/bin
Mount-bind /run/firejail/mnt/bin on top of /usr/bin
Mount-bind /run/firejail/mnt/bin on top of /bin
Mount-bind /run/firejail/mnt/bin on top of /usr/games
Mount-bind /run/firejail/mnt/bin on top of /usr/sbin
Mount-bind /run/firejail/mnt/bin on top of /sbin
Relabeling /run/firejail/mnt/bin as /bin (system_u:object_r:bin_t:s0)
1 program installed in 8.21 ms
<!-- gh-comment-id:952720310 --> @rusty-snake commented on GitHub (Oct 27, 2021): Minimal STR: `firejail --noprofile --private-bin=true true` Snipped from `--debug`: ``` Copying files in the new bin directory Checking /usr/local/bin/true Checking /usr/bin/true sbox run: /run/firejail/lib/fcopy /usr/bin/true /run/firejail/mnt/bin Relabeling /run/firejail/mnt/bin/true as /usr/bin/true (system_u:object_r:bin_t:s0) fopen: Permission denied Mount-bind /run/firejail/mnt/bin on top of /usr/local/bin Mount-bind /run/firejail/mnt/bin on top of /usr/bin Mount-bind /run/firejail/mnt/bin on top of /bin Mount-bind /run/firejail/mnt/bin on top of /usr/games Mount-bind /run/firejail/mnt/bin on top of /usr/sbin Mount-bind /run/firejail/mnt/bin on top of /sbin Relabeling /run/firejail/mnt/bin as /bin (system_u:object_r:bin_t:s0) 1 program installed in 8.21 ms ```
Author
Owner

@smitsohu commented on GitHub (Oct 27, 2021):

Thanks!

The message is coming from here:
efbf74e124/src/firejail/fs_logger.c (L91-L100)

If private-bin is the first to call fs_logger_print() it must be root to create the file. I'll push a fix shortly.

<!-- gh-comment-id:952886837 --> @smitsohu commented on GitHub (Oct 27, 2021): Thanks! The message is coming from here: https://github.com/netblue30/firejail/blob/efbf74e12421c97d8a1756649422f83f4a0b7e50/src/firejail/fs_logger.c#L91-L100 If `private-bin` is the first to call fs_logger_print() it must be root to create the file. I'll push a fix shortly.
Author
Owner

@smitsohu commented on GitHub (Oct 27, 2021):

I'll push a fix shortly.

Ah sorry, I didn't see that @glitsj16 already wanted to work on it. It's yours :)

<!-- gh-comment-id:952895865 --> @smitsohu commented on GitHub (Oct 27, 2021): > I'll push a fix shortly. Ah sorry, I didn't see that @glitsj16 already wanted to work on it. It's yours :)
Author
Owner

@ghost commented on GitHub (Oct 27, 2021):

Ah sorry, I didn't see that @glitsj16 already wanted to work on it. It's yours :)

I'm not sure what happened, but I think GitHub assigned me automatically somehow.
@smitsohu I don't want to break things, please push your fix :)

<!-- gh-comment-id:953170716 --> @ghost commented on GitHub (Oct 27, 2021): > Ah sorry, I didn't see that @glitsj16 already wanted to work on it. It's yours :) I'm not sure what happened, but I think GitHub assigned me automatically somehow. @smitsohu I don't want to break things, please push your fix :)
Author
Owner

@smitsohu commented on GitHub (Oct 28, 2021):

Well... it looks like I am breaking things, too ;)

<!-- gh-comment-id:953865839 --> @smitsohu commented on GitHub (Oct 28, 2021): Well... it looks like I am breaking things, too ;)
Author
Owner

@smitsohu commented on GitHub (Oct 29, 2021):

Fixed!

<!-- gh-comment-id:954610484 --> @smitsohu commented on GitHub (Oct 29, 2021): Fixed!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/firejail#2738
No description provided.