Or is there some exception mechanism which allows any directory path that the user selected manually?
Or is there some exception mechanism which allows any directory path that the user selected manually?
unveil(2) requires upfront knowledge, hard-coded or via configuration file, or computed at initialization time before the final locking unveil call.
One model is using a privilege separation, various ways to do it, browsers might allow the main browser process access to the filesystem, defining an IPC mechanism (passing file descriptors) for restricted processes, like the renderer or content processes which are "sandboxed". They could use unveil(2) to lock down direct access to the filesystem, except to maybe read access to browser config, temporary directories.
Another is having an out-of-process "filepicker" UI.
See: architecture of acme-client(1): https://kristaps.bsd.lv/acme-client/