3 Replies
      Latest reply: Oct 25, 2016 2:46 AM by eskimo RSS
      giorgaros Level 1 Level 1 (0 points)

        I am currently using SMJobBless to create a privileged helper tool. I want to change the "standard" location (/Library/PrivilegedHelperTools/) it uses and install it in /Library/myapp/. I tried to manually add ProgramArguments to my launchd plist with no success.

         

        Is there any proper way to manipulate plist in order to do that or I have to move the helper manually and creating the folder I want to use too?

         

        Here is my swift code

         

            var authItem = AuthorizationItem(name: kSMRightBlessPrivilegedHelper,
                                                 valueLength: 0, value: nil, flags: 0)
               
                var myRights = AuthorizationRights(count: 1, items: &authItem)
               
                let myFlags : AuthorizationFlags = [.interactionAllowed, .preAuthorize, .extendRights ]
               
                var authRef: AuthorizationRef?
                let osStatus = AuthorizationCreate(&myRights, nil, myFlags, &authRef)
               
                if osStatus == errAuthorizationSuccess {
                    var error: Unmanaged<CFError>?
                    SMJobBless(kSMDomainSystemLaunchd, "com.company.HelperTool" as CFString, authRef, &error)
                    /
                   
                    if (error != nil) {
                        print(error)
                    }
                }
        
        • Re: Install a privileged helper in other location using SMJobBless
          eskimo Apple Staff Apple Staff (7,190 points)

          I am currently using SMJobBless to create a privileged helper tool. I want to change the "standard" location (/Library/PrivilegedHelperTools/) it uses and install it in /Library/myapp/.

          Please don’t do that.

          … or [do] I have to move the helper manually and creating the folder I want to use too?

          Please don’t do that either.

          Your SMJobBless privileged helper tool must live in /Library/PrivilegedHelperTools/.  Anything else puts you way off the beaten path of supported solutions.  If you absolutely must have a privileged helper tool installed elsewhere, install it using an installer.

          Share and Enjoy

          Quinn “The Eskimo!”
          Apple Developer Relations, Developer Technical Support, Core OS/Hardware
          let myEmail = "eskimo" + "1" + "@apple.com"