• 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: [Q] Unlocking an arbitrary file?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Q] Unlocking an arbitrary file?


  • Subject: Re: [Q] Unlocking an arbitrary file?
  • From: Chris Parker <email@hidden>
  • Date: Wed, 25 Sep 2002 09:47:08 -0700

Hi Ando,

On Tuesday, September 24, 2002, at 07:19 PM, Ando Sonenblick wrote:

Narrowing in on this method (of NSFileManager):

- (BOOL)changeFileAttributes:(NSDictionary *)attributes atPath:(NSString
*)path

I discover that:

(Problem 1) - 3Attributes that you can change are the owner, group, file
permissions, and modification date.2 It doesn9t look like I can change the
immutable attribute, which I9m presuming is the lock bit - documentation
wasn9t helpful - am I mistaken?

The changeFileAttributes:atPath: method documentation lists NSFileImmutable as a dictionary key, which is what will determine the "locked" nature of the file. You can pass this in as a key and you should see the locked state change accordingly.

Furthermore:

(Problem 2) - 3As in the POSIX standard, the application must either own the
file or directory or must be running as superuser for attribute changes to
take effect.2

Ack! Being still relatively new to Unix, I don9t know what (if?) I9ll need
to do to make my app run as superuser or otherwise have permission to tweak
a file9s attributes...

Hrm. That statement sounds overly broad - the locked bit that's being twiddled in this case is the "user immutable" bit which can be set and unset by the owner of the file, not the "system immutable" bit which can only be set by root, and only unset by mucking about with the machine's securelevel (or being in single-user mode).

So... Can anyone either inform me of a different approach to unlock any
file? Or provide insight on solving either of the two problems I9ve
encountered?

If the user running your application owns the files, then you're all set - NSFileManager's -changeFileAttributes:atPath: should do it. If not, you'll have to get privileges to execute a tool that will execute the same code, just as root. See the security documentation for more details (http://developer.apple.com/techpubs/macosx/CoreTechnologies/ securityservices/authorizationservices/authorization_concepts/ index.html is a good place to start).

.chris

--
Chris Parker
Cocoa Frameworks Engineer
Apple Computer, Inc.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >[Q] Unlocking an arbitrary file? (From: Ando Sonenblick <email@hidden>)

  • Prev by Date: pointer to window from NSDocController
  • Next by Date: Re: Making an object accessible by both MyDocument AND a custom class
  • Previous by thread: Re: [Q] Unlocking an arbitrary file?
  • Next by thread: Drawer larger than the window?
  • Index(es):
    • Date
    • Thread