Install a privileged helper in other location using SMJobBless

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)
            }
        }

Replies

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"

The reason I want to do this is so I can have some text files accompanying my launch daemon that are completely necessary (and cannot bundled within it because it's an executable not an app). I don't thing /Library/PrivilegedHelperTools is the right place to put them

I don't thing /Library/PrivilegedHelperTools is the right place to put [my text files]

Right. Are these files you want to show to the user? Or configuration files read by the daemon?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"