Launching Carbon applications with root privileges
03-03-2003, 06:56 PM
Older Carbon applications have to be run via LaunchCFMApp
because they are in the wrong binary format for Mac OS X, so LaunchCFMApp handles the necessary translation.
To launch a Carbon application directly (without using open), one has to actually run LaunchCFMApp, giving it the application as an argument:
can also be used to launch Carbon applications. open
simulates a double click, hence the package name is given, rather than the full path to the executable. open
's main advantage is in opening documents since it uses the Finder's 'open with' database of what applications open what documents, and in opening Carbon applications. Using open
, most of the difficult work is done for you: open '/path/to/some/application'
To launch a Carbon application with root privileges, you have to prepend sudo -b
to the first command above. Here is a specific example:
sudo -b /System/Library/Frameworks/Carbon.framework/Versions/Current/Support/LaunchCFMApp '/Applications/BBEdit Lite 6.1/BBEdit Lite 6.1 for OS X'
Launching Cocoa applications with root privileges
To run applications as root, we use sudo
. However combining open
in this form:
sudo open /path/to/some.app
results in sudo
as root, but open still opens the application as the original user
Therefore, the longer method of specifying the full path name for Cocoa applications (not just to the .app
package, but to the actual executable):
flag can be specified to run appropriate applications in the background. You can't use &
when an authentication password is required, necessitating the need for the -b