Mac-Osx

是否可以以 root 身份執行 OS X GUI 應用程序?

  • September 20, 2009

當您以其他使用者身份登錄時,是否可以以 root 身份執行 Mac OS X GUI 應用程序?

$$ Yes, I recognize that this is usually a bad idea. $$ 當我嘗試

sudo open /Path/To/My.app

據我所知,它以登錄使用者身份執行。

$$ I’m sure you are wondering why I want to do this. Sigh. I am running NetRestore within a NetBoot image that was not created by NetRestore Helper, as I need to run some other GUI software after I do the restore. It logs into a standard administrator account. Normally when you run NetRestore, it asks you to authenticate before restoring. It appears that it determines that it is NetBooted and assumes that it is running under the root account, and refuses to ask for authentication, and thus has insufficient permissions to perform a restore. $$

$$ Most likely I will have to tweak my netbooting setup so it automatically logs into the root account, but if I could just run the one application as root, it would take much less time to set up. $$

[是的,我可以想出另一種方法來進行多播還原,但 NetRestore 已經過驗證、友好,並且在 Leopard 下仍然有效。作為替代方案,我可以將asr命令與iHook一起使用。]

open如果您想以其他使用者身份執行,請不要使用。打開通過 LaunchServices 啟動您要求的應用程序,它會像您點兩下它一樣載入它。

但是,如果您直接執行應用程序二進製文件,它將起作用。例如,以 root 身份(因此從已經以 root 身份執行的腳本或 via sudo)執行/Applications/TextEdit.app/Contents/MacOS/TextEdit,TextEdit 將以 root 身份執行。

您可能想為此嘗試Pseudo,因為您可以使用它來啟動具有系統管理員權限的應用程序。

我不太確定你在問什麼。如果你想讓某些東西自動執行,我猜你可以使用程序的啟動文件功能來創建啟動路徑。我沒有使用過這個功能,但它可能是你想要研究的東西。

引用自:https://serverfault.com/questions/47141