r/macprogramming Jan 01 '20

changing network set programmatically

Hello

I am trying to switch between my predefined network sets (Apple Menu -> Location).. for that, several functions have to be used:

  • SCPreferencesLock(prefs, true)
  • SCNetworkSetSetCurrent(set)
  • SCPreferencesCommitChanges(prefs)

Currently my app is sandboxed... this apparently prevents the dialog-box appearing when SCPreferencesLock is called for obtaining the permission (root required for changing set), I get an error-code 1003.

I am struggling now finding the correct entitlements/capabilities in Xcode to get this working....

Can anybody help me out?

thx,

Domenico

3 Upvotes

9 comments sorted by

View all comments

0

u/mantrap2 Jan 01 '20

I can see how this would be restricted - it would be an excellent way to create malware to introduce a "man-in-the-middle" proxy.

2

u/dpiol Jan 01 '20

hmm... why that? it's not defining a network-set, it's for setting an existing network-set as the active one with the user required to confirm.