3

I am trying to write an app that will edit a file that is stored in

/private/etc/hosts 

Normally, from the Terminal, I must use sudo to write to this file, so I should think I need elevated permissions in my cocoa app.

I was hoping to ask for it once, and then somehow store the permission so I don't need to ask again. I am a little lost about where to start.

halfer
  • 19,824
  • 17
  • 99
  • 186
Martin
  • 23,844
  • 55
  • 201
  • 327
  • I have the same question. I want to run /usr/bin/sudo /usr/sbin/nvram boot-args="-v" but get exception [General] Couldn't posix_spawn: error 1 – Tomachi Sep 06 '19 at 05:33

1 Answers1

1

The normal way to do this is by using a helper program to make the required changes and then requesting administrator privileges when the helper is run.

See this question for some more information on requesting admin privileges.

Community
  • 1
  • 1
David Berry
  • 40,941
  • 12
  • 84
  • 95