I have seen these 2 articles that I have attached below that seem to offer some assistance. But is there a more modern way to share secured information between macOS users on same machine?
STEPS TO REPRODUCE
do
{
let baseDir = try fileMgr.url(for: .applicationSupportDirectory, in: .localDomainMask, appropriateFor: nil, create: true).appendingPathComponent("com.MyCompany.AppName", conformingTo: .directory)
try fileMgr.createDirectory(at: baseDir, withIntermediateDirectories: true, attributes: nil)
}
catch
{
Swift.print("ERROR: can't create baseDir \(baseDir)")
exit(0)
}
Sorry that I didn’t reply earlier. For annoying internal reasons, I wasn’t notified of your last post (r. 131905835)-:
You wrote:
the data should remain protected from external modification by users who are not using our application
There isn’t a 100% guaranteed way to do that. What you’re asking for is a DRM system: You want to give the user some data but restrict how they can use it. DRM systems are tricky, because they involve a three-way trade-off between effectiveness, compatibility, and coding effort.
DTS doesn’t support DRM development because of the compatibility concerns. The more effective a DRM system is, the more likely it is to run into compatibility problems.
However, there are reasonably effective approaches that are likely to be highly compatible. I gave an example of that in this post.
So, let’s break this down into two parts:
-
Where do you store the data?
-
How do you protect this data from the user?
There’s a clear answer to the first part: /Library/Application Support/NNN
, where NNN
is something unique to your company or product name.
There’s only one challenge with doing that, namely, if the first user who runs your app is a non-admin user, you can’t write to that location directly. There are a few ways you could handle that:
-
Tell them “No.” That is, require that they get an admin user to run the app for its initial setup.
-
Implement one of the privilege escalation techniques described in BSD Privilege Escalation on macOS.
-
Let the user run in ‘this user only’ mode and provide a way for an admin user to upgrade to ‘all users’ mode.
As to how you protect this data from the user, that’s the DRM issue I mentioned above and it’s not something I answer definitively. As I said, it’s a complicated trade-off, and you’re the only person with all the info required to make that trade-off. Specifically, you’re the only one who knows how much this data is ‘worth’.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"