SwiftPrivilegedHelper | Example application using a privileged helper tool | Authentication library
kandi X-RAY | SwiftPrivilegedHelper Summary
kandi X-RAY | SwiftPrivilegedHelper Summary
This is an example application to demonstrate how to use a privileged helper tool with authentication in Swift 4.2. Please undestand the code and improve and customize it to suit your needs and your application.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of SwiftPrivilegedHelper
SwiftPrivilegedHelper Key Features
SwiftPrivilegedHelper Examples and Code Snippets
Community Discussions
Trending Discussions on SwiftPrivilegedHelper
QUESTION
I'm writing a macOS app in Swift that needs a privileged helper tool -- wish the elevation wasn't necessary, but it looks like it is.
I found this excellent example application especially tailored for this scenario. I've managed to port its code to my own app, but I'm stuck at the point where I need to check if the helper tool is installed, and if it isn't, use SMJobBless()
and friends to install it.
When running the example app, if the helper tool is not installed, the app stays stuck at the following screen:
To be clear, from reading the code, I thought it was supposed to update the label to "Helper Installed: No" at some point, but that doesn't seem to happen.
If I click "Install Helper", this is the result.
From now on, unless I manually remove the helper tool, rerunning the app will display this screen with "Helper Installed: Yes".
This behavior might be OK in this example situation where the user has to manually click on the "Install Helper" button. However, in my app, I would like it to automatically request installation of the helper tool if it's not installed yet. If it's already installed, I don't want to waste the user's time requesting their password again.
I thought this would be simple enough: if the helper tool is not available, somewhere along the process of connecting to it, an error would happen, which is the trigger for me to request installation of the tool. If no errors happen, it's assumed that the tool was already installed.
Here is the hacked together code that I wrote for connecting to the helper tool via XPC:
...ANSWER
Answered 2019-Jan-19 at 14:02I would check the file system if the binary exists (in /Library/PrivilegedHelperTools and if the plist exists in /Library/LaunchDaemons). Then you might contact the XPC service and call kind of a ping function which answers if the service is up and running.
just my 2 cts,
Robert
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install SwiftPrivilegedHelper
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page