Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I add a unix user from C++?? 1

Status
Not open for further replies.

brendan11

Programmer
Jul 16, 2001
10
IE
Folks,
Is it possible to create a new unix user account from within a C++ program that is not running as root? And if so How??
Thanks.
 
No, it's not possible. Unless you hack the system, of course ;-)
 
brendan11,

It is possible if root owns the executable image and the set UID bit is set on the file permissions. (Do a man on chmod to see how to do this. I believe it is chmod 1xxx, but am not sure.)

When this bit is set **anyone** running the program will execute it as if they were root. This is what the "passwd" command does to allow an ordinary user to modify the /etc/passwd file when they set their password.

The catch is, of course, that root must originally set this up with the chmod command.

Hope this helps.

Brudnakm

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top