2

I am writing an application that when is running should modify SystemConfiguration to set system wide proxy.

I know it is possible to do that using "Authorization Services" framework provided by Apple, however I see that it keeps asking for a user password to allow changes.

On the other hand I have 3rd party application (not the one I am writing) that does the same, but does not require user password. The application is not even written in Objective-C, but written in FreePascal (FPC) instead. Unfortunately I have no source code for this application to see how it does this trick.

I know I should be able to achieve the same (system config changes without sudo password) by either having Privileged Helper Tool supplied with the application (and perhaps install it on first run) or by going even nastier and loading a kext.

However I see that this application does neither of above. It only performs system calls and no password asked! I am completely puzzled how did they achieve that and would like to find a way to do the same.

So the question is - how to achieve complete "no password asked" for changing System Configuration on Mac OS X with an application?

PS: Application I have at hand runs as user, not root. And there is no modifications to sudoers neither.

Alexey Kamenskiy
  • 2,888
  • 5
  • 36
  • 56
  • If your application is not written in Objective-C, then why do you select that tag to confuse people? And which system configuration do you intend to alter? Many of them can be accessed through AppleScript. – El Tomato Dec 04 '15 at 08:13
  • @ElTomato My application is written in Objective-C, but the application that I see doing it without password is not. For the system configuration that I want to access is network preferences, specifically system wide proxies (HTTP/HTTPS/SOCKS) – Alexey Kamenskiy Dec 04 '15 at 08:27
  • The majority, if not all, of the configuration settings simply change plist files in the system or user library folders. I don't know which file specifically is responsible for networking/proxies, but if you can find it in the user's library folder you should be able to edit it using the standard plist editing utilities. Of course your changes will be limited to the current user, but it should be kind of obvious that you can't change system-wide settings without a password. – Dave Dec 04 '15 at 08:39
  • @Dave The plist which contains these settings does not belong to user, it belongs to root. So editing that file directly will require standard privilege escalation. Moreover I tried multiple tools to figure out how this 3rd pary application does it including monitoring of starting child processes or opening files. Nothing like that happens here. All done just through system calls. – Alexey Kamenskiy Dec 04 '15 at 08:43
  • I see. I'm sorry I've misunderstood you. I don't know anything about networks. There are some network configurations you can access through AppleScript, which, of course, you can control with your Objective-C application. If you don't know what you can do with AppleScript, open Script Editor and choose Open Dictionary under File. Then select System Events. – El Tomato Dec 04 '15 at 09:16

1 Answers1

1

This is silly, but after 2 days straight of searching for a solution I found that there is no special code nor any tricks required.

This is easily done via setting setuid bit to binary that requires escalated privilege and calling setuid(0) in the code before doing operations that require privilege (not sure if second part is necessary).

Relevant links:

PS: This works basically on any Unix-like system (BSD, Linux Solaris etc) with one details - this does not work on scripts (the ones that require hash-bang #! in order to execute interpreter) with exception of Solaris, where it seems to work just fine.

Community
  • 1
  • 1
Alexey Kamenskiy
  • 2,888
  • 5
  • 36
  • 56