Improving Firefox's file dialog on OpenBSD
This post shares how I have optimized the Firefox file dialog that is common for both file uploads and downloads on OpenBSD.
Background
For those unfamiliar, OpenBSD secures Firefox (and Chromium) through its unveil(2) feature and as a result each type of Firefox process is limited to being able to access a select number of files and directories.
For the everyday user this means both ~/Downloads
and
/tmp
are available for file downloads and uploads by
default, and the rest of the filesystem remains off limits.
The files referenced by /etc/firefox/unveil.*
provide a
complete list of the files and directories available to each Firefox
process, and these same set of files can be edited to further restrict or
expand filesystem access.
Overall this is great and one of the reasons I choose to use OpenBSD on the desktop, but because the file dialog used for both file uploads and downloads is limited to a select few locations it can be frustrating to use without some additional configuration.
Bookmarks
Thankfully the file dialog can be improved by pinning file locations
we know unveil(2) allows access to. This can be done by editing the
bookmarks
file used by GTK file dialogs to show pinned file
locations. It can be found at
${HOME}/.config/gtk-3.0/bookmarks
.
The following is a copy of my bookmarks
file, the first
location is the user's downloads directory that's made available by
default, and the second location is a custom directory that was manually
added to /etc/firefox/unveil.{main,content}
by myself.
Also keep in mind that the _firefox
user runs Firefox on
my system, and that might not be the case on your system:
$ cat /home/_firefox/.config/gtk-3.0/bookmarks
/home/_firefox/Downloads Downloads
/mnt/browser-extensions Extensions
Conclusion
With the bookmarks file in place, the file dialog now shows both
Downloads
and Extensions
as pinned file
locations that are easy to navigate to (see the attached screenshot).
With this small change we can solve a minor frustration with the default
behavior, where often there was no straight forward way to navigate to a
desired file location.