0

I am working on a simple C/C++ project in which I have to collect a bunch of files from a bunch of macOS specific directories. But some directories/files require root access. I know that I can open it from the terminal. But I want to know if there is a way to elevate to root when the app starts.

Shawn
  • 47,241
  • 3
  • 26
  • 60

1 Answers1

2

It's not possible to access files without the correct file permissions for that user.

  • Can't I elevate the app's privileges to root in order to access for example /private/var/db/launchd.db/subfolders? –  Dec 17 '18 at 13:26
  • 1
    You could run with sudo basically giving the progress root access, this would give your program access to all the files on the system. – James Hudson Dec 17 '18 at 13:33
  • I know that I can run it with sudo. But I want something that prompts the user for their password and uses it to grant access in those locked directories. –  Dec 17 '18 at 13:35
  • 2
    https://github.com/michaelvobrien/OSXSimpleAuth/wiki - This is a guide on asking for root access on OSX. I haven't used it myself but looks complete. Also has examples – James Hudson Dec 17 '18 at 13:47
  • Thank you for your time! I will look at it. –  Dec 17 '18 at 13:48
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://superuser.com/help/whats-reputation) you will be able to [comment on any post](https://superuser.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/low-quality-posts/815725) – Blackwood Dec 17 '18 at 14:08
  • 3
    Umm, ```sudo``` ***does*** prompt the user for their password and grant root access. Why is it not an acceptable answer? – Scott - Слава Україні Dec 17 '18 at 14:35
  • I want to ask the user for their password with the authorization plugin ( with a GUI ), not from the terminal. – Ivelin Krastev Dec 18 '18 at 07:23