Gentoo has a feature in portage, that prevents and logs writes outside of the build and packaging directories.
Checkinstall is able to monitor writes, and package up all the generated files after completion.
Autotools have the DESTDIR
macro that enables you to usually direct most of the filesystem activity to an alternate location.
- How can I do this myself with the safety of the Gentoo sandboxing method?
- Can I use SELinux, rlimit, or some other resource limiting API?
- What APIs are available do this from C, Python?
Update0
- The mechanism used will not require root privileges or any involved/persistent system modification. This rules out creating users and using
chroot()
. - Please link to the documentation for APIs that you mention, for some reason they're exceptionally difficult to find.
Update1
- This is to prevent accidents. I'm not worried about malicious code, only the poorly written variety.