0
|
1 /* Copyright (C) 2002 Timo Sirainen */
|
|
2
|
|
3 #include "common.h"
|
|
4 #include "userinfo.h"
|
|
5
|
|
6 #include <stdlib.h>
|
|
7
|
|
8 UserInfoModule *userinfo;
|
|
9
|
|
10 void userinfo_init(void)
|
|
11 {
|
|
12 const char *name, *args;
|
|
13
|
|
14 userinfo = NULL;
|
|
15
|
|
16 name = getenv("USERINFO");
|
|
17 if (name == NULL)
|
|
18 i_fatal("USERINFO environment is unset");
|
|
19
|
|
20 #ifdef USERINFO_PASSWD
|
|
21 if (strcasecmp(name, "passwd") == 0)
|
|
22 userinfo = &userinfo_passwd;
|
|
23 #endif
|
|
24 #ifdef USERINFO_SHADOW
|
|
25 if (strcasecmp(name, "shadow") == 0)
|
|
26 userinfo = &userinfo_shadow;
|
|
27 #endif
|
|
28 #ifdef USERINFO_PAM
|
|
29 if (strcasecmp(name, "pam") == 0)
|
|
30 userinfo = &userinfo_pam;
|
|
31 #endif
|
|
32 #ifdef USERINFO_PASSWD_FILE
|
|
33 if (strcasecmp(name, "passwd-file") == 0)
|
|
34 userinfo = &userinfo_passwd_file;
|
|
35 #endif
|
|
36
|
|
37 if (userinfo == NULL)
|
|
38 i_fatal("Unknown userinfo type '%s'", name);
|
|
39
|
|
40 /* initialize */
|
|
41 if (userinfo->init != NULL) {
|
|
42 args = getenv("USERINFO_ARGS");
|
|
43 if (args == NULL) args = "";
|
|
44
|
|
45 userinfo->init(args);
|
|
46 }
|
|
47
|
|
48 if ((auth_methods & AUTH_METHOD_PLAIN) &&
|
|
49 userinfo->verify_plain == NULL)
|
|
50 i_fatal("Userinfo %s doesn't support PLAIN method", name);
|
|
51 if ((auth_methods & AUTH_METHOD_DIGEST_MD5) &&
|
|
52 userinfo->lookup_digest_md5 == NULL)
|
|
53 i_fatal("Userinfo %s doesn't support DIGEST-MD5 method", name);
|
|
54 }
|
|
55
|
|
56 void userinfo_deinit(void)
|
|
57 {
|
|
58 if (userinfo != NULL && userinfo->deinit != NULL)
|
|
59 userinfo->deinit();
|
|
60 }
|