{"id":77,"date":"2010-03-25T08:26:36","date_gmt":"2010-03-25T08:26:36","guid":{"rendered":"http:\/\/blog.designed79.co.uk\/?p=77"},"modified":"2010-03-25T08:26:36","modified_gmt":"2010-03-25T08:26:36","slug":"launch-apps-with-root-permissions-2","status":"publish","type":"post","link":"https:\/\/blog.designed79.co.uk\/?p=77","title":{"rendered":"Launch Apps With Root Permissions"},"content":{"rendered":"<p><strong><span style=\"text-decoration: underline;\">Launching Carbon applications with root privileges<\/span><\/strong><\/p>\n<p><strong><br \/>\n<\/strong><\/p>\n<p>Older Carbon applications have to be run via\u00a0<strong>LaunchCFMApp<\/strong> because they are in the wrong binary format for Mac OS X, so LaunchCFMApp handles the necessary translation.<\/p>\n<p>To launch a Carbon application directly (without using open), one has to actually run LaunchCFMApp, giving it the application as an argument:<\/p>\n<p>\/System\/Library\/Frameworks\/Carbon.framework\/Versions\/Current\/Support\/LaunchCFMApp &#8216;\/path\/to\/some\/application&#8217;.<\/p>\n<p><strong>open<\/strong> can also be used to launch Carbon applications.\u00a0<strong>open<\/strong> simulates a double click, hence the package name is given, rather than the full path to the executable.\u00a0<strong>open<\/strong>&#8216;s main advantage is in opening documents since it uses the Finder&#8217;s &#8216;open with&#8217; database of what applications open what documents, and in opening Carbon applications. Using\u00a0<strong>open<\/strong>, most of the difficult work is done for you:\u00a0open &#8216;\/path\/to\/some\/application&#8217;<\/p>\n<p>To launch a Carbon application with root privileges, you have to prepend\u00a0<strong>sudo -b<\/strong> to the first command above. Here is a specific example:<\/p>\n<p>sudo -b \/System\/Library\/Frameworks\/Carbon.framework\/Versions\/Current\/Support\/LaunchCFMApp &#8216;\/Applications\/BBEdit Lite 6.1\/BBEdit Lite 6.1 for OS X&#8217;<\/p>\n<p><strong><span style=\"text-decoration: underline;\">Launching Cocoa applications with root privileges<\/span><\/strong><\/p>\n<p><strong><br \/>\n<\/strong><\/p>\n<p>To run applications as root, we use\u00a0<strong>sudo<\/strong>. However combining\u00a0<strong>open<\/strong> and\u00a0<strong>sudo<\/strong> in this form:<\/p>\n<p>sudo open \/path\/to\/some.app<\/p>\n<p>results in\u00a0<strong>sudo<\/strong> running\u00a0<strong>open<\/strong> as root, but\u00a0<strong><em>open<\/em><\/strong><em> still opens the application as the original user<\/em>!!!<\/p>\n<p>Therefore, the longer method of specifying the full path name for Cocoa applications (not just to the\u00a0<strong>.app<\/strong> package, but to the actual executable):<\/p>\n<p>sudo &#8220;\/Applications\/TextEdit.app\/Contents\/MacOS\/TextEdit&#8221;<\/p>\n<p>(The\u00a0<strong>-b<\/strong> flag can be specified to run appropriate applications in the background. You can&#8217;t use<strong>&amp;<\/strong> and\u00a0<strong>sudo<\/strong> when an authentication password is required, necessitating the need for the\u00a0<strong>-b<\/strong>flag.)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Launching Carbon applications with root privileges Older Carbon applications have to be run via\u00a0LaunchCFMApp because they are in the wrong binary format [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-77","post","type-post","status-publish","format-standard","hentry","category-info-on-tech"],"_links":{"self":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/77","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=77"}],"version-history":[{"count":0,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/77\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=77"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=77"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=77"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}