Page 1 of 1

Where to store an app's data file so it can be modified by all users

Posted: Wed Oct 19, 2022 4:46 pm
by Verymuch
Dear forum,

After some searching I've found two locations where an app can store a data file so other users can modify it:

Code: Select all

/Users/Shared/YourApp
and

Code: Select all

/Library/Application Support/YourApp
Which one of the two locations is the best place to use?

Thank you

Re: Where to store an app's data file so it can be modified by all users

Posted: Wed Oct 19, 2022 4:54 pm
by Klaus
Why not just use -> specialfolderpath("documents") (in a subfolder)?
The average user does not want to mess with/in any Library folder!

Re: Where to store an app's data file so it can be modified by all users

Posted: Wed Oct 19, 2022 5:12 pm
by Verymuch
Klaus wrote:
Wed Oct 19, 2022 4:54 pm
Why not just use -> specialfolderpath("documents") (in a subfolder)?
The average user does not want to mess with/in any Library folder!
specialfolderpath("documents") yields a location writable only by the current user.
I would like the data file to be stored where the app can modify the same file when another Mac user is logged in.

Re: Where to store an app's data file so it can be modified by all users

Posted: Wed Oct 19, 2022 5:16 pm
by FourthWorld
/Users/Shared is recommended by Apple Support.
https://support.apple.com/guide/mac-hel ... lp1122/mac

/Library/Application Support requires admin privileges; attempting to write to it without elevating privileges will result in an error 13 ("Permission denied").

Re: Where to store an app's data file so it can be modified by all users

Posted: Wed Oct 19, 2022 5:18 pm
by Klaus
Oops. sorry, overlooked that.
Well then "/Users/Shared/YourApp" should do.

Re: Where to store an app's data file so it can be modified by all users

Posted: Wed Oct 19, 2022 5:25 pm
by Verymuch
Thank you. I'll put my file in
/Users/Shared/MyApp
and then i'll use

Code: Select all

shell "chmod o=wrx /Users/Shared/MyApp/Myfile"
to give the other users write access.

Re: Where to store an app's data file so it can be modified by all users

Posted: Wed Oct 19, 2022 5:39 pm
by FourthWorld
I don't know that it would make much difference in your setup, but I'd be inclined to use "a=" ("all") rather than "o=" ("others").

Also, if the file isn't an executable program I'd leave off "x". Also not likely critical, but the earlier we adopt habits of granting least privilege the better the systems we will deploy over the years ahead.

Re: Where to store an app's data file so it can be modified by all users

Posted: Wed Oct 19, 2022 5:45 pm
by Verymuch
Thank you Richard for the sound advice. It's much appreciated.