Okay, seems like sandbox-1.2.14 was released without applying FreeBSD fixes, so I’ve tried completing the port using gnulib. After a lot of work and a 50K patch, it does not work yet. The problem is that the replacement getcwd() provided by it… uses once again opendir(), that re-start the complete loop.
Now I’m going to try with a different strategy: I’ll import the getcwd from FreeBSD’s libc into sandbox (being BSD licensed it’s not a problem) and then try to use it, after changing the opendir call to true_opendir.
Wish me luck!