2 ** Copyright 1998 - 1999 Double Precision, Inc. See COPYING for
3 ** distribution information.
7 #include "courier_auth_config.h"
15 #include "courierauthdebug.h"
21 static const char rcsid
[]="$Id: preauthpam.c,v 1.12 2005/02/20 04:41:20 mrsam Exp $";
23 int auth_pam_pre(const char *userid
, const char *service
,
24 int (*callback
)(struct authinfo
*, void *),
33 memset(&auth
, 0, sizeof(auth
));
35 if ((pw
=getpwnam(userid
)) == 0)
37 if (errno
== ENOMEM
) return (1);
38 DPRINTF("authpam: username '%s' not found in password file", userid
);
43 auth
.sysusername
=userid
;
44 auth
.sysgroupid
=pw
->pw_gid
;
45 auth
.homedir
=pw
->pw_dir
;
47 auth
.fullname
=pw
->pw_gecos
;
48 auth
.passwd
=pw
->pw_passwd
;
51 if ((spw
=getspnam(userid
)) != 0)
52 auth
.passwd
=spw
->sp_pwdp
;
54 courier_authdebug_authinfo("DEBUG: authpam: ", &auth
, 0, pw
->pw_passwd
);
56 return ((*callback
)(&auth
, arg
));