Linux bind mounts
Linux bind mounts
Posted Mar 19, 2025 13:58 UTC (Wed) by farnz (subscriber, #17727)In reply to: flatpacks falling flat, packing bugs, snaps snapping resources, both suck by andrejp
Parent article: Fedora discusses Flatpak priorities
You can bind-mount files as well as directories, under Linux, and have the bind mount reduce permissions as compared to the original pointer to the file. So if you genuinely need read access to /etc/hostname, you can bind-mount that into the sandbox as read only, getting you read access but not write.
That said, if reading /etc/hostname is something your program does often enough for performance of that read to matter, you've got bigger concerns than sandboxing - why are you rereading a value that rarely changes, instead of caching it after first read and invalidating the cache when you get told it's changed?
The LWN site is currently under high scraper load, so comment display has been suppressed for anonymous users. If you are a human, you may read the comments by clicking the button below:
Note: you can avoid this step in the future by logging into your LWN account.
