We are still actively working on the spam issue.

Firejail

From InstallGentoo Wiki
Revision as of 23:10, 23 December 2016 by Galactus (talk | contribs) (PulseAudio: - fixes partially incorrect information)
Jump to: navigation, search
Firejail Logo

Firejail is a Linux-only sandbox that uses Linux namespaces, seccomp-bpf and all the latest Linux security features to create a new, fully secure filesystem. It allows a process and all its descendants to have their own private view of the globally shared kernel resources, such as the network stack, process table, mount table. It comes with a myriad of profiles by default, which are then used on a per-software basis.

Installation

Installation varies among different GNU/Linux distributions, and it might be as easy as installing it as a package from an official repo. Check your distros repos first.

Debian

Debian's Firejail installation process requires you to add a backports repository if you're using stable (jessie). Simply add the backports line to your sources.list in /etc/apt, update your repositories and install firejail using the -t jessie-backports option.

  • $ sudo apt-get -t jessie-backports install firejail

Usage

Using firejail is pretty simple, just open a terminal and enter $ firejail <program name>. Alternatively, edit the exec field in the *.desktop files in /usr/share/applications so it doesn't take input space.

Example:

  • Firejailing Firefox: $ firejail firefox

Ideally, you might want to use --name= to name it, should you want to join that sandbox later on with --join=. This is particularly useful for opening new windows on firefox, since one instance is used to manage multiple windows.

Whitelisting directories

By default firejail gives each firejailed program it's own view of the filesystem, so you may need to whitelist directories in some programs to access your files (whitelisting your pictures directory for your web browser to post chinese cartoons on imageboards, for example).

To whitelist a directory for a program, edit the programs respective profile in ~/.config/firejail. For instance, to whitelist your documents directory in firefox, you'd copy your firefox.profile file to ~/.config/firejail/firefox.profile and add the line whitelist ~/Documents. These rules are user-wide, but firejail will read ~/ as the users own home directory, so don't worry about cross contamination. Permissions in whitelisted directories are the same as their filesystem permissions, so if you make a file read-only in a whitelisted directory, programs with that directory whitelist will respect that permission and will only be able to read the file.

Notes

Chromium

Sometimes if you exit out of Chromium, it will keep running in the background. You will notice this in your firejail terminal. Press Control-C and Chromium is killed and the firejail ended (this is true for all firejailed programs/processes).

In order to fully fix this, simply go to Chromium's settings page and uncheck "Continue running background apps when Google Chrome is closed".

group and passwd

While a firejail is running, firejail will lock your /etc/group and /etc/passwd files, making it so no program can access or write data to them (even root). This is a security feature and not a bug. If your group or passwd files don't work correctly (groupadd error code 10), close all firejails then try again.

PulseAudio

Firejail profiles with --private-dev will mount a tmpfs directory on top of /dev/shm and, due to unresolved PA bug delete PulseAudio's shm files, causing audio to stop working in the process.

Adding enable-memfd = yes to daemon.conf mitigates this, and will be the default value come PulseAudio 10.0.

See also