05nelsonm / kmp-tor

Kotlin Multiplatform Library for embedding Tor into your applications
Apache License 2.0
33 stars 5 forks source link

Fix Jvm directory permission setting #443

Closed 05nelsonm closed 1 month ago

05nelsonm commented 1 month ago

When TorDaemon goes to create all directories within the provided TorConfig, it sets permissions for them such that only the owner has access. The issue on Jvm is that the File API is trash such that you have to first change permissions so that noone has access, then set ownerOnly permissions. This results in a brief moment where directory permissions are inaccessible to the user only group which is not ideal. It also is non-atomic and are 6 separate filesystem calls.

The setDirectoryPermissions actual function for Jvm should try to use Path (if available), and try modifying permissions in 1 go, and then fallback to the File APIs as a last resort.