• 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
NSFileManager destroying target of symlink at changefileattributes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSFileManager destroying target of symlink at changefileattributes


  • Subject: NSFileManager destroying target of symlink at changefileattributes
  • From: thomas bauer <email@hidden>
  • Date: Sun, 18 Nov 2007 20:39:29 +0100

dear list,

following code is executed as root in a test foundation tool.
it simply copies the localtime symlink (/etc/localtime) to another partition and then tries to clone
its fileattributes. if a copy of the source fileattributes dictionary is used
instead of the original one, the changefileattributes call damages the target
of the symlink replacing it with a broken symlink.


(ie /usr/share/zoneinfo/yourzone will be damaged, destroying your timezone setting.
make a copy before testing this!)


if the original dict is used, everything is fine.
i nslogged both dicts and both are identical.

(only in this example code i use a trivial copy of the attributes dict. the original code has to use
a mutable copy to alter the permission flags between source and target. since this modification
is not related to the issue i have altered the testcode to just use a trivial copy)


thanks and regards
thomas bauer - freeridecoding


#import <Foundation/Foundation.h>

int main (int argc, const char * argv[]) {
   NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

NSFileManager *fm = [NSFileManager defaultManager];
[fm copyPath:@"/private/etc/localtime" toPath:@"/Volumes/tigerclone/ localtime" handler:nil];


NSDictionary *sourceAttributes = [fm fileAttributesAtPath:@"/private/ etc/localtime" traverseLink:NO];
NSDictionary *copyattrs= [NSDictionary dictionaryWithDictionary:sourceAttributes];

// [fm changeFileAttributes:copyattrs atPath:@"/Volumes/tigerclone/ localtime"]; // THIS BREAKS TARGET OF SOURCE SYMLINK
[fm changeFileAttributes:sourceAttributes atPath:@"/Volumes/ tigerclone/localtime"]; //THIS IS OK


	[pool release];
   return 0;
}

d
_______________________________________________

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: NSFileManager destroying target of symlink at changefileattributes
      • From: thomas bauer <email@hidden>
  • Prev by Date: Re: Accessing C++ class method from ObjC++ code
  • Next by Date: Notification when new email received
  • Previous by thread: Re: Accessing C++ class method from ObjC++ code
  • Next by thread: Re: NSFileManager destroying target of symlink at changefileattributes
  • Index(es):
    • Date
    • Thread