Reputation: 121
I'm trying to change the system proxy settings with authentication. The system proxy can be changed successfully, but when my App relaunched, the auhorizating dialog(requiring username and password) always pop up.
How can I authorize once and for all?
I have a demo App with source codes on GitHub: https://github.com/codinn/SystemProxySettingsDemo
details:
A demo for changing system proxy settings.
After click “Enable System Proxy”, a dialog for requesting auhorization will be popped up, and subsequent clicks won't popup again, which is fine. But if we Quit and Relaunch the app, the auhorizating dialog will be popped up again.
How can we authorize once and for all?
Function define:
// requesting authorization with “AuthorizationCopyRights”
// set system network preferences proxy with “SCPreferencesCreateWithAuthorization” and “SCPreferencesPathSetValue”
func socksProxySet(enabled: Bool)`
4. File “CommonAuthorization.swift”: set / get authorization policy database entries 5. File “codinnDemoRightRemove.sh”: clear policy database entries belongs to demo app
Upvotes: 2
Views: 600
Reputation: 121
The best way to maintain a persistent authorisation to change these settings is to create a launchd daemon that runs as root. Such a daemon can change System Configuration preferences at any time without further authorisation.
Apple sample referrnce: EvenBetterAuthorizationSample
Upvotes: 2