Add a FreeBSD user from c++

Is it possible to add a user without function
Code:
int system ( const char * command );
and how can I use this user in my application? E.g. this user has a username and a password and I want when I run the application to use the username and password for login in my application. Or I can add this user with
Code:
int system ( const char * command );
but how can I use the username and password for login in my application?
 
To create a new user, you can simply add a proper line in /etc/master.passwd (*), a proper line in /etc/group and create a proper user's home by creating the proper folder and copying in that the whole contents of /usr/share/skel, but renaming all the "dot.*" files in ".*". Remember to properly adjust the home permissions.

(*) You can choose the user's password by generating the proper hash string or leaving it blank and, after the user creation, calling system("passwd ...").

The abuse of the word "properly" is not a coincidence!
 
BARz said:
To create a new user, you can simply add a proper line in /etc/master.passwd (*), a proper line in /etc/group and create a proper user's home by creating the proper folder and copying in that the whole contents of /usr/share/skel, but renaming all the "dot.*" files in ".*". Remember to properly adjust the home permissions.
You also have to rebuild the user databases with pwd_mkdb(8).
 
Back
Top