LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   calling UNIX commands C/C++ (https://www.linuxquestions.org/questions/programming-9/calling-unix-commands-c-c-710693/)

Asteroid 03-11-2009 04:15 AM

calling UNIX commands C/C++
 
hi Guys,

I am planning to write a program which can be able to execute scripts/commands which needs a user to be root.

Note: we are not interested to use sudoers option.

.e.g. The requirement can be explaind as:

Quote:

/opt/VRTS/bin/hastatus -sum
A normal UNIX system user cannot execute above command(veritas cluster summary command) root previleages are required for its executions. so facilitating normal users (who donot know root passwords) to execute above command we can adopt a program. The program knows root password and should internally execute the above command.
A sample program could be like below. I need to know how and where to provide root password.

Any suggestions.

Code:


#include"stdlib.h"
void main()
{

string root_passwd= "mypassword123";
system("/opt/VRTS/bin/hastatus -sum");

}

Thanks and Regards
@ asteroid

abolishtheun 03-11-2009 05:49 AM

having the root password as a string in the program is a ridiculous idea; is setuid what you're looking for?


All times are GMT -5. The time now is 06:03 AM.