Re: Still having problume with Security API
Re: Still having problume with Security API
- Subject: Re: Still having problume with Security API
- From: Guy Winslow <email@hidden>
- Date: Wed, 16 May 2001 11:17:12 -0700
on 5/16/01 8:15 AM, Ryan Dary at email@hidden wrote:
>
Actually, when you call the AuthorizationExecuteWithPrivileges, it must
>
be altering the argv array that is passed in because you don't need to
>
pass it the path to the program as the first arg, as might be expected.
>
The program being executed will still receive the path as the first [0]
>
arg.
>
>
- Ryan
>
>
>
On Tuesday, May 15, 2001, at 04:15 PM, email@hidden wrote:
>
>
> On Wednesday, May 16, 2001, at 12:56 AM, Ryan Dary wrote:
>
>
>
>>> Your argv doesn't have a NULL termination:
>
>>>
>
>>> char * argv[3];
>
>>>
>
>>> [...]
>
>>>
>
>>> argv[0] = SOURCE;
>
>>> argv[1] = DESINATION;
>
>>> argv[2] = NULL;
>
>>>
>
>>> Try adding that..
>
>>>
>
>>> - Ryan
>
>
>
> argv[0] should be the application name, so it's something like:
>
>
>
> char *argv[4];
>
>
>
> argv[0]=PROGRAM; // "cp"
>
> argv[1]=SOURCE;
>
> argv[2]=DESTINATION;
>
> argv[3]=NULL;
>
> --
>
> Pelle Johansson
>
> <email@hidden>
>
> _______________________________________________
>
> cocoa-dev mailing list
>
> email@hidden
>
> http://www.lists.apple.com/mailman/listinfo/cocoa-dev
>
_______________________________________________
>
cocoa-dev mailing list
>
email@hidden
>
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Ok Ran Another test with All Possibilities. This was my results:
Test Cases:
If I Use this Function:
- (void)doCommand
{
OSStatus err = 0;
char *argv[3];
argv[0] = COMMAND;
argv[1] = SOURCE;
argv[2] = DESINATION;
if(![self authenticate])
return;
err = AuthorizationExecuteWithPrivileges(authorizationRef, COMMAND, 0,
argv, NULL);
if(err!=0)
{
NSBeep();
NSLog(@"Error %d in AuthorizationExecuteWithPrivileges",err);
}
}
I Get This:
May 16 10:20:24 SMBControlPanel[503] Error -60031 in
AuthorizationExecuteWithPrivileges
If I Use this Function:
- (void)doCommand
{
OSStatus err = 0;
char *argv[3];
argv[1] = SOURCE;
argv[2] = DESINATION;
if(![self authenticate])
return;
err = AuthorizationExecuteWithPrivileges(authorizationRef, COMMAND, 0,
argv, NULL);
if(err!=0)
{
NSBeep();
NSLog(@"Error %d in AuthorizationExecuteWithPrivileges",err);
}
}
I Get This:
usage: cp [-R [-H | -L | -P]] [-f | -i] [-p] src target
cp [-R [-H | -L | -P]] [-f | -i] [-p] src1 ... srcN directory
If I Use this Function:
- (void)doCommand
{
OSStatus err = 0;
char *argv[3];
argv[0] = NULL;
argv[1] = SOURCE;
argv[2] = DESINATION;
if(![self authenticate])
return;
err = AuthorizationExecuteWithPrivileges(authorizationRef, COMMAND, 0,
argv, NULL);
if(err!=0)
{
NSBeep();
NSLog(@"Error %d in AuthorizationExecuteWithPrivileges",err);
}
}
I Get This:
usage: cp [-R [-H | -L | -P]] [-f | -i] [-p] src target
cp [-R [-H | -L | -P]] [-f | -i] [-p] src1 ... srcN directory
If I Use this Function:
- (void)doCommand
{
OSStatus err = 0;
char *argv[4];
argv[0] = COMMAND;
argv[1] = SOURCE;
argv[2] = DESINATION;
argv[3] = NULL;
if(![self authenticate])
return;
err = AuthorizationExecuteWithPrivileges(authorizationRef, COMMAND, 0,
argv, NULL);
if(err!=0)
{
NSBeep();
NSLog(@"Error %d in AuthorizationExecuteWithPrivileges",err);
}
}
I Get This:
usage: cp [-R [-H | -L | -P]] [-f | -i] [-p] src target
cp [-R [-H | -L | -P]] [-f | -i] [-p] src1 ... srcN directory
If I Use this Function:
- (void)doCommand
{
OSStatus err = 0;
char *argv[4];
argv[0] = "cp";
argv[1] = SOURCE;
argv[2] = DESINATION;
argv[3] = NULL;
if(![self authenticate])
return;
err = AuthorizationExecuteWithPrivileges(authorizationRef, COMMAND, 0,
argv, NULL);
if(err!=0)
{
NSBeep();
NSLog(@"Error %d in AuthorizationExecuteWithPrivileges",err);
}
}
I Get This:
usage: cp [-R [-H | -L | -P]] [-f | -i] [-p] src target
cp [-R [-H | -L | -P]] [-f | -i] [-p] src1 ... srcN directory
If I Use this Function:
- (void)doCommand
{
OSStatus err = 0;
char *argv[3];
argv[0] = SOURCE;
argv[1] = DESINATION;
argv[2] = NULL;
if(![self authenticate])
return;
err = AuthorizationExecuteWithPrivileges(authorizationRef, COMMAND, 0,
argv, NULL);
if(err!=0)
{
NSBeep();
NSLog(@"Error %d in AuthorizationExecuteWithPrivileges",err);
}
}
I Get This:
/bin/cp: /tmp/smb.conf: No such file or directory
Note - This one Works Randomly.