Re: Running EUID as root
Re: Running EUID as root
- Subject: Re: Running EUID as root
- From: Peter Sichel <email@hidden>
- Date: Tue, 21 Aug 2001 10:27:57 -0400
The description below is helpful, but begs the question how do
typical end users install your application as SUID root?
Ideally, I want to support drag and drop install.
I've written a simple unix tool called "IPNetMonitorAuthorize"
that sets my app to be SUID root by doing:
chmod 4777 path-to-my-tool/IPNetMonitorX
chown root path-to-my-tool/IPNetMonitorX
I've tested that it works from the terminal.
That is, before running my tool
"ls -l"
-rwxr-xr-x 1 psichel wheel 794740 Aug 21 10:02 IPNetMonitorX
Running the tool without privileges fails:
../Resources/IPNetMonitorAuthorize
chown: ../macos/IPNetMonitorX: Operation not permitted
and with privileges works as follows [SUID bit set, owner is root]:
sudo ../Resources/IPNetMonitorAuthorize
ls -l
-rwsrwxrwx 1 root wheel 794740 Aug 21 10:02 IPNetMonitorX
When my app starts up, I use the Security Framework to check if
I'm already authorized, and if not to AuthorizationExecuteWithPrivileges
IPNetMonitorAuthorize. My plan is to check if I'm authorized, and if
not authorize myself, quit the app, and relaunch it. This only
needs to happen once when my applications bundle is copied
to a new location.
I've encountered two problems:
(1) When I AuthorizationExecuteWithPrivileges IPNetMonitorAuthorize
it sets the SUID bit, but chown root fails (the owner doesn't
change). Any idea why? Does my tool need to raise the EUID
first? Does AuthorizationExecuteWithPrivileges really execute
my tool as root? The result code says it succeeded, and the
Security Framework reports my app is authorized.
(2) The Security Framework always reports my app is not authorized
until it collects a username and password even if my app is
already SUID root. What exactly does authorizing with the
Security Framework do that is different from being EUID root?
What's the Macintosh way to deliver an end user application
that needs to run as root? Any pointers would be much appreciated.
- Peter
At 8:19 AM -0500 8/21/01, Eric Peyton wrote:
You cannot change an application that is not setuid(root) or run by
root from the euid of an arbitrary user to the euid of root. The
MacOSX underlying BSD/kernel implementation prevents it. A user
application can NEVER become root. You will either need to ...
a) install your application setuid(root)
b) teach your users how to run your application as root
c) encapsulate your pcap code in a unix tool that is setuid(root)
and communicate back with the main app in some manner
c) encapsulate your pcap code in a unix tool that is run from your
main application and could be launched with
ApplicationExecuteWithPrivileges() and communicates back with the
main app in some manner.
There are a number of
examples of using the Security Framework to
AuthorizeExecuteWithPrivileges() another progam (e.g., at Stepwise), but
I want my own process to run in root mode.
--