So, unix really is lovely...
> mkdir -p /foo/bar
> cd /foo/bar
> chmod a-x /foo
> touch first
> touch /foo/bar/second
touch: cannot touch '/foo/bar/second': Permission denied
As written, this library has the same problem as the second case. We use the absolute path when creating temporary files instead of the relative path. I believe this can actually be an issue in practice with some jails.
Fixing this on linux is doable with openat and unlinkat. Fixing this on osx is possible using per-thread CWDs (at the cost of two extra syscalls to set/unset the thread-local CWD).