View Single Post
Schturman's Avatar
Posts: 5,339 | Thanked: 4,133 times | Joined on Jan 2010 @ Israel
#9
Originally Posted by meShell View Post
setuid( 0 )

It is possible, I am using this "helper" to start my "vpnc" with a GUI-Button, because I did not get a response and did not find any "recommended way to run as privileged" via Sailfis-App.

So there are 3 steps.
  • compile helper program
  • change owner to root:root
  • change permissions to 4755


Example (added example with 2 commands seperated by "&&"):

Code:
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>

int main()
{
   setuid( 0 );
   system( "/usr/sbin/vpnc && /sbin/ip route add xxx.xxx.x.0/24 dev tun0);

   return 0;
}
compiled it with gcc on the phone like this:

Code:
gcc vpnc-helper.c -o vpnc-helper
devel-su
chown root:root vpnc-helper
chmod 4755 vpnc-helper
Hmmm, thanks... don't sure If I understand it correctly, I need to create this files like your vpnc-helper to each command that I need to run as ROOT when I under USER?
For example in script included commands:
root command
user command
user command
root command
user command
Each root command is a different command, that mean I need a different my-helper files ?
And how I implement this and how to run this file in the script ?