Mercurial > dovecot > original-hg > dovecot-1.2
annotate src/auth/userdb.c @ 9008:fc4f65a4ca60 HEAD
virtual: Don't show mailboxes as \Noselect.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Fri, 01 May 2009 14:56:52 -0400 |
parents | 4aa05d7d8b07 |
children | 00cd9aacd03c |
rev | line source |
---|---|
8590
b9faf4db2a9f
Updated copyright notices to include year 2009.
Timo Sirainen <tss@iki.fi>
parents:
8513
diff
changeset
|
1 /* Copyright (c) 2002-2009 Dovecot authors, see the included COPYING file */ |
1035
fe49ece0f3ea
We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
2 |
fe49ece0f3ea
We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
3 #include "common.h" |
6187
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
4 #include "array.h" |
3638
4e55969a6a93
Don't crash if we have blocking userdb but non-blocking passdb.
Timo Sirainen <tss@iki.fi>
parents:
3520
diff
changeset
|
5 #include "auth-worker-server.h" |
1035
fe49ece0f3ea
We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
6 #include "userdb.h" |
fe49ece0f3ea
We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
7 |
fe49ece0f3ea
We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
8 #include <stdlib.h> |
3043
8b80b69938f0
If UID or GID isn't numeric, look it up from passwd/group.
Timo Sirainen <tss@iki.fi>
parents:
2942
diff
changeset
|
9 #include <pwd.h> |
8b80b69938f0
If UID or GID isn't numeric, look it up from passwd/group.
Timo Sirainen <tss@iki.fi>
parents:
2942
diff
changeset
|
10 #include <grp.h> |
1035
fe49ece0f3ea
We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
11 |
6187
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
12 static ARRAY_DEFINE(userdb_interfaces, struct userdb_module_interface *); |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
13 |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
14 static struct userdb_module_interface *userdb_interface_find(const char *name) |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
15 { |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
16 struct userdb_module_interface *const *ifaces; |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
17 unsigned int i, count; |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
18 |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
19 ifaces = array_get(&userdb_interfaces, &count); |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
20 for (i = 0; i < count; i++) { |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
21 if (strcmp(ifaces[i]->name, name) == 0) |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
22 return ifaces[i]; |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
23 } |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
24 return NULL; |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
25 } |
3066
34c1cf646467
Moved extern userdb/passdb declarations to .c files.
Timo Sirainen <tss@iki.fi>
parents:
3065
diff
changeset
|
26 |
6187
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
27 void userdb_register_module(struct userdb_module_interface *iface) |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
28 { |
8888
4aa05d7d8b07
auth: Fixed loading known passdb/userdb plugins.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
29 struct userdb_module_interface *old_iface; |
4aa05d7d8b07
auth: Fixed loading known passdb/userdb plugins.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
30 |
4aa05d7d8b07
auth: Fixed loading known passdb/userdb plugins.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
31 old_iface = userdb_interface_find(iface->name); |
4aa05d7d8b07
auth: Fixed loading known passdb/userdb plugins.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
32 if (old_iface != NULL && old_iface->lookup == NULL) { |
4aa05d7d8b07
auth: Fixed loading known passdb/userdb plugins.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
33 /* replacing a "support not compiled in" userdb */ |
4aa05d7d8b07
auth: Fixed loading known passdb/userdb plugins.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
34 userdb_unregister_module(old_iface); |
4aa05d7d8b07
auth: Fixed loading known passdb/userdb plugins.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
35 } else if (old_iface != NULL) { |
6187
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
36 i_panic("userdb_register_module(%s): Already registered", |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
37 iface->name); |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
38 } |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
39 array_append(&userdb_interfaces, &iface, 1); |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
40 } |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
41 |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
42 void userdb_unregister_module(struct userdb_module_interface *iface) |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
43 { |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
44 struct userdb_module_interface *const *ifaces; |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
45 unsigned int i, count; |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
46 |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
47 ifaces = array_get(&userdb_interfaces, &count); |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
48 for (i = 0; i < count; i++) { |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
49 if (ifaces[i] == iface) { |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
50 array_delete(&userdb_interfaces, i, 1); |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
51 return; |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
52 } |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
53 } |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
54 i_panic("userdb_unregister_module(%s): Not registered", iface->name); |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
55 } |
2942
c7d426f8cb58
Added name variable for userdb_module and passdb_module and changed their
Timo Sirainen <tss@iki.fi>
parents:
2754
diff
changeset
|
56 |
3043
8b80b69938f0
If UID or GID isn't numeric, look it up from passwd/group.
Timo Sirainen <tss@iki.fi>
parents:
2942
diff
changeset
|
57 uid_t userdb_parse_uid(struct auth_request *request, const char *str) |
8b80b69938f0
If UID or GID isn't numeric, look it up from passwd/group.
Timo Sirainen <tss@iki.fi>
parents:
2942
diff
changeset
|
58 { |
8b80b69938f0
If UID or GID isn't numeric, look it up from passwd/group.
Timo Sirainen <tss@iki.fi>
parents:
2942
diff
changeset
|
59 struct passwd *pw; |
5874
5fa84de81413
Allow uid/gid names that begin with numbers, as long as it's not completely
Timo Sirainen <tss@iki.fi>
parents:
5873
diff
changeset
|
60 uid_t uid; |
5fa84de81413
Allow uid/gid names that begin with numbers, as long as it's not completely
Timo Sirainen <tss@iki.fi>
parents:
5873
diff
changeset
|
61 char *p; |
3043
8b80b69938f0
If UID or GID isn't numeric, look it up from passwd/group.
Timo Sirainen <tss@iki.fi>
parents:
2942
diff
changeset
|
62 |
3520 | 63 if (str == NULL) |
64 return (uid_t)-1; | |
65 | |
5874
5fa84de81413
Allow uid/gid names that begin with numbers, as long as it's not completely
Timo Sirainen <tss@iki.fi>
parents:
5873
diff
changeset
|
66 if (*str >= '0' && *str <= '9') { |
5fa84de81413
Allow uid/gid names that begin with numbers, as long as it's not completely
Timo Sirainen <tss@iki.fi>
parents:
5873
diff
changeset
|
67 uid = (uid_t)strtoul(str, &p, 10); |
5fa84de81413
Allow uid/gid names that begin with numbers, as long as it's not completely
Timo Sirainen <tss@iki.fi>
parents:
5873
diff
changeset
|
68 if (*p == '\0') |
5fa84de81413
Allow uid/gid names that begin with numbers, as long as it's not completely
Timo Sirainen <tss@iki.fi>
parents:
5873
diff
changeset
|
69 return uid; |
5fa84de81413
Allow uid/gid names that begin with numbers, as long as it's not completely
Timo Sirainen <tss@iki.fi>
parents:
5873
diff
changeset
|
70 } |
3043
8b80b69938f0
If UID or GID isn't numeric, look it up from passwd/group.
Timo Sirainen <tss@iki.fi>
parents:
2942
diff
changeset
|
71 |
8b80b69938f0
If UID or GID isn't numeric, look it up from passwd/group.
Timo Sirainen <tss@iki.fi>
parents:
2942
diff
changeset
|
72 pw = getpwnam(str); |
8b80b69938f0
If UID or GID isn't numeric, look it up from passwd/group.
Timo Sirainen <tss@iki.fi>
parents:
2942
diff
changeset
|
73 if (pw == NULL) { |
8b80b69938f0
If UID or GID isn't numeric, look it up from passwd/group.
Timo Sirainen <tss@iki.fi>
parents:
2942
diff
changeset
|
74 if (request != NULL) { |
3069 | 75 auth_request_log_error(request, "userdb", |
4738 | 76 "Invalid UID value '%s'", str); |
3043
8b80b69938f0
If UID or GID isn't numeric, look it up from passwd/group.
Timo Sirainen <tss@iki.fi>
parents:
2942
diff
changeset
|
77 } |
8b80b69938f0
If UID or GID isn't numeric, look it up from passwd/group.
Timo Sirainen <tss@iki.fi>
parents:
2942
diff
changeset
|
78 return (uid_t)-1; |
8b80b69938f0
If UID or GID isn't numeric, look it up from passwd/group.
Timo Sirainen <tss@iki.fi>
parents:
2942
diff
changeset
|
79 } |
8b80b69938f0
If UID or GID isn't numeric, look it up from passwd/group.
Timo Sirainen <tss@iki.fi>
parents:
2942
diff
changeset
|
80 return pw->pw_uid; |
8b80b69938f0
If UID or GID isn't numeric, look it up from passwd/group.
Timo Sirainen <tss@iki.fi>
parents:
2942
diff
changeset
|
81 } |
8b80b69938f0
If UID or GID isn't numeric, look it up from passwd/group.
Timo Sirainen <tss@iki.fi>
parents:
2942
diff
changeset
|
82 |
8b80b69938f0
If UID or GID isn't numeric, look it up from passwd/group.
Timo Sirainen <tss@iki.fi>
parents:
2942
diff
changeset
|
83 gid_t userdb_parse_gid(struct auth_request *request, const char *str) |
8b80b69938f0
If UID or GID isn't numeric, look it up from passwd/group.
Timo Sirainen <tss@iki.fi>
parents:
2942
diff
changeset
|
84 { |
8b80b69938f0
If UID or GID isn't numeric, look it up from passwd/group.
Timo Sirainen <tss@iki.fi>
parents:
2942
diff
changeset
|
85 struct group *gr; |
5874
5fa84de81413
Allow uid/gid names that begin with numbers, as long as it's not completely
Timo Sirainen <tss@iki.fi>
parents:
5873
diff
changeset
|
86 gid_t gid; |
5fa84de81413
Allow uid/gid names that begin with numbers, as long as it's not completely
Timo Sirainen <tss@iki.fi>
parents:
5873
diff
changeset
|
87 char *p; |
3043
8b80b69938f0
If UID or GID isn't numeric, look it up from passwd/group.
Timo Sirainen <tss@iki.fi>
parents:
2942
diff
changeset
|
88 |
3520 | 89 if (str == NULL) |
5873 | 90 return (gid_t)-1; |
3520 | 91 |
5874
5fa84de81413
Allow uid/gid names that begin with numbers, as long as it's not completely
Timo Sirainen <tss@iki.fi>
parents:
5873
diff
changeset
|
92 if (*str >= '0' && *str <= '9') { |
5fa84de81413
Allow uid/gid names that begin with numbers, as long as it's not completely
Timo Sirainen <tss@iki.fi>
parents:
5873
diff
changeset
|
93 gid = (gid_t)strtoul(str, &p, 10); |
5fa84de81413
Allow uid/gid names that begin with numbers, as long as it's not completely
Timo Sirainen <tss@iki.fi>
parents:
5873
diff
changeset
|
94 if (*p == '\0') |
5fa84de81413
Allow uid/gid names that begin with numbers, as long as it's not completely
Timo Sirainen <tss@iki.fi>
parents:
5873
diff
changeset
|
95 return gid; |
5fa84de81413
Allow uid/gid names that begin with numbers, as long as it's not completely
Timo Sirainen <tss@iki.fi>
parents:
5873
diff
changeset
|
96 } |
3043
8b80b69938f0
If UID or GID isn't numeric, look it up from passwd/group.
Timo Sirainen <tss@iki.fi>
parents:
2942
diff
changeset
|
97 |
8b80b69938f0
If UID or GID isn't numeric, look it up from passwd/group.
Timo Sirainen <tss@iki.fi>
parents:
2942
diff
changeset
|
98 gr = getgrnam(str); |
8b80b69938f0
If UID or GID isn't numeric, look it up from passwd/group.
Timo Sirainen <tss@iki.fi>
parents:
2942
diff
changeset
|
99 if (gr == NULL) { |
8b80b69938f0
If UID or GID isn't numeric, look it up from passwd/group.
Timo Sirainen <tss@iki.fi>
parents:
2942
diff
changeset
|
100 if (request != NULL) { |
3069 | 101 auth_request_log_error(request, "userdb", |
4738 | 102 "Invalid GID value '%s'", str); |
3043
8b80b69938f0
If UID or GID isn't numeric, look it up from passwd/group.
Timo Sirainen <tss@iki.fi>
parents:
2942
diff
changeset
|
103 } |
8b80b69938f0
If UID or GID isn't numeric, look it up from passwd/group.
Timo Sirainen <tss@iki.fi>
parents:
2942
diff
changeset
|
104 return (gid_t)-1; |
8b80b69938f0
If UID or GID isn't numeric, look it up from passwd/group.
Timo Sirainen <tss@iki.fi>
parents:
2942
diff
changeset
|
105 } |
8b80b69938f0
If UID or GID isn't numeric, look it up from passwd/group.
Timo Sirainen <tss@iki.fi>
parents:
2942
diff
changeset
|
106 return gr->gr_gid; |
8b80b69938f0
If UID or GID isn't numeric, look it up from passwd/group.
Timo Sirainen <tss@iki.fi>
parents:
2942
diff
changeset
|
107 } |
8b80b69938f0
If UID or GID isn't numeric, look it up from passwd/group.
Timo Sirainen <tss@iki.fi>
parents:
2942
diff
changeset
|
108 |
3183
16ea551957ed
Replaced userdb/passdb settings with blocks so it's possible to give
Timo Sirainen <tss@iki.fi>
parents:
3069
diff
changeset
|
109 void userdb_preinit(struct auth *auth, const char *driver, const char *args) |
1035
fe49ece0f3ea
We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
110 { |
6187
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
111 struct userdb_module_interface *iface; |
3183
16ea551957ed
Replaced userdb/passdb settings with blocks so it's possible to give
Timo Sirainen <tss@iki.fi>
parents:
3069
diff
changeset
|
112 struct auth_userdb *auth_userdb, **dest; |
1062
0522a0315d2f
Cleanups, LDAP support compiles again and generally looks ok, even if it
Timo Sirainen <tss@iki.fi>
parents:
1035
diff
changeset
|
113 |
2234
60802bea8f32
Default to "" args instead of NULL to avoid some crashes
Timo Sirainen <tss@iki.fi>
parents:
2232
diff
changeset
|
114 if (args == NULL) args = ""; |
2232
e5684c8c60f9
skip extra whitespace between "dbtype arguments"
Timo Sirainen <tss@iki.fi>
parents:
1995
diff
changeset
|
115 |
3183
16ea551957ed
Replaced userdb/passdb settings with blocks so it's possible to give
Timo Sirainen <tss@iki.fi>
parents:
3069
diff
changeset
|
116 auth_userdb = p_new(auth->pool, struct auth_userdb, 1); |
16ea551957ed
Replaced userdb/passdb settings with blocks so it's possible to give
Timo Sirainen <tss@iki.fi>
parents:
3069
diff
changeset
|
117 auth_userdb->auth = auth; |
16ea551957ed
Replaced userdb/passdb settings with blocks so it's possible to give
Timo Sirainen <tss@iki.fi>
parents:
3069
diff
changeset
|
118 auth_userdb->args = p_strdup(auth->pool, args); |
16ea551957ed
Replaced userdb/passdb settings with blocks so it's possible to give
Timo Sirainen <tss@iki.fi>
parents:
3069
diff
changeset
|
119 |
16ea551957ed
Replaced userdb/passdb settings with blocks so it's possible to give
Timo Sirainen <tss@iki.fi>
parents:
3069
diff
changeset
|
120 for (dest = &auth->userdbs; *dest != NULL; dest = &(*dest)->next) |
16ea551957ed
Replaced userdb/passdb settings with blocks so it's possible to give
Timo Sirainen <tss@iki.fi>
parents:
3069
diff
changeset
|
121 auth_userdb->num++; |
16ea551957ed
Replaced userdb/passdb settings with blocks so it's possible to give
Timo Sirainen <tss@iki.fi>
parents:
3069
diff
changeset
|
122 *dest = auth_userdb; |
2648
cc2e39912eb3
Added preinit() call to userdb/passdbs, which is called before dropping
Timo Sirainen <tss@iki.fi>
parents:
2234
diff
changeset
|
123 |
6187
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
124 iface = userdb_interface_find(driver); |
8217
c47b78e843aa
Separate "unknown passdb/userdb X" and "support for X not compiled in" error messages.
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
125 if (iface == NULL) |
c47b78e843aa
Separate "unknown passdb/userdb X" and "support for X not compiled in" error messages.
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
126 i_fatal("Unknown userdb driver '%s'", driver); |
c47b78e843aa
Separate "unknown passdb/userdb X" and "support for X not compiled in" error messages.
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
127 if (iface->lookup == NULL) { |
c47b78e843aa
Separate "unknown passdb/userdb X" and "support for X not compiled in" error messages.
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
128 i_fatal("Support not compiled in for userdb driver '%s'", |
3748
1649ca519b7d
Give a few helpul suggestions with "Unknown passdb/usedb driver" errors.
Timo Sirainen <tss@iki.fi>
parents:
3667
diff
changeset
|
129 driver); |
1649ca519b7d
Give a few helpul suggestions with "Unknown passdb/usedb driver" errors.
Timo Sirainen <tss@iki.fi>
parents:
3667
diff
changeset
|
130 } |
1035
fe49ece0f3ea
We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
131 |
8513
0691f5294bb9
Fail if trying to give unknown parameters to passdb/userdb.
Timo Sirainen <tss@iki.fi>
parents:
8307
diff
changeset
|
132 if (iface->preinit == NULL && iface->init == NULL && |
0691f5294bb9
Fail if trying to give unknown parameters to passdb/userdb.
Timo Sirainen <tss@iki.fi>
parents:
8307
diff
changeset
|
133 *auth_userdb->args != '\0') { |
0691f5294bb9
Fail if trying to give unknown parameters to passdb/userdb.
Timo Sirainen <tss@iki.fi>
parents:
8307
diff
changeset
|
134 i_fatal("userdb %s: No args are supported: %s", |
0691f5294bb9
Fail if trying to give unknown parameters to passdb/userdb.
Timo Sirainen <tss@iki.fi>
parents:
8307
diff
changeset
|
135 driver, auth_userdb->args); |
0691f5294bb9
Fail if trying to give unknown parameters to passdb/userdb.
Timo Sirainen <tss@iki.fi>
parents:
8307
diff
changeset
|
136 } |
0691f5294bb9
Fail if trying to give unknown parameters to passdb/userdb.
Timo Sirainen <tss@iki.fi>
parents:
8307
diff
changeset
|
137 |
3658
fc4622b1c1ef
Separated userdb_module's interface and the actual data struct.
Timo Sirainen <tss@iki.fi>
parents:
3638
diff
changeset
|
138 if (iface->preinit == NULL) { |
fc4622b1c1ef
Separated userdb_module's interface and the actual data struct.
Timo Sirainen <tss@iki.fi>
parents:
3638
diff
changeset
|
139 auth_userdb->userdb = |
fc4622b1c1ef
Separated userdb_module's interface and the actual data struct.
Timo Sirainen <tss@iki.fi>
parents:
3638
diff
changeset
|
140 p_new(auth->pool, struct userdb_module, 1); |
fc4622b1c1ef
Separated userdb_module's interface and the actual data struct.
Timo Sirainen <tss@iki.fi>
parents:
3638
diff
changeset
|
141 } else { |
fc4622b1c1ef
Separated userdb_module's interface and the actual data struct.
Timo Sirainen <tss@iki.fi>
parents:
3638
diff
changeset
|
142 auth_userdb->userdb = |
fc4622b1c1ef
Separated userdb_module's interface and the actual data struct.
Timo Sirainen <tss@iki.fi>
parents:
3638
diff
changeset
|
143 iface->preinit(auth_userdb, auth_userdb->args); |
fc4622b1c1ef
Separated userdb_module's interface and the actual data struct.
Timo Sirainen <tss@iki.fi>
parents:
3638
diff
changeset
|
144 } |
fc4622b1c1ef
Separated userdb_module's interface and the actual data struct.
Timo Sirainen <tss@iki.fi>
parents:
3638
diff
changeset
|
145 auth_userdb->userdb->iface = iface; |
2648
cc2e39912eb3
Added preinit() call to userdb/passdbs, which is called before dropping
Timo Sirainen <tss@iki.fi>
parents:
2234
diff
changeset
|
146 } |
cc2e39912eb3
Added preinit() call to userdb/passdbs, which is called before dropping
Timo Sirainen <tss@iki.fi>
parents:
2234
diff
changeset
|
147 |
3183
16ea551957ed
Replaced userdb/passdb settings with blocks so it's possible to give
Timo Sirainen <tss@iki.fi>
parents:
3069
diff
changeset
|
148 void userdb_init(struct auth_userdb *userdb) |
2648
cc2e39912eb3
Added preinit() call to userdb/passdbs, which is called before dropping
Timo Sirainen <tss@iki.fi>
parents:
2234
diff
changeset
|
149 { |
3658
fc4622b1c1ef
Separated userdb_module's interface and the actual data struct.
Timo Sirainen <tss@iki.fi>
parents:
3638
diff
changeset
|
150 if (userdb->userdb->iface->init != NULL) |
fc4622b1c1ef
Separated userdb_module's interface and the actual data struct.
Timo Sirainen <tss@iki.fi>
parents:
3638
diff
changeset
|
151 userdb->userdb->iface->init(userdb->userdb, userdb->args); |
3638
4e55969a6a93
Don't crash if we have blocking userdb but non-blocking passdb.
Timo Sirainen <tss@iki.fi>
parents:
3520
diff
changeset
|
152 |
4e55969a6a93
Don't crash if we have blocking userdb but non-blocking passdb.
Timo Sirainen <tss@iki.fi>
parents:
3520
diff
changeset
|
153 if (userdb->userdb->blocking && !worker) { |
4e55969a6a93
Don't crash if we have blocking userdb but non-blocking passdb.
Timo Sirainen <tss@iki.fi>
parents:
3520
diff
changeset
|
154 /* blocking userdb - we need an auth server */ |
4e55969a6a93
Don't crash if we have blocking userdb but non-blocking passdb.
Timo Sirainen <tss@iki.fi>
parents:
3520
diff
changeset
|
155 auth_worker_server_init(); |
4e55969a6a93
Don't crash if we have blocking userdb but non-blocking passdb.
Timo Sirainen <tss@iki.fi>
parents:
3520
diff
changeset
|
156 } |
1035
fe49ece0f3ea
We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
157 } |
fe49ece0f3ea
We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
158 |
3183
16ea551957ed
Replaced userdb/passdb settings with blocks so it's possible to give
Timo Sirainen <tss@iki.fi>
parents:
3069
diff
changeset
|
159 void userdb_deinit(struct auth_userdb *userdb) |
1035
fe49ece0f3ea
We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
160 { |
3658
fc4622b1c1ef
Separated userdb_module's interface and the actual data struct.
Timo Sirainen <tss@iki.fi>
parents:
3638
diff
changeset
|
161 if (userdb->userdb->iface->deinit != NULL) |
fc4622b1c1ef
Separated userdb_module's interface and the actual data struct.
Timo Sirainen <tss@iki.fi>
parents:
3638
diff
changeset
|
162 userdb->userdb->iface->deinit(userdb->userdb); |
1035
fe49ece0f3ea
We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
163 } |
6187
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
164 |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
165 extern struct userdb_module_interface userdb_prefetch; |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
166 extern struct userdb_module_interface userdb_static; |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
167 extern struct userdb_module_interface userdb_passwd; |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
168 extern struct userdb_module_interface userdb_passwd_file; |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
169 extern struct userdb_module_interface userdb_vpopmail; |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
170 extern struct userdb_module_interface userdb_ldap; |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
171 extern struct userdb_module_interface userdb_sql; |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
172 extern struct userdb_module_interface userdb_nss; |
8307
33eae1ca0be0
Added support for userdb checkpassword. Patch by Sascha Wilde.
Timo Sirainen <tss@iki.fi>
parents:
8217
diff
changeset
|
173 extern struct userdb_module_interface userdb_checkpassword; |
6187
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
174 |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
175 void userdbs_init(void) |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
176 { |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
177 i_array_init(&userdb_interfaces, 16); |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
178 userdb_register_module(&userdb_passwd); |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
179 userdb_register_module(&userdb_passwd_file); |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
180 userdb_register_module(&userdb_prefetch); |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
181 userdb_register_module(&userdb_static); |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
182 userdb_register_module(&userdb_vpopmail); |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
183 userdb_register_module(&userdb_ldap); |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
184 userdb_register_module(&userdb_sql); |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
185 userdb_register_module(&userdb_nss); |
8307
33eae1ca0be0
Added support for userdb checkpassword. Patch by Sascha Wilde.
Timo Sirainen <tss@iki.fi>
parents:
8217
diff
changeset
|
186 userdb_register_module(&userdb_checkpassword); |
6187
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
187 } |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
188 |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
189 void userdbs_deinit(void) |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
190 { |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
191 array_free(&userdb_interfaces); |
7c81e6d848f6
Added pass/userdb_register_module() functions and used them to register the
Timo Sirainen <tss@iki.fi>
parents:
5874
diff
changeset
|
192 } |