Commit | Line | Data |
---|---|---|
b0322a85 CE |
1 | /* |
2 | ** Copyright 1998 - 1999 Double Precision, Inc. See COPYING for | |
3 | ** distribution information. | |
4 | */ | |
5 | ||
6 | #if HAVE_CONFIG_H | |
7 | #include "courier_auth_config.h" | |
8 | #endif | |
9 | #include <stdio.h> | |
10 | #include <stdlib.h> | |
11 | #include <string.h> | |
12 | #include <errno.h> | |
13 | #include <pwd.h> | |
14 | #if HAVE_UNISTD_H | |
15 | #include <unistd.h> | |
16 | #endif | |
17 | ||
18 | #include "auth.h" | |
19 | #include "authsqlite.h" | |
20 | ||
21 | int auth_sqlite_pre(const char *user, const char *service, | |
22 | int (*callback)(struct authinfo *, void *), void *arg) | |
23 | { | |
24 | struct authsqliteuserinfo *authinfo; | |
25 | struct authinfo aa; | |
26 | ||
27 | authinfo=auth_sqlite_getuserinfo(user, service); | |
28 | ||
29 | if (!authinfo) /* Fatal error - such as Sqlite being down */ | |
30 | return (1); | |
31 | ||
32 | if (!authinfo->home) /* User not found */ | |
33 | return (-1); | |
34 | ||
35 | memset(&aa, 0, sizeof(aa)); | |
36 | ||
37 | /*aa.sysusername=user;*/ | |
38 | aa.sysuserid= &authinfo->uid; | |
39 | aa.sysgroupid= authinfo->gid; | |
40 | aa.homedir=authinfo->home; | |
41 | aa.maildir=authinfo->maildir && authinfo->maildir[0] ? | |
42 | authinfo->maildir:0; | |
43 | aa.address=authinfo->username; | |
44 | aa.passwd=authinfo->cryptpw; | |
45 | aa.clearpasswd=authinfo->clearpw; | |
46 | aa.fullname=authinfo->fullname; | |
47 | aa.quota=authinfo->quota && authinfo->quota[0] ? | |
48 | authinfo->quota:0; | |
49 | aa.options=authinfo->options; | |
50 | return ((*callback)(&aa, arg)); | |
51 | } |