0a133b26db9b205d7346bd58ef2d80980bdf8cd5
6 // This program will execute the openvpn executable
7 // passing in through the command line parameters
8 // The purpose is to allow openvpn to be executed
9 // as a different user (e.g. root)
11 int main (int argc
, char *argv
[]) {
12 char * const command
= "openvpn";
13 char ** newargv
= malloc (sizeof(char*) * (argc
+ 1));
16 // Transfer the arguments passed in to a new argument array
17 for (arg
= 0; arg
< argc
; arg
++) {
18 newargv
[arg
] = argv
[arg
];
20 // Ensure the argument list is NULL terminated (for execvp)
22 // Ensure the first argument matches the command
25 // Execute the external command
27 execvp (command
, newargv
);
29 // This part of the code shouldn't be reached
30 printf ("Error executing openvpn\n");