Draft: libalpm: isolate install scriptlets in a private network namespace
Preface: tests are currently failing in CI but I wanted to gather feedback, and know if the feature could be accepted, before I try to debug this.
Given the recent flood of malicious edits to AUR packages I tought at what else could be done to avoid this in the future, besides working on AUR itself.
In my opinion install scriptlets do not need network access for their intended purpose. It represents an unnecessary attack surface and could have blocked the specific attack that has been used in the malicious edits on AUR.
Obviously I do not believe that this does magically make AUR safe, but this could still be an incremental improvement.
Now for the technical aspect of the MR:
The change adds an unshare call into the chroot created by _alpm_run_chroot.
Since not every chroot should disable network access, I had to add a new argument to the function and at the moment only _alpm_runscriptlet enables it. There's also the chroot for ldconfig that I think could use it but it should be mostly inconsequential.
Alpm hooks are unaffected.
I added syscall detection in meson and guarded the call with HAVE_UNSHARE. Not sure if it's really needed.
I also looked at how sandbox_fs worked and tought that the feature should probably have similar apis with alpm_option_{get,set}_disable_sandbox_network() and consequently be integrated into alpm_option_{get,set}_disable_sandbox(). I wasn't also sure if I needed to document the new API in this MR.