Authorization and removing folders
Hi all, I need to remove a folder from within /Applications/OurCompany, so I'm using Authorization Services to get Admin rights, and then using removeFileAtPath to remove the folder. When I'm logged on as admin, this works perfectly fine. When I'm logged in as a standard user, I authenticate with the admin username and password, authorization is granted ok, but then it still can't delete the folder. Can anybody suggest what I might be missing here? Perhaps I have mis-understood the Apple security documentation? Here is my code in case that may shed any light on this (strFolderPath is declared earlier in the code) // create the authorization reference... AuthorizationRef myAuthorizationRef; OSStatus myStatus; myStatus = AuthorizationCreate (NULL, kAuthorizationEmptyEnvironment, kAuthorizationFlagDefaults, myAuthorizationRef); AuthorizationItem myItems[1]; AuthorizationRights myRights; myRights.items = myItems; AuthorizationFlags myFlags = kAuthorizationFlagDefaults | kAuthorizationFlagInteractionAllowed | kAuthorizationFlagExtendRights; myItems[0].name = com.Test.myRight1; myItems[0].valueLength = 0; myItems[0].value = NULL; myItems[0].flags = 0; myRights.count = 1; if (AuthorizationCopyRights (myAuthorizationRef, myRights, kAuthorizationEmptyEnvironment, myFlags, NULL) == errAuthorizationSuccess) { panel = NSRunAlertPanel (@Test, @Got Authorization!, @OK, nil, nil); if ([NSFm removeFileAtPath: (NSString *) strFolderPath handler: nil] == NO) { panel = NSRunAlertPanel (@Test, @Folder NOT removed, @OK, nil, nil); } else { panel = NSRunAlertPanel (@Test, @Folder removed, @OK, nil, nil); } } else { panel = NSRunAlertPanel (@Test, @Not Got Authorization!, @OK, nil, nil); } Promethean Limited is a company registered in England and Wales with company number 1308938 and VAT number GB 572 2599 18 __ Promethean Ltd and or associated and or subsidiary companies : The views expressed in this communication may not necessarily be the views held by Promethean Ltd and or associated and or subsidiary companies. This e-mail is for the exclusive use of the addressee(s). Unauthorised disclosure, copying or distribution is prohibited. This e-mail message has been swept for the presence of computer viruses. Promethean Ltd and or associated and or subsidiary companies accepts no liability for any loss resulting from this email transmission. Promethean, Promethean House, Lower Philips Road, Blackburn, Lancashire, BB1 5TH, UK. Please update your records accordingly. Thank you! * This email has been checked by the e-Sweeper Service * ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Finding files before app loads
Hi there, I need to locate certain files and set the state of some objects in my nib accordingly before the app is visible to the user. I'm using fileExistsAtPath to look for the files when the awakeFromNib method is invoked. The files are definitely present, but fileExistsAtPath always returns false on each search - please could someone advise where I might be going wrong? Kind Regards Dave Promethean Limited is a company registered in England and Wales with company number 1308938 and VAT number GB 572 2599 18 __ Promethean Ltd and or associated and or subsidiary companies : The views expressed in this communication may not necessarily be the views held by Promethean Ltd and or associated and or subsidiary companies. This e-mail is for the exclusive use of the addressee(s). Unauthorised disclosure, copying or distribution is prohibited. This e-mail message has been swept for the presence of computer viruses. Promethean Ltd and or associated and or subsidiary companies accepts no liability for any loss resulting from this email transmission. Promethean, Promethean House, Lower Philips Road, Blackburn, Lancashire, BB1 5TH, UK. Please update your records accordingly. Thank you! * This email has been checked by the e-Sweeper Service * ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
RE: Finding files before app loads
Sorry, I've found a problem creating an NSFileManager instance, but this is resolved and the file checks are now working :o) -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] om] On Behalf Of Glover,David Sent: 28 October 2008 15:34 To: Cocoa Development Subject: Finding files before app loads Hi there, I need to locate certain files and set the state of some objects in my nib accordingly before the app is visible to the user. I'm using fileExistsAtPath to look for the files when the awakeFromNib method is invoked. The files are definitely present, but fileExistsAtPath always returns false on each search - please could someone advise where I might be going wrong? Kind Regards Dave Promethean Limited is a company registered in England and Wales with company number 1308938 and VAT number GB 572 2599 18 __ Promethean Ltd and or associated and or subsidiary companies : The views expressed in this communication may not necessarily be the views held by Promethean Ltd and or associated and or subsidiary companies. This e-mail is for the exclusive use of the addressee(s). Unauthorised disclosure, copying or distribution is prohibited. This e-mail message has been swept for the presence of computer viruses. Promethean Ltd and or associated and or subsidiary companies accepts no liability for any loss resulting from this email transmission. Promethean, Promethean House, Lower Philips Road, Blackburn, Lancashire, BB1 5TH, UK. Please update your records accordingly. Thank you! * This email has been checked by the e-Sweeper Service * ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/david.glover%40promethe anworld.com This email sent to [EMAIL PROTECTED] * This email has been checked by the e-Sweeper Service * ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
RE: Finding files before app loads
I am now using [NSFileManager defaultManager], and all is working well (noob!) :o) -Original Message- From: I. Savant [mailto:[EMAIL PROTECTED] Sent: 28 October 2008 15:49 To: Glover,David Cc: Cocoa Development Subject: Re: Finding files before app loads On Tue, Oct 28, 2008 at 11:44 AM, Glover,David [EMAIL PROTECTED] wrote: Sorry, I've found a problem creating an NSFileManager instance, but this is resolved and the file checks are now working :o) Just as an aside, are you using +[NSFileManager defaultManager]? You shouldn't have to create an instance yourself. -- I.S. Promethean Limited is a company registered in England and Wales with company number 1308938 and VAT number GB 572 2599 18 __ Promethean Ltd and or associated and or subsidiary companies : The views expressed in this communication may not necessarily be the views held by Promethean Ltd and or associated and or subsidiary companies. This e-mail is for the exclusive use of the addressee(s). Unauthorised disclosure, copying or distribution is prohibited. This e-mail message has been swept for the presence of computer viruses. Promethean Ltd and or associated and or subsidiary companies accepts no liability for any loss resulting from this email transmission. Promethean, Promethean House, Lower Philips Road, Blackburn, Lancashire, BB1 5TH, UK. Please update your records accordingly. Thank you! * This email has been checked by the e-Sweeper Service * ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Deleting Alias
Hi, I've tried using removeFileAtPath to delete an alias in the users home folder, but this doesn't work - it deletes any other file, just not aliases. I can't seem to find another method that will do the job. Any help or advice to resolve this would be greatly appreciated. Kind Regards Dave Promethean Limited is a company registered in England and Wales with company number 1308938 and VAT number GB 572 2599 18 __ Promethean Ltd and or associated and or subsidiary companies : The views expressed in this communication may not necessarily be the views held by Promethean Ltd and or associated and or subsidiary companies. This e-mail is for the exclusive use of the addressee(s). Unauthorised disclosure, copying or distribution is prohibited. This e-mail message has been swept for the presence of computer viruses. Promethean Ltd and or associated and or subsidiary companies accepts no liability for any loss resulting from this email transmission. Promethean, Promethean House, Lower Philips Road, Blackburn, Lancashire, BB1 5TH, UK. Please update your records accordingly. Thank you! * This email has been checked by the e-Sweeper Service * ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
RE: Deleting Alias
Hi, just in case anybody else notices similar behaviour - I called removeFileAtPath if an fileExistsAtPath check on the alias evaluated to true - BUT fileExistsAtPath method only returns true on an alias if the original file / app is present. The removeFileAtPath method on its own will quite happily delete an alias whether the original file is present or not AFAIK. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] om] On Behalf Of Glover,David Sent: 19 September 2008 11:36 To: Cocoa Development Subject: Deleting Alias Hi, I've tried using removeFileAtPath to delete an alias in the users home folder, but this doesn't work - it deletes any other file, just not aliases. I can't seem to find another method that will do the job. Any help or advice to resolve this would be greatly appreciated. Kind Regards Dave Promethean Limited is a company registered in England and Wales with company number 1308938 and VAT number GB 572 2599 18 __ Promethean Ltd and or associated and or subsidiary companies : The views expressed in this communication may not necessarily be the views held by Promethean Ltd and or associated and or subsidiary companies. This e-mail is for the exclusive use of the addressee(s). Unauthorised disclosure, copying or distribution is prohibited. This e-mail message has been swept for the presence of computer viruses. Promethean Ltd and or associated and or subsidiary companies accepts no liability for any loss resulting from this email transmission. Promethean, Promethean House, Lower Philips Road, Blackburn, Lancashire, BB1 5TH, UK. Please update your records accordingly. Thank you! * This email has been checked by the e-Sweeper Service * ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/david.glover%40promethe anworld.com This email sent to [EMAIL PROTECTED] * This email has been checked by the e-Sweeper Service * ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Removing folder from /Applications
Hi there, I've create a little app that is required to remove an obsolete folder from /Applications. This works fine when the user is logged in as an Admin, but not when logged in as a Standard user, as they obviously require authorization. So, I added some code to request an Admin username and password using Authorization Services, immediately before calling removeFileAtPath to remove the folder. However, the folder still cannot be removed after inputting an Admin username and password. Please can anybody offer any insight into what I'm missing here? Kind regards Dave Promethean Limited is a company registered in England and Wales with company number 1308938 and VAT number GB 572 2599 18 __ Promethean Ltd and or associated and or subsidiary companies : The views expressed in this communication may not necessarily be the views held by Promethean Ltd and or associated and or subsidiary companies. This e-mail is for the exclusive use of the addressee(s). Unauthorised disclosure, copying or distribution is prohibited. This e-mail message has been swept for the presence of computer viruses. Promethean Ltd and or associated and or subsidiary companies accepts no liability for any loss resulting from this email transmission. Promethean, Promethean House, Lower Philips Road, Blackburn, Lancashire, BB1 5TH, UK. Please update your records accordingly. Thank you! * This email has been checked by the e-Sweeper Service * ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
RE: Removing folder from /Applications
Hi, here is the code; [...] // create the authorization reference... AuthorizationRef myAuthorizationRef; OSStatus myStatus; myStatus = AuthorizationCreate (NULL, kAuthorizationEmptyEnvironment, kAuthorizationFlagDefaults, myAuthorizationRef); // if the folder isn't there, then don't try to remove it! if ([NSFm fileExistsAtPath:@/Applications/Folder isDirectory: isDir] isDir) { // set up authorization before attempting to remove the folder... AuthorizationItem myItems[1]; myItems[0].name = com.promethean.DeviceRegisterUninstaller; myItems[0].valueLength = 0; myItems[0].value = NULL; myItems[0].flags = 0; AuthorizationRights myRights; myRights.count = sizeof (myItems) / sizeof (myItems[0]); myRights.items = myItems; AuthorizationFlags myFlags; myFlags = kAuthorizationFlagDefaults | kAuthorizationFlagInteractionAllowed | kAuthorizationFlagExtendRights; myStatus = AuthorizationCopyRights (myAuthorizationRef, myRights, kAuthorizationEmptyEnvironment, myFlags, NULL); if ([NSFm removeFileAtPath: (NSString *) @/Applications/Folder handler: nil] == NO) { [...] -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] om] On Behalf Of Robert Cerny Sent: 08 July 2008 12:35 To: Cocoa Development Subject: Re: Removing folder from /Applications On 8.7.2008, at 12:52, Glover,David wrote: Hi there, I've create a little app that is required to remove an obsolete folder from /Applications. This works fine when the user is logged in as an Admin, but not when logged in as a Standard user, as they obviously require authorization. So, I added some code to request an Admin username and password using Authorization Services, immediately before calling removeFileAtPath to remove the folder. However, the folder still cannot be removed after inputting an Admin username and password. Please can anybody offer any insight into what I'm missing here? Kind regards Dave Hi Dave, hard to help without any code. Robert ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/david.glover%40promethe anworld.com This email sent to [EMAIL PROTECTED] Promethean Limited is a company registered in England and Wales with company number 1308938 and VAT number GB 572 2599 18 __ Promethean Ltd and or associated and or subsidiary companies : The views expressed in this communication may not necessarily be the views held by Promethean Ltd and or associated and or subsidiary companies. This e-mail is for the exclusive use of the addressee(s). Unauthorised disclosure, copying or distribution is prohibited. This e-mail message has been swept for the presence of computer viruses. Promethean Ltd and or associated and or subsidiary companies accepts no liability for any loss resulting from this email transmission. Promethean, Promethean House, Lower Philips Road, Blackburn, Lancashire, BB1 5TH, UK. Please update your records accordingly. Thank you! * This email has been checked by the e-Sweeper Service * ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Requesting Administrator Name and Password
Hi all, I've created a little app that removes some files from within /Applications. This works fine when logged in as an Administrator, but won't run when logged in as a standard user. I've been spending some time looking into requesting an Adminstrator name and password (hoping that it would be as simple as using sudo!), but can't seem to find anything. Please can anyone advise on how best to do this? Kind Regards Promethean Limited is a company registered in England and Wales with company number 1308938 and VAT number GB 572 2599 18 __ Promethean Ltd and or associated and or subsidiary companies : The views expressed in this communication may not necessarily be the views held by Promethean Ltd and or associated and or subsidiary companies. This e-mail is for the exclusive use of the addressee(s). Unauthorised disclosure, copying or distribution is prohibited. This e-mail message has been swept for the presence of computer viruses. Promethean Ltd and or associated and or subsidiary companies accepts no liability for any loss resulting from this email transmission. Promethean, Promethean House, Lower Philips Road, Blackburn, Lancashire, BB1 5TH, UK. Please update your records accordingly. Thank you! * This email has been checked by the e-Sweeper Service * ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Appending to file with writeToFile
Hi All, I'm using writeToFile to send strings to a log file at various points in my program, however it doesn't append the strings, it just overwrites the previous one. So the only thing in the log file is the very last string that was sent to it. I've searched around for a while and can't find any way to append the strings in my file. I was wondering if anyone else had achieved this? Or if anybody knows how to do it? Kind Regards Dave Promethean Limited is a company registered in England and Wales with company number 1308938 and VAT number GB 572 2599 18 __ Promethean Ltd and or associated and or subsidiary companies : The views expressed in this communication may not necessarily be the views held by Promethean Ltd and or associated and or subsidiary companies. This e-mail is for the exclusive use of the addressee(s). Unauthorised disclosure, copying or distribution is prohibited. This e-mail message has been swept for the presence of computer viruses. Promethean Ltd and or associated and or subsidiary companies accepts no liability for any loss resulting from this email transmission. Promethean, Promethean House, Lower Philips Road, Blackburn, Lancashire, BB1 5TH, UK. Please update your records accordingly. Thank you! * This email has been checked by the e-Sweeper Service * ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
RE: Appending to file with writeToFile
Thank you for your advice - I used your suggestion plus using seekToEndOfFile beforehand worked a treat. Thanks again -Original Message- From: Ken Thomases [mailto:[EMAIL PROTECTED] Sent: 29 May 2008 16:08 To: Glover,David Cc: Cocoa-dev@lists.apple.com Subject: Re: Appending to file with writeToFile On May 29, 2008, at 9:42 AM, Glover,David wrote: I'm using writeToFile to send strings to a log file at various points in my program, however it doesn't append the strings, it just overwrites the previous one. So the only thing in the log file is the very last string that was sent to it. Yes. The writeToFile:... methods mean create a file with the receiver as its contents. It isn't for incremental building of a file, but for wholesale creation of a file. I've searched around for a while and can't find any way to append the strings in my file. I was wondering if anyone else had achieved this? Or if anybody knows how to do it? Use NSFileHandle. For example: NSFileHandler* fh = [NSFileHandle fileHandleForWritingAtPath:myOutputFilePath]; // ... [fh writeData:[myString dataUsingEncoding:NSUTF8StringEncoding]]; Cheers, Ken Promethean Limited is a company registered in England and Wales with company number 1308938 and VAT number GB 572 2599 18 __ Promethean Ltd and or associated and or subsidiary companies : The views expressed in this communication may not necessarily be the views held by Promethean Ltd and or associated and or subsidiary companies. This e-mail is for the exclusive use of the addressee(s). Unauthorised disclosure, copying or distribution is prohibited. This e-mail message has been swept for the presence of computer viruses. Promethean Ltd and or associated and or subsidiary companies accepts no liability for any loss resulting from this email transmission. Promethean, Promethean House, Lower Philips Road, Blackburn, Lancashire, BB1 5TH, UK. Please update your records accordingly. Thank you! * This email has been checked by the e-Sweeper Service * ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]