New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

Start a Discussion

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Development and Darwin Discussion and questions about development for Mac OS X.

Slightly Better authorization sample fails only in Leopard

Post Reply New Thread Subscribe

Thread Tools

Member Since: Jan 19, 2012
Posts: 1
globalian is on a distinguished road

globalian is offline
Hi All,

I have been using slightly better authorization model sample program for executing OpenVPN command from the shell. It seems that while adding the IP into the routing table, I get the following error at Leopard ( 10.6.8 ) - "route: must be root to alter routing table". In Lion ( 10.7.2 ) the same authorization model works fine for me. There is no routing table insertion error as above. Is there any difference between the AuthorizationCreate() & AuthorizationExecuteWithPrivileges() calls on Lion and Leopard? If I want to stick with the same authorization elevation model, will there be any additional flag(s) to be set for Leopard program? Below are my current flag setting :

int main() {

OSStatus myStatus;
AuthorizationFlags myFlags = kAuthorizationFlagDefaults; // 1
AuthorizationRef myAuthorizationRef; // 2

myStatus = AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment, // 3
myFlags, &myAuthorizationRef);
if (myStatus != errAuthorizationSuccess)
return myStatus;

AuthorizationItem myItems = {kAuthorizationRightExecute, 0, // 4
NULL, 0};
AuthorizationRights myRights = {1, &myItems}; // 5

myFlags = kAuthorizationFlagDefaults | // 6
kAuthorizationFlagInteractionAllowed |
kAuthorizationFlagPreAuthorize |
myStatus = AuthorizationCopyRights (myAuthorizationRef, // 7
&myRights, NULL, myFlags, NULL );

if (myStatus != errAuthorizationSuccess) goto DoneWorking;

char myToolPath[] = "/Applications/MyApp/";
char *myArguments[] = { "--remote","", "1194", "udp" , "--config", "/Applications/MyApp/", NULL };
FILE *myCommunicationsPipe = NULL;
char myReadBuffer[128];

myFlags = kAuthorizationFlagDefaults; // 8
myStatus = AuthorizationExecuteWithPrivileges // 9
(myAuthorizationRef, myToolPath, myFlags, myArguments,

if (myStatus == errAuthorizationSuccess)
int bytesRead = read (fileno (myCommunicationsPipe),
( unsigned char * ) myReadBuffer, sizeof (myReadBuffer));
if (bytesRead < 1) goto DoneWorking;
write (fileno (stdout), (unsigned char * ) myReadBuffer, bytesRead);

AuthorizationFree (myAuthorizationRef, kAuthorizationFlagDefaults); // 10

if (myStatus) printf("Status: %ld\n", myStatus);
return myStatus;

I am struck with this problem for more than 2 days. Any help on this is more appreciated.

QUOTE Thanks

Post Reply New Thread Subscribe

« Editing a script | Mac Script Problems »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Starter
Last Post
slightly older macbook - upgrading from Leopard to Lion questions jbrittmartin OS X - Operating System 4 07-21-2011 05:51 PM
Snow Leopard 10.6 fails to update to 10.6.1 gbarnes28 OS X - Operating System 1 12-09-2009 12:53 AM
new macbook pro system log normal? micho.mad OS X - Operating System 3 04-24-2009 03:13 PM
Every time my internet connection fails leopard wants me to restart Jukike OS X - Operating System 7 11-22-2007 07:18 PM

All times are GMT -4. The time now is 12:25 PM.

Powered by vBulletin
Copyright ©2000 - 2015, Jelsoft Enterprises Ltd.

Welcome to

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!

(4 digit year)

Already a member?