我正在使用Install4j为我们的Java应用程序创建OS X安装程序。安装程序设置为安装服务,然后启动它。它会这样做,但它以当前用户而不是root用户身份运行服务。重新启动后,该服务将以root身份运行(因为它是作为LaunchDaemon安装的)。当安装程序第一次启动时,如何将其设置为以root身份运行?
更新1:在“安装服务”之后添加“启动服务”操作后,我从日志中获取以下信息:
> [INFO]
> com.install4j.runtime.beans.actions.services.InstallServiceAction [ID
> 67]: Execute action
> Property description:
> Property installedServices: []
> Property serviceName: null
> Property executable: null
> Property launcherId: 57
> Property accountNameOrSid:
> Property macosIdentifier: com.degoo.backgroundService
> Property password: [logging of password is disabled]
> Property serviceAccount: Local System
> Property windowsArguments:
> Property windowsDependencies:
> Property windowsPriority: Normal
> Property autoStart: true
> Property interactive: false
> Property keepCurrentAccount: false
> Property restartOnFailure: true
> Property persistentProperties: {}
> Property rollbackSupported: true
> Execute action successful after 21 ms [INFO] com.install4j.runtime.beans.actions.services.StartServiceAction [ID
> 223]: Execute action
> Property autostartOnly: false
> Property serviceName: null
> Property executable: null
> Property launcherId: 57
> Property rollbackSupported: true
> usedExecutable: /Applications/Degoo/DegooBackgroundService
> SUID elevation: true, true
>
> ERROR] com.install4j.runtime.installer.helper.launching.LaunchHelper:
> return value is 126 [ERROR]
> com.install4j.runtime.beans.actions.services.StartServiceAction [ID
> 223]: Execute action not successful after 519 ms [INFO]
> com.install4j.runtime.beans.screens.InstallationScreen [ID 8]:
> Rollback barrier reached
> command: move 1 screens, executing actions, checking condition [INFO] com.install4j.runtime.beans.screens.FinishedScreen [ID 12]:
> Show screen [INFO] com.install4j.runtime.beans.screens.FinishedScreen
> [ID 12]: command: finish
> cleaning up
> Finished
答案 0 :(得分:3)
在“安装服务”操作后使用“启动服务”操作,而不是直接执行启动器。
答案 1 :(得分:2)
我发现了问题。我在操作树中的“安装”下面有“启动服务”操作。将其移至“完成”之后,它以root身份成功执行。