[GH-ISSUE #2867] Can't seem to stop .Xauthority or .asound from being created/copied #1789

Closed
opened 2026-05-05 08:27:42 -06:00 by gitea-mirror · 7 comments
Owner

Originally created by @slackhead on GitHub (Jul 22, 2019).
Original GitHub issue: https://github.com/netblue30/firejail/issues/2867

firejail 0.9.60

I would like to run shell scripts that don't require network, X11 or sound

firejail --x11=none --net=none --nosound --private=./ sh

Originally created by @slackhead on GitHub (Jul 22, 2019). Original GitHub issue: https://github.com/netblue30/firejail/issues/2867 firejail 0.9.60 I would like to run shell scripts that don't require network, X11 or sound firejail --x11=none --net=none --nosound --private=./ sh <script> However I can't stop .asound or .Xauthority being made in current directory. I tried blacklisting ${HOME}/.Xauthority etc. in disable-common.inc and default.profile but it didn't have any effect. I also tried with --noprofile too but it didn't help. Any ideas?
gitea-mirror 2026-05-05 08:27:42 -06:00
Author
Owner

@rusty-snake commented on GitHub (Jul 22, 2019):

  1. --private=./ for what?
  2. firejail --x11=none --net=none --nosound ls -l .Xauthority should show you r-------- and owner: nobody => firejail --x11=none --net=none --nosound cat .Xauthority ends in Permission denied
  3. If you want that they don't exist, you need to use whitelist.
    EDIT:
    To deny access to .asound you need --blacklist=${HOME}/.asound.
<!-- gh-comment-id:513773207 --> @rusty-snake commented on GitHub (Jul 22, 2019): 1. `--private=./` for what? 2. `firejail --x11=none --net=none --nosound ls -l .Xauthority` should show you `r--------` and owner: `nobody` => `firejail --x11=none --net=none --nosound cat .Xauthority` ends in `Permission denied` 3. If you want that they don't exist, you need to use `whitelist`. EDIT: To deny access to `.asound` you need `--blacklist=${HOME}/.asound`.
Author
Owner

@slackhead commented on GitHub (Jul 22, 2019):

Hi

1 I need to block any writing to filesystem except for the current directory and /tmp. --chroot seems to want the cwd to be owned by root.

2 The current directory is a build directory whch will be synced with a git repo after each shell script has been tested, so I don't want any extra files created.

I have tried to whitelist them but it makes no difference:

whitelist ${HOME}/.asoundrc
whitelist ${HOME}/.Xauthority

in both default.profile and whitelist-common.inc.

Thanks

EDIT

It seems --chroot wants a real chroot with /proc etc. anyway.

<!-- gh-comment-id:513777743 --> @slackhead commented on GitHub (Jul 22, 2019): Hi 1 I need to block any writing to filesystem except for the current directory and /tmp. --chroot seems to want the cwd to be owned by root. 2 The current directory is a build directory whch will be synced with a git repo after each shell script has been tested, so I don't want any extra files created. I have tried to whitelist them but it makes no difference: whitelist ${HOME}/.asoundrc whitelist ${HOME}/.Xauthority in both default.profile and whitelist-common.inc. Thanks EDIT It seems --chroot wants a real chroot with /proc etc. anyway.
Author
Owner

@rusty-snake commented on GitHub (Jul 22, 2019):

Well, now I get you setup and intend.

I have tried to whitelist them but it makes no difference:

whitelisting the files you want, not the files you don't want. Anyway.

I need to block any writing to filesystem except for the current directory and /tmp.

--private=. will only protect ${HOME}.
You can use --read-only=PATH to mount PATH ro.

<!-- gh-comment-id:513784910 --> @rusty-snake commented on GitHub (Jul 22, 2019): Well, now I get you setup and intend. > I have tried to whitelist them but it makes no difference: `whitelist`ing the files you want, not the files you don't want. Anyway. > I need to block any writing to filesystem except for the current directory and /tmp. `--private=.` will only protect `${HOME}`. You can use `--read-only=PATH` to mount PATH `ro`.
Author
Owner

@rusty-snake commented on GitHub (Jul 22, 2019):

@slackhead can you try firejail --x11=none --net=none --nosound --whitelist=${HOME}/GIT_REPO bash SCRIPT

<!-- gh-comment-id:513786589 --> @rusty-snake commented on GitHub (Jul 22, 2019): @slackhead can you try `firejail --x11=none --net=none --nosound --whitelist=${HOME}/GIT_REPO bash SCRIPT`
Author
Owner

@slackhead commented on GitHub (Jul 22, 2019):

Thanks, that helps a lot. I have a couple of different ideas. This one blacklists /tmp too:

firejail \
  --shell=none \
  --net=none \
  --x11=none \
  --nosound \
  --blacklist=/tmp \
  --whitelist=`pwd` \
  --noprofile $@

I also will need to run some scripts as root and be able to use ccache. I think something like this should work if I set the ccache directory to a named overlay in /root/.firejail/sbo/odiff/root/.ccache

firejail \
--net=none \
--shell=none \
--nosound \
--x11=none \
--noprofile \
--read-only=`pwd` \
--overlay-named=sbo \
sh <script>

Hopefully that leaves only /tmp writeable, and I should be able to find /root/.firejail to see if anything tried write anywhere else.

<!-- gh-comment-id:513846640 --> @slackhead commented on GitHub (Jul 22, 2019): Thanks, that helps a lot. I have a couple of different ideas. This one blacklists /tmp too: ``` firejail \ --shell=none \ --net=none \ --x11=none \ --nosound \ --blacklist=/tmp \ --whitelist=`pwd` \ --noprofile $@ ``` I also will need to run some scripts as root and be able to use ccache. I think something like this should work if I set the ccache directory to a named overlay in /root/.firejail/sbo/odiff/root/.ccache ``` firejail \ --net=none \ --shell=none \ --nosound \ --x11=none \ --noprofile \ --read-only=`pwd` \ --overlay-named=sbo \ sh <script> ``` Hopefully that leaves only /tmp writeable, and I should be able to find /root/.firejail to see if anything tried write anywhere else.
Author
Owner

@smitsohu commented on GitHub (Jul 26, 2019):

IMHO it would be "more right" to indeed not copy these files if there is a nosound or x11 none option.

<!-- gh-comment-id:515436140 --> @smitsohu commented on GitHub (Jul 26, 2019): IMHO it would be "more right" to indeed not copy these files if there is a `nosound` or `x11 none` option.
Author
Owner

@smitsohu commented on GitHub (Aug 7, 2019):

Should be fixed.

<!-- gh-comment-id:519119604 --> @smitsohu commented on GitHub (Aug 7, 2019): Should be 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#1789
No description provided.