1

I have a windows application getting ported for Mac.In windows i store encrypted data in the registry.But when it comes to Mac im unfamiliar.

The application is licensed per PC.So all Users using the Machine will be able to use it.So in windows im storing the key in HKEY\LOCAL MACHINE

How does user access rights work in Mac? Where do i need to store the data?

techno
  • 6,100
  • 16
  • 86
  • 192

1 Answers1

2

This type of data is usually stored in a file in Application Support directory. If you want to store one file for all users you should choose /Library/Application Support system directory.

The directory is not user-writable, so you will have to run installer with root privileges. This directory can't be used by sandboxed apps.

You should create a subfolder in this directory and store your file inside.

For more information see The Mac Application Environment, especially Table 1-1, "Key directories for Mac apps", and File System Basics.

Edit:

Usually OS X apps don't need any installation. They are self-contained bundles that can be run from any location. Usually you keep them in Applications folder (drag it there). System wide /Applications folder is accessible for all users. There is also private ~/Applications folder in each user's home.

On the other hand apps that need to install data to system folders use installers. Installer usually copies application bundle to /Applications folder, but also handles authentication and asks user for admin credentials. Installers may also run scripts.

Maybe your license could be generated by a script during installation? If not, you would have to generate license file on first application run. In such case, if you want to keep one file for all users in /Library/Application Support, you will have to escalate privileges and ask user for admin access. If you don't want to do that, consider storing separate license file for each user in their home ~/Library/Application Support folder.

baf
  • 4,531
  • 1
  • 21
  • 24
  • Thanks.I have few more questions related to this.In Mac when a user installs a program(By drag and drop) the program is installed only for that particular user,right? How are Mac Applications commonly installed ? Does they come with an installer normally?if yes,does the installer automatically have root privileges. I dont want installer to write to "/Library/Application Support" my application needs to write to this folder. – techno Mar 25 '15 at 09:51
  • Thanks.You say that the Applications folder is accessible system wide..So can i put the license data within my application folder without root privilages? – techno Mar 25 '15 at 17:32
  • System Applications folder is not writeable for non-admin users. Also it is not recommended to create folders there (though some applications do). It is also bad idea to store files inside your [app bundle](https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/BundleTypes/BundleTypes.html), as it may be replaced by user during upgrade. – baf Mar 25 '15 at 19:02
  • I think you should create installer package which will install your app bundle in `/Applications` folder and run a script which will prepare `/Library/Application Support/YOURAPP` folder writable by everyone (installer will run with admin privileges). Your application will then be able to store license file there on the first run without need for admin rights. – baf Mar 25 '15 at 19:50
  • Thanks i will check it in detail after testing is complete. – techno Mar 29 '15 at 09:02
  • I have completed testing around 70%.In your previous comment you asked me to create a directory /Library/Application Support/YOURAPP writable by everyone.If i create a directory using the script can my app write to it without any admin rights? How can i create such a script can you guide me please. – techno Jun 07 '15 at 08:51
  • I implemented a solution to create and access a application specific folder in "/Library/Application Support". See my answer here: https://stackoverflow.com/questions/33162116/permission-to-access-library-application-support-from-mac-app-bundle/74287803#74287803 – RED SOFT ADAIR Nov 03 '22 at 09:55