- #1
James889
- 192
- 1
Hi,
I'm trying to write a simple authentication plugin which authenticates a user against /etc/master.passwd.
The problem is the call to getpwnam() which fails with 'no such file or directory'
Relevant code below
Replacing the reference to the username buffer with "<actual username>" works.
Any ideas?
I'm trying to write a simple authentication plugin which authenticates a user against /etc/master.passwd.
The problem is the call to getpwnam() which fails with 'no such file or directory'
Relevant code below
Code:
char username[10];
memset(username,0,sizeof(username));
/* Read the username */
printf("Username:");
fgets(username,sizeof(username),stdin); /* Read the password */
crypt_set_format("sha512");
char *pass;
pass = getpass("password:");
char *p = (char *)calloc(strlen(pass),sizeof(char)); strlcpy(p,crypt(pass,salt),sizeof(p));
struct passwd *local_pass = getpwnam(username);
if( local_pass == NULL){
printf("%s",strerror(errno));
exit(1);
}
Replacing the reference to the username buffer with "<actual username>" works.
Any ideas?