• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: user access privileges to plist in /library/preferences
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: user access privileges to plist in /library/preferences


  • Subject: Re: user access privileges to plist in /library/preferences
  • From: Greg Guerin <email@hidden>
  • Date: Wed, 1 Apr 2009 13:55:11 -0700

Memo Akten wrote:

Hi Greg, actually /Users/Shared didn't work either. If I am logged in as admin it works, but if I am logged in as a normal user it doesn't. My code is:

#define LOG_PATH_FOLDER @"/Users/Shared/Library/Preferences/"
#define LOG_FILENAME @"MyLog.plist"
#define LOG_PATH [LOG_PATH_FOLDER stringByAppendingPathComponent:LOG_FILENAME]


NSFileManager *fileManager = [NSFileManager defaultManager];
if([fileManager fileExistsAtPath: LOG_PATH_FOLDER] == NO) {
NSLog(@"creating folder %@", LOG_PATH_FOLDER);
[fileManager createDirectoryAtPath: LOG_PATH_FOLDER attributes: nil];

Do you understand the Posix permissions and ownership concepts, as applied to files and dirs? If not, you need to learn those.


Do you understand the Posix 'umask' concept and its default value? Again, you should learn that.

Finally, you will need to provide non-nil attributes to createDirectoryAtPath: that specifies all-read, all-write, and all- search permissions on the created dir. If you don't, then the directory will not be writable to anyone except its owner (the user account that creates it), due to how the default umask value affects the created dirs initial permissions.

Whenever you write the log-file, you may also need to specify all- write permissions. It may depend on how you write the file.

You might also consider having a user-specific LOG_FILENAME, constructed from the current user-ID. This means that users won't be overwriting one another's logs. It also means that a log-analyzer would have to coalesce multiple plist files, but that's not too difficult with NSDictionary.

  -- GG

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: user access privileges to plist in /library/preferences
      • From: Memo Akten <email@hidden>
  • Prev by Date: Re: Saving Address Book for more than 1000 recrods
  • Next by Date: Re: Bindings and MenuItems
  • Previous by thread: Re: user access privileges to plist in /library/preferences
  • Next by thread: Re: user access privileges to plist in /library/preferences
  • Index(es):
    • Date
    • Thread