Ensure folder can be read/written to by current user, even if program is admin
I want to ensure that a folder I create is fully accessible by the current user.
I'm afraid that if the user runs my program as admin, the folder and its files will be created as the root user, and they will become inaccessible to other programs that are not running as admin/sudo.
How can I make sure they can access it?
6 Replies
windows?
on windows by default theyre accessible if the folder theyre in is accessible by the user
on other OSes i have no idea
problem is linux
ah
half the time the directory I need to access is already sudo restricted, so I recommend to everyone to run the app as sudo, but then other apps can't access it anymore ¯\_(ツ)_/¯
it's a mess
oof
I think you can access folders in like general porpuse directories (similar to stuff like appdata and such) but some are restricted to their users home path
The safest way is to use relative path at working directory
This not only allows the user to configure a working dir (when setting up a service file for auto start for example) but it also "ensures" the program can always access a folder (unless the owner of the machine messes up so badly to the point not even the user has access to their own dir)