• 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: [NOT NEWBIE]launching tasks as root
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [NOT NEWBIE]launching tasks as root


  • Subject: Re: [NOT NEWBIE]launching tasks as root
  • From: Peter Sichel <email@hidden>
  • Date: Tue, 1 Oct 2002 20:27:23 -0400

At 6:11 PM -0500 10/1/02, Charles Srstka wrote:
When I launch a task with AuthorizationExecuteWithPrivileges(), the actual UID of that task is the same as the currently logged-in user, but the effective UID is root. Unfortunately, the vsdbutil tool requires the actual UID be root. Is there any way I can launch a task with an actual UID of root without resorting to using sudo?

Thanks in advance,
Charles

Since your effective UID is root, you can write a small unix tool to
run your task and pipe back the results. Within your tool,
set your UID to be root before using execv to run vsdbutil.

// Run vsdbutil from a privileged process and pipe back the results.
// Notice we don't use fork() since we want to replace ourselves so
// the caller can retain control using NSTask.

setuid(0);
execv("/usr/sbin/vsdbutil", argv);

See Stevens "Advanced Programming in the UNIX Environment" for more info
on setuid() and execv(). With this technique, you can use NSTask to
launch and control any privileged command.

- Peter
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: [NOT NEWBIE]launching tasks as root
      • From: Charles Srstka <email@hidden>
References: 
 >[NOT NEWBIE]launching tasks as root (From: Charles Srstka <email@hidden>)

  • Prev by Date: Re: UML and Cocoa (again...)
  • Next by Date: Re: [NOT NEWBIE]launching tasks as root
  • Previous by thread: Re: [NOT NEWBIE]launching tasks as root
  • Next by thread: Re: [NOT NEWBIE]launching tasks as root
  • Index(es):
    • Date
    • Thread