[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: persistent data with Sun pam



On Thu, Oct 23, 2003 at 09:59:51AM +0200, Gero Wassweiler materna de wrote:
> Hello.
> 
> You can Create a user. Look following code. It's not good,
> but it works. Maybe you've to make some corrections.
> 
> Gero
> 
> ----------------------------------------------------------------
> #include <crypt.h>
> 
> int createuser(char *user, char *passwd)
> {
> 	struct passwd* pwd;
> 	char str[150];
> 	char comment[]= "testuser";
> 	char skeldir[]= "/etc/skel";
> 	char shell[] = "/bin/bash";
> 
> 	if ((pwd = getpwnam(user)) == NULL)
> 	{
> 		sprintf(str,"useradd -d /home/%s -s %s -c %s -m -k %s -p %s
> %s", user, shell, comment, skeldir, \
> 			crypt(password,"az"), user);
> 		system(str);
> 
> 		return 0;
> 	}
> 	
> 	return 0;
> }
> 
> 
The man crypt page suggests the following includes and templates:

#define _XOPEN_SOURCE
#include <unistd.h>

char *crypt(const char *key, const char *salt);

also why do you want  all passwds to have the same salt. Why don't you randomly generate the salts?
-- 
-------------------------------------------
Aaron Konstam
Computer Science
Trinity University
715 Stadium Dr.
San Antonio, TX 78212-7200

telephone: (210)-999-7484
email:akonstam trinity edu




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]