Hi ,
I want to create a new user using c program not with unix adduser command .
is it possible to write a cprogram to create a new user account , it should accept username , grouid , group name and all other privilages .
i can use system calls inside c program to do this .
i will execute it in a super user mode .
Many thanks in advance !
Naren
I don't think this is a simple "C" program with a couple of system calls.... It sounds like you're on Linux, so try getting a copy of your distro's source for useradd.
Hi Jim ,
Thanks for your response .
no i am in HP-uX 11i, my requirement is whether i can write a cprogram to create unix user account .
is it possible !
thanks once again .
Narendra
I'm on HPUX as well. Half the time.
Yes it's trivially possible since it's already been done by HP, but I do not know how.
You have a lot of reading and research to do:
Richard Stevens 'Advanced Programming in the UNIX Environment'
Cooper & More 'HP-UX 11i Internals'
What is the reason you can't use existing HP-provided code?
Hi Jim ,
Thanks again for your response .
I can use Hp-provided code , but my requirement is that , i should br be able to accept user input from stdin and create a user .
My client wants a mechanisim where he can create users with his login ( if has given the permission of root ) and not by sys admin or root .
anything else let me know !
thanks once again .
Narendra
Just use the HP program useradd. Have your C program construct a useradd command line and then use system() to run the command.