How can I run commands as root?

I want to log in as root using the system call in Xcode. I tried this code without success:

 System("su"); System("alpine"); 

or

 System("su root"); System("alpine"); 

or

 System("su root alpine"); 

When I google, I found out that this is done using NSTask or NSPipe . Can someone tell me how to run multiple system commands using NSTask and NSPipe ?

Please give me some tips about this or another method for this. I use this app on jailbroken iPhone.

More information here .

+4
source share
1 answer

If you want to run something as root, you can use sudo .

Example of use on the same line as the password:

 echo <password> | sudo -S <command> 
+1
source

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


All Articles