Objective-c MacOS Administrator Rights inheritance

Source: Internet
Author: User

Under MacOS, you can use the Authorizationexecutewithprivileges function to run a program as an administrator, which will pop up a box to enter a password if run with administrator privileges. And the execution of this program if the administrator to execute another program, will pop up a box. This means that permissions are not inherited.

The person who wrote the Windows program should know that if running the program as an administrator in the Win7 will pop up the UAC prompt, but the program is running, if you run another program, then the other program is an administrator, and does not play the UAC prompt, this means that permissions are inherited.

Below we implement permissions inheritance under Mac

#import <Cocoa/Cocoa.h> #import "STPrivilegedTask.h" int main (int argc, const char * argv[]) {        Stprivilegedtask *mytask = [[Stprivilegedtask alloc] init];    NSString *fullpath = @ "/applications/test.app/contents/macos/test";    Nsarray *args = [Nsarray arraywithobjects: @ "Install", nil]; Parameters        [MyTask Setlaunchpath:fullpath];    [MyTask Setarguments:args];    [MyTask launch];        Return Nsapplicationmain (argc, argv);}


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Objective-c MacOS Administrator Rights inheritance

Related Article

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.