Hello all,
Approx a week back I got the info that I need to use a C program
to execute a command a root for web scripts (PHP).
I have given that a try, I created a
addnewhost.cpp :
#include <stdlib.h>
int main()
{
system("/usr/sbin/useradd newusernewuser");
return 0;
}
Compiled, linked and suid it as (Did this as root)
g++ -c addnewhost.cpp
g++ -o addnewhost.bin addnewhost.o
chown root.root addnewhost.bin
chmod 4755 addnewhost.bin
But when I try to run the addnewhost.bin as a normal user it says
useradd: unable to lock password file
But runs fine as root.
Any clues where should I go next. All I need to do is execute some
command as a superuser but from a PHP page.
Thanks in advance.
Bye.