Wednesday, 15 September 2010

c++ - Exec program that needs sudo privilages -



c++ - Exec program that needs sudo privilages -

so end goal run programme on beaglebone black on boot (add init file) exec other programs. other programs beingness started need sudo privileges start. research, have seen couple of ways don't know 1 "correct". point me in right direction?

here code testing right start 1 of many programs:

#include <iostream> #include <unistd.h> using std::cout; using std::cin; int main() { pid_t pid; pid = fork(); if (0 == pid) { setreuid(geteuid(), getuid()); execl("/usr/local/bin/osmo-trx", "osmo-trx", "-f", null); cout << "\n\n***something went wrong starting osmo-trx***\n\n"; } else if (0 < pid) ; else { cout << "\n\nsomething went wrong...\n\n"; homecoming -1; } homecoming 0; }

i'm having problem figuring out right question. here have though may way off path should take.

can exec programme sudo privileges? tried the uid no luck.

if give debian user root privileges, able run program? tried editing visudo , adding debian no success. below file:

# # file must edited 'visudo' command root. # # please consider adding local content in /etc/sudoers.d/ instead of # straight modifying file. # # see man page details on how write sudoers file. # defaults env_reset defaults mail_badpass defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" # host alias specification # user alias specification # cmnd alias specification # user privilege specification root all=(all:all) debian all=(all:all) # allow members of grouping sudo execute command %sudo all=(all:all) # see sudoers(5) more info on "#include" directives: #includedir /etc/sudoers.d %admin all=(all) all</code>

--note: sorry epic indentation editor giving me problem highlighting code.--

please help...

c++ linux debian exec sudo

No comments:

Post a Comment