• 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: Communicate with pipe and AuthorizationExecuteWithPrivileges
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Communicate with pipe and AuthorizationExecuteWithPrivileges


  • Subject: Re: Communicate with pipe and AuthorizationExecuteWithPrivileges
  • From: "Sven A. Schmidt" <email@hidden>
  • Date: Mon, 25 Jun 2001 20:13:43 +0200

On Montag, Juni 25, 2001, at 06:10 Uhr, Jorge Salvador Caffarena wrote:

Here I am again with a question about AuthorizationExecuteWithPrivileges. The only documentation I have found on this function is on its header file, and it is short and not very helpfull sometimes.

I want to get the output of the tool I execute with AuthorizationExecuteWithPrivileges, but when I use a FILE * handler, after trying to read from it my app enter some kind of deadlock and the Beachball Of Death appears. Here is the code:

err = AuthorizationExecuteWithPrivileges(authorizationRef,
"/sbin/shutdown",0,args,&output);

fread(buffer,1,4096,output);
NSLog(@"%s\n",buffer);

The variable "output" is of type "FILE *" and the NSLog do not execute, what am I doing wrong?

I'm using the following successfully, which is from Ben Lachman's BLAuthentication framework, which again is based on Brian Hill's article on the Authorization framework on stepwise.

outputData = [NSMutableData data];
tempData = [NSMutableData dataWithLength:512];
do {
[tempData setLength:512];
//read the output of the task using fread or any other
//standard FILE function.
//You should also be able to write to the task if needed
//(but don't if it's not needed, or you'll get a SIGPIPE).
len = fread([tempData mutableBytes],1,512,communicationsPipe);
//NSLog( @"len: %i", len );
if(len>0) {
[tempData setLength:len];
[outputData appendData:tempData];
}
} while(len==512);

Like I said, this works, but I've encountered the same symptom as you whenever I tried to write to the same pipe I before I read from it.

HTH,
Sven


  • Follow-Ups:
    • Re: Communicate with pipe and AuthorizationExecuteWithPrivileges
      • From: Jorge Salvador Caffarena <email@hidden>
References: 
 >Communicate with pipe and AuthorizationExecuteWithPrivileges (From: Jorge Salvador Caffarena <email@hidden>)

  • Prev by Date: Re: [NEWBIE] Sheets problem
  • Next by Date: Re: *?
  • Previous by thread: Communicate with pipe and AuthorizationExecuteWithPrivileges
  • Next by thread: Re: Communicate with pipe and AuthorizationExecuteWithPrivileges
  • Index(es):
    • Date
    • Thread