[GH-ISSUE #216] whitelist globbing #149

Closed
opened 2026-05-05 05:10:19 -06:00 by gitea-mirror · 19 comments
Owner

Originally created by @curiosity-seeker on GitHub (Jan 10, 2016).
Original GitHub issue: https://github.com/netblue30/firejail/issues/216

I was trying to rewrite/streamline my Firejail profile for LibreOffice. One rule which I tried was

whitelist ~/*.odt

but that doesn't work. It does work, though, in the form

whitelist ~/Example.odt

So it seems that placeholders are not supported. This would be a very useful enhancement in Firejail, indeed!

Originally created by @curiosity-seeker on GitHub (Jan 10, 2016). Original GitHub issue: https://github.com/netblue30/firejail/issues/216 I was trying to rewrite/streamline my Firejail profile for LibreOffice. One rule which I tried was whitelist ~/*.odt but that doesn't work. It does work, though, in the form whitelist ~/Example.odt So it seems that placeholders are not supported. This would be a very useful enhancement in Firejail, indeed!
gitea-mirror 2026-05-05 05:10:19 -06:00
Author
Owner

@netblue30 commented on GitHub (Jan 10, 2016):

I'll implement it, thanks for the idea!

<!-- gh-comment-id:170355667 --> @netblue30 commented on GitHub (Jan 10, 2016): I'll implement it, thanks for the idea!
Author
Owner

@curiosity-seeker commented on GitHub (Jan 10, 2016):

Great - thank you very much in advance!

BTW, it would be nice if one could add several file suffixes in one line if possible. Something like

whitelist ~/*.odt, *.doc, *.docx

or

whitelist ~/*.odt | *.doc | *.docx

just to keep the profile more readable.

<!-- gh-comment-id:170358696 --> @curiosity-seeker commented on GitHub (Jan 10, 2016): Great - thank you very much in advance! BTW, it would be nice if one could add several file suffixes in one line if possible. Something like whitelist ~/*.odt, *.doc, *.docx or whitelist ~/*.odt | *.doc | *.docx just to keep the profile more readable.
Author
Owner

@netblue30 commented on GitHub (Jan 10, 2016):

I'll try that one also.

<!-- gh-comment-id:170380119 --> @netblue30 commented on GitHub (Jan 10, 2016): I'll try that one also.
Author
Owner

@ghost commented on GitHub (Jan 31, 2016):

Maybe in Bash syntax:
whitelist ~/*.{odt,doc,docx}

<!-- gh-comment-id:177590438 --> @ghost commented on GitHub (Jan 31, 2016): Maybe in Bash syntax: whitelist ~/*.{odt,doc,docx}
Author
Owner

@netblue30 commented on GitHub (Mar 6, 2016):

several similar requests to follow:

<!-- gh-comment-id:192943598 --> @netblue30 commented on GitHub (Mar 6, 2016): several similar requests to follow:
Author
Owner

@netblue30 commented on GitHub (May 2, 2016):

Also allow {}

<!-- gh-comment-id:216234953 --> @netblue30 commented on GitHub (May 2, 2016): Also allow [](){}
Author
Owner

@vn971 commented on GitHub (May 13, 2016):

And []

<!-- gh-comment-id:219016975 --> @vn971 commented on GitHub (May 13, 2016): And `[]`
Author
Owner

@msva commented on GitHub (Mar 5, 2017):

Any updates on this?

<!-- gh-comment-id:284267255 --> @msva commented on GitHub (Mar 5, 2017): Any updates on this?
Author
Owner

@june128 commented on GitHub (Oct 15, 2019):

I'm currently working on enhancing the Thunderbird profile, so that Thunderbird can set itself as the default mail-program (and other things).
Thunderbird needs to modify the ~/.config/mimeapps.list-file for that. It does that by first creating a file named ~/.config/mimeapps.list.randomBit (where randomBit are 6 random characters [a-zA-Z0-9]) and then renaming this temporary file to ~/.config/mimeapps.list to make the change.

For that enhancement to be done, whitelist globbing would be needed (I think).

<!-- gh-comment-id:542448597 --> @june128 commented on GitHub (Oct 15, 2019): I'm currently working on enhancing the Thunderbird profile, so that Thunderbird can set itself as the default mail-program (and other things). Thunderbird needs to modify the `~/.config/mimeapps.list`-file for that. It does that by first creating a file named `~/.config/mimeapps.list.randomBit` (where `randomBit` are 6 random characters `[a-zA-Z0-9]`) and then renaming this temporary file to `~/.config/mimeapps.list` to make the change. For that enhancement to be done, whitelist globbing would be needed (I think).
Author
Owner

@rusty-snake commented on GitHub (Oct 16, 2019):

@julianschacher #2874

EDIT:

whitelist globbing would be needed (I think)

To whitelist a file/dir it must be exists in the "normal" fs, thats why mkdir/mkfile is in the profiles.

<!-- gh-comment-id:542622100 --> @rusty-snake commented on GitHub (Oct 16, 2019): @julianschacher #2874 EDIT: > whitelist globbing would be needed (I think) To `whitelist` a file/dir it must be exists in the "normal" fs, thats why `mkdir`/`mkfile` is in the profiles.
Author
Owner

@june128 commented on GitHub (Oct 17, 2019):

@julianschacher #2874

@rusty-snake Thanks for the link! That's really an unfortunate issue.

<!-- gh-comment-id:542957234 --> @june128 commented on GitHub (Oct 17, 2019): > @julianschacher #2874 @rusty-snake Thanks for the link! That's really an unfortunate issue.
Author
Owner

@rusty-snake commented on GitHub (Apr 1, 2020):

601df2f

<!-- gh-comment-id:607310290 --> @rusty-snake commented on GitHub (Apr 1, 2020): 601df2f
Author
Owner

@danielkrajnik commented on GitHub (Dec 18, 2021):

thanks, is it possible to use it resursively, that is all *.mp4 files in a directory and its subdirectories?

<!-- gh-comment-id:997225403 --> @danielkrajnik commented on GitHub (Dec 18, 2021): thanks, is it possible to use it resursively, that is all *.mp4 files in a directory and its subdirectories?
Author
Owner

@rusty-snake commented on GitHub (Dec 19, 2021):

man 7 glob:

Globbing is applied on each of the components of a pathname separately. A '/' in a pathname cannot be matched by a '?' or '*' wildcard

<!-- gh-comment-id:997348629 --> @rusty-snake commented on GitHub (Dec 19, 2021): `man 7 glob`: > Globbing is applied on each of the components of a pathname separately. A '/' in a pathname cannot be matched by a '?' or '*' wildcard
Author
Owner

@danielkrajnik commented on GitHub (Dec 19, 2021):

I see, so glibc doesn't provide a way to do it? Is there no other way to whitelist all files of specific format (e.g. *.mp4) in all subdirectories?

<!-- gh-comment-id:997360365 --> @danielkrajnik commented on GitHub (Dec 19, 2021): I see, so glibc doesn't provide a way to do it? Is there no other way to whitelist all files of specific format (e.g. *.mp4) in all subdirectories?
Author
Owner

@rusty-snake commented on GitHub (Dec 19, 2021):

If the (sub)directory structure isn't to deep, you can

whitelist ${HOME}/Downloads/*.mp4
whitelist ${HOME}/Downloads/*/*.mp4
whitelist ${HOME}/Downloads/*/*/*.mp4
<!-- gh-comment-id:997361288 --> @rusty-snake commented on GitHub (Dec 19, 2021): If the (sub)directory structure isn't to deep, you can ``` whitelist ${HOME}/Downloads/*.mp4 whitelist ${HOME}/Downloads/*/*.mp4 whitelist ${HOME}/Downloads/*/*/*.mp4 ```
Author
Owner

@danielkrajnik commented on GitHub (Dec 19, 2021):

Thanks, it is quite deep unfortunately (network mount). Ideally there would be a way to whitelist only certain files in such large directories rather than all of it.

<!-- gh-comment-id:997361828 --> @danielkrajnik commented on GitHub (Dec 19, 2021): Thanks, it is quite deep unfortunately (network mount). Ideally there would be a way to whitelist only certain files in such large directories rather than all of it.
Author
Owner

@ghost commented on GitHub (Dec 19, 2021):

@danielkrajnik Maybe you could write a shell script from where you pre-select the (*.mp4) files you want to whitelist and bind mount them in a specific location. That way you can blacklist your network mount and only whitelist the new mount path. Have you tried that yet?

<!-- gh-comment-id:997367640 --> @ghost commented on GitHub (Dec 19, 2021): @danielkrajnik Maybe you could write a shell script from where you pre-select the (*.mp4) files you want to whitelist and bind mount them in a specific location. That way you can blacklist your network mount and only whitelist the new mount path. Have you tried that yet?
Author
Owner

@rusty-snake commented on GitHub (Dec 19, 2021):

You can use find+xargs:

find ~/Videos -type f -name "*.mp4" -printf "--whitelist=%p\0" | xargs -0 -x -s 65536 /bin/sh -c 'firejail "$@" /usr/bin/totem'

I'm not sure if you can perform injections with this command (spaces in filenames work), but if this is an untrusted network mount, you should check this.

<!-- gh-comment-id:997368001 --> @rusty-snake commented on GitHub (Dec 19, 2021): You can use find+xargs: ```bash find ~/Videos -type f -name "*.mp4" -printf "--whitelist=%p\0" | xargs -0 -x -s 65536 /bin/sh -c 'firejail "$@" /usr/bin/totem' ``` _I'm not sure if you can perform injections with this command (spaces in filenames work), but if this is an untrusted network mount, you should check this._
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#149
No description provided.