Access / private / etc with c

This may be a simple question, but how can I "request" the / root priviliges system from a user in a c console application. I need to write / Private / etc, but I can not. This is for mac / unix.

I saw that it is used in other console commands, for example. when you run the following command: "sudo / System / Library / CoreServices / Finder.app / Contents / MacOS / Finder", Terminal asks for your password. How to do it?

thanks, jnk

+3
source share
3 answers

, root. , seteuid , ( euid uid).

sudo , setuid. , sudo , (root), , . sudo , , . , fork execve .

root , . fork/execve sudo . . , , . .

+5

, Mac, - " ", , , . launchd , .

, , . "", . , , .

, ( ) sudo, . UNIX.

+1

For UNIX systems, you need to have the setuid flag in your program, and it should check / etc / passwd and / etc / shadow for valid credentials. I believe the crypt (3) function is used to hash passwords. Not sure about the Mac.

0
source

Source: https://habr.com/ru/post/1782628/


All Articles