mirror of
https://github.com/netblue30/firejail.git
synced 2026-05-15 14:16:14 -06:00
[GH-ISSUE #40] Support files in current directory and paths with private.keep #20
Labels
No labels
LTS merge
LTS merge
bug
bug
converted-to-discussion
doc-todo
documentation
duplicate
enhancement
file-transfer
firecfg
firejail-in-firejail
firetools
graphics
help wanted
information_old
installation
invalid
modif
moved
needinfo
networking
notabug
notourbug
old-version
overlayfs
packaging
profile-request
pull-request
question
question_old
removal
runtime-permissions
sandbox-ipc
security
stale
wiki
wiki
wontfix
wordpress
workaround
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/firejail#20
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @pigmonkey on GitHub (Aug 22, 2015).
Original GitHub issue: https://github.com/netblue30/firejail/issues/40
I want to use firejail and
--private.keepto view a PDF file within a sandbox. If my PDF reader ispdfreaderand the file is in~/, this works great:However, this fails when the file is somewhere other than
~/I would like
--private.keepto accept files in the current directory, as well as paths. For instance, in addition to the previous example I'd like to be able to do stuff like:I understand that
--private.keepwas probably originally intended just to copy over dotfiles from the real home, but I think expanding it to support file paths like this would make it much more useful.@netblue30 commented on GitHub (Aug 22, 2015):
private.keep is being renamed to --private-home in the next version. It makes "private" only files in home directory. I have a --private-etc doing the same for /etc directory. I'll implement a --private-tmp, it shouldn't be a big deal.
Some users came up with the idea to have only .mozilla directory visible. I guessthe main usage so far is "firejail --private-home=.mozilla firefox"
What is pdfreader? I could build a default profile for it. Also, use --net=none with pdf readers - the bad guys are interested in sending data back.
@ghost commented on GitHub (Aug 22, 2015):
@netblue30 The
tmpdirectory in his example is relative to the home directory, i.e. it's/home/user/tmp/random...- it tripped me up at first! Currently the--private-homecode doesn't expand the~or${HOME}at the front, and just appends it tohomedir. So~/tmpin his example expands to/home/user/~/tmpwhich doesn't work.I've already been thinking of making a function called something like
expand_user_supplied_pathas there's several places where we expand~and${HOME}using the same code. We could call that from the--private-homecode and then check that the result starts with whatever's in thehomedirvariable. That would also take care of callingrealpathand expanding out any paths like../diras well. Would you like me to put up a pull request for it?@netblue30 commented on GitHub (Aug 22, 2015):
yes, thanks!
@pigmonkey commented on GitHub (Aug 22, 2015):
Yeah, that tmp directory was in my home dir. Sorry if that was confusing. To give another example, I want to be able to do all of the following:
The first example already works. The second example will work with
expand_home. The third example is the one I care about most. I haven't actually ran into a situation where I wanted to use the fourth example, but I would expect it to work.@ghost commented on GitHub (Aug 22, 2015):
The issue with the third example is the meaning of the parameters. For example, if you have the following two files:
/home/user/notes.txt/home/user/dir/notes.txt...if you say
firejail --private-home=notes.txtthe meaning is to take/home/user/notes.txt, no matter what directory you run firejail from. That way you can sayfirejail --private-home=.mozilla firefoxand it works correctly all the time.It is possible to change the meaning of the
--private-homeoption to reference against the current directory instead of the home directory, but that would break existing scripts. @netblue30 would have to be the one to make that decision.@pigmonkey commented on GitHub (Aug 22, 2015):
Good point.
With
--private.keepbeing renamed to--private-homein the next release, this is probably as good a time as any to break stuff! The newexpand_homeshould make it easy for users to fix any existing scripts by just dropping a~/in front of the path.My goal with all of this is to be able to jail a PDF reader (or other application) without thinking about it. Currently, if I want to read
~/documents/file.pdfin a jail and I am already in~/documents, I need to do this:What I want to do is create a bash script -- called
pdfjailor something -- that looks like this:With that script, I could accomplish the same thing in the previous example by just doing this:
But for it to work, I need
--private-hometo accept any path that the PDF reader does.I think the ability to do something like this would be super useful for a number of different applications. The PDF reader example is just my immediate need.
@netblue30 commented on GitHub (Aug 23, 2015):
If you are using a script, you can expand the path of the file in your script using "readlink -f", something like this:
@pigmonkey commented on GitHub (Aug 25, 2015):
That will address my immediate need if
--private-homewill accept an absolute path.@netblue30 commented on GitHub (Aug 25, 2015):
It does,as long as the file is in your home directory and you are the owner of the file.
@pigmonkey commented on GitHub (Aug 26, 2015):
Good enough!