-
Notifications
You must be signed in to change notification settings - Fork 570
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to configure applications to automatically go through firejail? #3191
Comments
Create a symbolic link: You may also want to take a look at |
How does it get firefox to run through firejail if I launched it through KDE? I just want to understand this better. |
It works because on your system |
Programs implement default application associations in different ways. While command-line programs traditionally use environment variables, graphical applications - or GUI apps - tend to use the XDG MIME Applications specification. This is a common Linux standard (a convention) using .desktop files in If you take a look inside, you'll notice an 'Exec=blahblah' line, e.g. 'Exec=firefox %U', which in human-speak means "start Firefox by executing the command 'firefox', and append whatever text string follows" - a URL in this context. Easy peasy, let's hit it already - I hear you think. But wait, there's a problem to be solved first. What happens when there are several commands on the system called 'firefox'? Where exactly can we find all these, and decide which one to actually execute? Machines can figure this all out and solve the problem by - you guessed it - relying on another (set of) standard convention(s). The relevant one in this context being
Like hordes of hungry beasts, machines start scanning through this collection of predefined locations, eagerly looking for something to execute. No matter how fast (or slow) this happens, this process seems to follow the same 'internal logic': let's not waste too much resources here and always execute the command from whatever location we find first so we can move on and take a rest already. Scanning stops, beasts happily tiptoe off to greener, shadier pastures and, whammo, a new thingie appears that looks like we can actually use it to surf that WWW everybody is on about! In the grand order of things, hopefully |
I see, so like since firejail knows that the link is named as Through firetools I configured firefox to not have access to the Desktop's files and it does work fine when I launch firefox either by firejail or firetools. However after adding the symblink in the specified directory, when I launch firefox through KDE's start menu, I can still access the Desktop's files. Is there a way to fix this? |
Correct.
It might be a conflict between firetools and firecfg if you previously also tried that, not 100% sure. I'd recommend sticking to one of the GUI tools to avoid clashes. Just try using your favorite GUI tool to undo all changes you've made so far and start afresh. That can also be achieved thru a file manager or in a terminal (so CLI). Be careful not to remove something from ~/.local/share/applications that you put there yourself (and isn't related to firejail). Making a quick local backup of that path is always a good idea. It will enable you to experiment with firejail and related GUI tools without having to worry about making unrecoverable changes to your system. Please contact us here again if fixing this doesn't work as expected. |
I haven't used firecfg. I only used firetools to change firefox's permission.
Is there something alternative to firetools?
What am I supposed to remove though to start fresh? |
In that case the problem with firefox must be something else. If you could post details here about your firejail and firetools version, files created by firetools in ~/.config/firejail/ to customize firefox and the content of ~/.local/share/applications/firefox.desktop we can determine what is going wrong. Let's not remove anything yet. We can tackle that later. |
Hmm strange, surprisingly when I typed Also in |
Ah, yes do post that
No I think it simple means firetools isn't using that directory to locally override /usr/share/applications. |
@glitsj16 Under the
After executing
Oh I see. So is there something I can do to fix this problem that I am having? |
Did some more research on firetools. Apparently it uses |
Ok so under
So what does this mean? |
Looks like window size dimensions. Nothing profile related at least. Is that the only file in that dir? |
Ok so I typed
Why does it say |
That's directory information. In the manual page of the 'ls' command (man ls) you can find detailed explanations. But again, nothing helpful to fix your issue. Let me suggest something. For now, close the firetools GUI and disable it from autostarting. We will temporarily use the firecfg command to create the necessary files and I'll explain how you can get the same settings for firefox to not show specific files you want to keep out of the sandbox in a minute. Using firecfg will ensure your applications are getting sandboxed, no matter how/which desktop environment you decide to use. It's the firejail native tool to do so. Up for it? |
How do I disable it from autostarting?
Thanks mate I am up for it. I will just run Should I remove |
To disable firetools from autostarting when you boot your machine you should have 2 options. Either find a setting in the GUI itself to do so. Or open ~/.config/autostart/firetools.desktop and show the content here. |
This file doesn't appear to exist Should I remove |
OK. Proceed with running the commands below. $ sudo firecfg --clean Next, set up symlinks and desktop files $ sudo firecfg |
Ok done that, now what do I do now? |
$ firecfg --list |
This is the output I got when I ran |
The error you see is AppArmor related. What kernel is your EndeavourOS using? Type 'uname -r' to find out. |
Does firejail use apparmor? This is the output I get after running |
OK, the stock arch linux kernel, which is fine. |
I ran it
|
To test if AppArmor has been correctly enabled: $ aa-enabled |
After running it |
What is your $PATH? $ echo $PATH Let's unclutter that file a bit to make it easier to read. Replace the content with the below.
|
So you want me to |
PATH looks fine, stock Arch output.
Correct. Other than readability I took out the '# converted by firecfg' line and changed the 'Exec=...' lines. The former should protect the file from being overwritten by future 'sudo firecfg' runs. We have some issues reported on that not working well for certain applications. The latter means taking manual control to ensure your Firefox will always run sandboxed now. At least that's what it should do once you make the edits in nano. So proceed with the edits and test your Firefox browser start routines again, double-checking with the 'firejail --tree' command to confirm it is actually sandboxed now. Don't worry about changing the content. If this doesn't fix your firefox you can always remove that file and regenerate it by running 'sudo firecfg' again. Apologies for editing/updating my comments here. It could help others that look thru the issues here in the future. |
Oh ok nice.
Do I have to do this to replace all the What does the
One error, for some weird reason I can make changes using Additionally I did change the write permissions and allowed the file to be written by any user and the same issue still persists. The reason why I am not using |
Sorry I have to go for now I will be available in around 10 hours time. Thanks for all your help :) |
I'll add a comment explaining a few things regarding your prior comment and what to do next etcetera. We can pick this up again later. Glad to help. |
No. In fact it shouldn't be needed at all. But due to some firecfg issues (see e.g. #3179) that are still not fixed or in-progress you currently need this workaround. If you notice any other of your installed applications not getting sandboxed properly (via 'firejail --tree') this routine is a way to take manual control and (try to) fix things.
Like @smitsohu and myself explained in the beginning of this thread, the
The 'weird' reason here is actually firejail itself :) In the list you posted in #3191 (comment) you can see 'kate created'. That means that your 'kate' editor is now being run through firejail (as are all the applications listed in that output).
Changing file permissions (outside the sandbox on your real filesystem) won't help here. The 'problem' is that the default /etc/firejail/kate.profile contains 'include disable-common.inc', which in turn has This is all 'standard' firejail behaviour: restrict a profile as much as possible while keeping it reasonably functional for the user. You will have to get used to being in control, believe it or not :). It is you - as the firejail user - that has to decide if/when/how to make changes to these defaults as specified in the profiles under /etc/firejail. Not that firejail is trying to shift blame or responsibility for something not working as expected into your shoes, or anything of the sort. Quite the contrary IMHO. Purposely designing things this way forces users to being more aware of how their specific setup uses the firejail sandboxing techniques and not lull them into a false 'install and forget' kind of security disaster. After all, firejail is just another set of tools. Luckily it tries to be (self-)aware of this and provides a convention to use overrides via If you decide to keep using 'kate' firejailed and want to allow it saving files under ~/.local/share/applications you have 2 options. Either create
To be honest I don't know that OTOH. Manual pages and internet searches to the rescue... |
To conclude our session for today, here are 2 reminders.
Enjoy experimenting! |
Hopefully it gets fixed soon.
Oh sorry I should have read it again.
Oh I get it lol.
I understand, I just didn't realise Is there a way to use |
No, in its current design firecfg doesn't allow that functionality. More granular control has been requested before, see #3016. I remembered showing a custom script in that issue, which still works fine, but depends heavily on your workflow. Maybe using https://github.com/rahiel/firectl instead of firecfg is the way to go for you in that case. |
I did a I installed I ran
through firejail chromium is being sandboxed which is good but not through I am not too sure why chromium is not working? |
Can you post the current content of /usr/share/applications/chromium.desktop please? As I understand it, I've started work on a On a similar note, if your list of applications you always want to be firejailed isn't too long, I suggest you drop tools like firectl/firecfg completely and setup symlinks (in /usr/local/bin) and edited .desktop files (in ~/.local/share/applications) yourself manually. In the end that looks to be the more manageable solution to all this IMHO. And even when the list is long(er), doing the work manually and keeping a file with info of what you always run through firejail isn't that complicated. It's what I've been doing ever since starting to use firejail for what that's worth... |
I started a firecfg.py, maybe we should collaborate to avoid duplicated work. |
Sure mate.
Where could all the *.desktop files be located? I am having issues with chromium. After running
Oh nice I hope it works out :)
I could try that but what do I put inside the *.desktop file?
I wish I could help you out but I have basic programming skills, unless if this is easy to code? |
Working way to fix .desktop files: https://gist.github.com/rusty-snake/3e4b8f8555e942d2964a181d4a5f64a0#file-firecfg-py |
@rusty-snake Yeah, I saw your nice Python script, works fine on a test sample for me. And I would definately like to collaborate on this firecfg mess. Give me a day to do some more extensive testing and I'll keep everybody informed on firecfg-ng in #2624 . For now it is just a simple
Allthough I really like your script, IMHO doing it in Python might hinder acceptance due to dependency decisions or keep it in contrib forever, both of which wouldn't serve the main goal here: to unbreak firecfg for regular users. Obviously the best solution would be to fix the |
Under ~/.local/share/applications.
The /usr/share/applications/chromium.desktop file looks fine to me. It has all the necessary 'Exec=' lines pointing to 'firejail /usr/bin/chromium', which is the way firectl works. I don't know why your chromium is still being sandboxed after disabling it in firectl. Unless there's still a ~/.local/share/applications/chromium.desktop on your system. If it is, take it out, together with any lingering firejail symlinks in /usr/local/bin. You can always use @rusty-snake's script too as he suggested. I didn't want to confuse your situation even more by adding another alternative to using firecfg and firectl :). |
@glitsj16 as a very first preview: https://github.com/rusty-snake/firecfg.py/tree/6f210201c5f4eec35c8e0ddd6c9c10e7e680e831
My goal about dependencies is to only require python3.6 (or what ever python version it will end). No pip, no other third-party python packages, the standart librarys are big enough. Reasons for the python decision
or as own project forever ;) |
@rusty-snake Thanks for the link and clarifying your reasons to go with Python. I wouldn't mind such a dependency being added to firejail, we have other Pythons in contrib. But I'm not a package manager :). It was a long day for me and I need a break. I'll keep you informed on the firefox-ng script, should be able to put something out during the weekend. |
Sure mate, but is @rusty-snake's script stable? Or is it still in testing phase? |
@rusty-snake Just out of curiosity, if you used Rust instead of Python, would it run faster the script that you are writing? |
Stable: https://gist.github.com/rusty-snake/3e4b8f8555e942d2964a181d4a5f64a0
Prieview (do not use): https://github.com/rusty-snake/firecfg.py/tree/0.0.0-preview
Sure. However, there are more python developers in the world (and in the firejail community) and my intention was no one man show. The python version runs in under one second and firecfg is usually only executed after installing/removing software. |
But
This is the next updated version of |
Yes, that's only an alternative for
Nope, currently this is just a personal project from me. Maybe it will replace firecfg in the future if wished or is shipped with the C-firecfg / in contrib. |
Oh ok so everytime I want to contain a program I have to run
Is this ready to use by any chance? If so I just have to build it and it will work, right? |
If you install/remove software with a firejail profile you should run
Give it some time ;) |
I'm closing here due to inactivity, please fell free to reopen if you have more questions. |
For some weird reason I didn't get your notification or something, sorry I forgot to respond to it if I did :) |
I wanted to know how do I configure certain applications to go through firejail, even through the launcher, for example if on KDE, if I click on
firefox
, I want it to open through firejail, how do I configure this?The text was updated successfully, but these errors were encountered: