Forums
New posts
Articles
Product Reviews
Policies
FAQ
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Menu
Log in
Register
Install the app
Install
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
Open GUI applications as root
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="gatorparrots" data-source="post: 2412"><p><strong>Launching Carbon applications with root privileges</strong></p><p>Older Carbon applications have to be run via <strong>LaunchCFMApp</strong> because they are in the wrong binary format for Mac OS X, so LaunchCFMApp handles the necessary translation. </p><p> </p><p>To launch a Carbon application directly (without using open), one has to actually run LaunchCFMApp, giving it the application as an argument:</p><p><span style="color: blue">/System/Library/Frameworks/Carbon.framework/Versions/Current/Support/LaunchCFMApp '/path/to/some/application'</span>. </p><p></p><p><strong>open</strong> can also be used to launch Carbon applications. <strong>open</strong> simulates a double click, hence the package name is given, rather than the full path to the executable. <strong>open</strong>'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 <strong>open</strong>, most of the difficult work is done for you: <span style="color: blue">open '/path/to/some/application'</span></p><p> </p><p>To launch a Carbon application with root privileges, you have to prepend <strong>sudo -b</strong> to the first command above. Here is a specific example:</p><p><span style="color: blue">sudo -b /System/Library/Frameworks/Carbon.framework/Versions/Current/Support/LaunchCFMApp '/Applications/BBEdit Lite 6.1/BBEdit Lite 6.1 for OS X'</span></p><p></p><p><strong>Launching Cocoa applications with root privileges</strong></p><p>To run applications as root, we use <strong>sudo</strong>. However combining <strong>open</strong> and <strong>sudo</strong> in this form:</p><p><span style="color: blue">sudo open /path/to/some.app</span></p><p>results in <strong>sudo</strong> running <strong>open</strong> as root, but <em><strong>open</strong> still opens the application as the original user</em>!!!</p><p></p><p>Therefore, the longer method of specifying the full path name for Cocoa applications (not just to the <strong>.app</strong> package, but to the actual executable): </p><p><span style="color: blue">sudo "/Applications/TextEdit.app/Contents/MacOS/TextEdit"</span></p><p></p><p>(The <strong>-b</strong> flag can be specified to run appropriate applications in the background. You can't use <strong>&</strong> and <strong>sudo</strong> when an authentication password is required, necessitating the need for the <strong>-b</strong> flag.)</p></blockquote><p></p>
[QUOTE="gatorparrots, post: 2412"] [b]Launching Carbon applications with root privileges[/b] Older Carbon applications have to be run via [b]LaunchCFMApp[/b] 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: [color=blue]/System/Library/Frameworks/Carbon.framework/Versions/Current/Support/LaunchCFMApp '/path/to/some/application'[/color]. [b]open[/b] can also be used to launch Carbon applications. [b]open[/b] simulates a double click, hence the package name is given, rather than the full path to the executable. [b]open[/b]'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 [b]open[/b], most of the difficult work is done for you: [color=blue]open '/path/to/some/application'[/color] To launch a Carbon application with root privileges, you have to prepend [b]sudo -b[/b] to the first command above. Here is a specific example: [color=blue]sudo -b /System/Library/Frameworks/Carbon.framework/Versions/Current/Support/LaunchCFMApp '/Applications/BBEdit Lite 6.1/BBEdit Lite 6.1 for OS X'[/color] [b]Launching Cocoa applications with root privileges[/b] To run applications as root, we use [b]sudo[/b]. However combining [b]open[/b] and [b]sudo[/b] in this form: [color=blue]sudo open /path/to/some.app[/color] results in [b]sudo[/b] running [b]open[/b] as root, but [i][b]open[/b] still opens the application as the original user[/i]!!! Therefore, the longer method of specifying the full path name for Cocoa applications (not just to the [b].app[/b] package, but to the actual executable): [color=blue]sudo "/Applications/TextEdit.app/Contents/MacOS/TextEdit"[/color] (The [b]-b[/b] flag can be specified to run appropriate applications in the background. You can't use [b]&[/b] and [b]sudo[/b] when an authentication password is required, necessitating the need for the [b]-b[/b] flag.) [/QUOTE]
Verification
Post reply
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
Open GUI applications as root
Top