App Right on Mac

Source: Internet
Author: User
Tags root access

An app on a Mac needs to create a profile under the/applications/my.app/contents/macos path, run under the root-enabled account, but run under an account that does not have root access, creating a file that fails and reports " Permission Denied "

Take the time to understand the application on the Mac right, for security reasons, the right way has been adjusted, the current Apple recommended way is to use security Manager, and provide an example: smjobbless

The following references are from StackOverflow Http://stackoverflow.com/questions/18404884/c-show-osx-permission-dialog

"

Originally, Apple provided a function 'authorizationexecutewithprivileges' allowed a application to launch Another with root privileges. This have since been deprecated for security reasons.

The dialog is a bit misleading. Apple provides authorization services, launches the dialog under various different situations, but usually from an app Lication has called the function authorizationcopyrights, after have setup rules in an authorization database (the FI Le At/etc/authorization) and has created the authorization reference with Authorizationcreate.

Security on OSX is split between a security daemon, a security agent and applications. An application can restrict features using this system, or request authorisation for the user to enter credentials so it C An launch a privileged application, which are what you need to do.

It's important to note the dialog have not been presented by the application, but by the Security Agent, which is sole Ly responsible for the security GUI. The daemon actually processes the authorization.

Apple's method for elevation are to has all applications run with standard User rights and should a privileged task be req Uired, then this must being factored out into a separate application which are registered to run with Launchd and given the El evated privileges. The example Apple provides issmjobbless.

While the calling code of the example was written in objective-c, the important functions was just C functions in the Smjob BLESSAPPCONTROLLER.M file, most notably Authorizationcreate to create a authorisation reference and the code in The Objective-c function blesshelperwithlabel:error: at the bottom of the file.

Begin with this help document on Smjobbless, which details the process.

Finally, if you ' re using Qt, you'll need to include Apple's Security framework for the required function calls. To does, just add the following to your. Pro File:-

QMAKE_LFLAGS += -F /System/Library/Frameworks/Security.framework/LIBS += -framework Security

"

Report:

1.Enable and using the "root" user in Mac OS X

https://support.apple.com/en-us/HT204012

App Right on Mac

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.