# Add a FreeBSD user from c++



## xnl96 (Dec 11, 2011)

Is it possible to add a user without function 
	
	



```
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 
	
	



```
int system ( const char * command );
```
 but how can I use the username and password for login in my application?


----------



## kpa (Dec 11, 2011)

Look at pam(3). The creation of the users has to be done with external utilities, pw(8) is the standard tool for handling user accounts and groups in FreeBSD.


----------



## Alt (Dec 11, 2011)

Open adduser's source and look xD


----------



## xnl96 (Dec 11, 2011)

Thank you both have been helpful


----------



## BARz (Dec 23, 2011)

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!


----------



## aragon (Dec 25, 2011)

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).


----------

