Cannot manage to get auth services running
Cannot manage to get auth services running
- Subject: Cannot manage to get auth services running
- From: Development <email@hidden>
- Date: Sun, 1 Mar 2009 18:55:14 -0700
I am trying to create a tool that will run as root to perform a simple
copy and rename function. However nothing I do seems to work.
I am using one of the self repairing tool examples and it fails
miserably. Basically it says its going to execute with privs loged for
debuging) and then immediately exits having not repaired itself, it
gives no error at all.
I'm looking for an idiots guide to authservices here because I simply
cannot get it to work to save my life. I've never understood the
framework and I dont know why. I tried to post the source I was using
but the message was kicked back.
This is the code that is suppose to execute and repair the tool (run
from within the tool)
if (geteuid() != 0)
{
int status;
int pid;
FILE *commPipe = NULL;
char *arguments[] = { "--self-repair", NULL };
char buffer[1024];
int bytesRead;
/* Set our own stdin and stdout to be the communication
channel with ourself. */
IFDEBUG(fprintf(stderr, "Tool about to self-exec through
AuthorizationExecuteWithPrivileges.\n");)
//This is the last message printed to my screen. After
this I immediately get notice that the process exited
//without any errors
if (AuthorizationExecuteWithPrivileges(auth,
path_to_self, kAuthorizationFlagDefaults, arguments, &commPipe))
exit(kMyAuthorizedCommandSelfRepairError);
/* Read from stdin and write to commPipe. */
for (;;)
{
bytesRead = read(0, buffer, 1024);
if (bytesRead < 1) break;
fwrite(buffer, 1, bytesRead, commPipe);
}
/* Flush any remaining output. */
fflush(commPipe);
/* Close the communication pipe to let the child know we
are done. */
fclose(commPipe);
/* Wait for the child of
AuthorizationExecuteWithPrivileges to exit. */
pid = wait(&status);
if (pid == -1 || ! WIFEXITED(status))
exit(kMyAuthorizedCommandSelfRepairError);
fprintf(stderr,"About to quit");
exit(WEXITSTATUS(status));
}
_______________________________________________
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