* configure.ac, NEWS: Add LDAP support.
* auth/Makefile.am (libmuauth_la_SOURCES): Add ldap.c. * auth/ldap.c: New file. * include/mailutils/Makefile.am (pkginclude_HEADERS): Add ldap.h. * include/mailutils/ldap.h: New file. * include/mailutils/libcfg.h (mu_ldap_cfg_capa): New extern. * include/mailutils/mu_auth.h (mu_auth_ldap_module): New extern. (MU_AUTH_REGISTER_ALL_MODULES): Register ldap. * libcfg/Makefile.am (libmucfg_la_SOURCES): Add ldap. * libcfg/ldap.c: New file. * libcfg/init.c (cfg_capa_table): Add ldap. * mailbox/gocs.c (mu_gocs_logging_init): Initialize log_facility to default if not specified otherwise. Need to revise this later. * mailbox/version.c (mu_conf_option): Reveal ldap, if supported. * mailbox/mu_auth.c (mu_auth_data_alloc): Add safety checks. Provide reasonable defaults for missing arguments. * mailbox/mutil.c (mutil_parse_field_map): Bugfix - increment by 2 on each loop. * libargp/mu_argp.c (mu_build_argp): Do not bail out if an unknown capability is requested. * include/mailutils/assoc.h (mu_assoc_count): New function. * mailbox/assoc.c: Likewise. * auth/radius.c (_expand_query): Static * mailbox/cfg_lexer.c: Fixed memory management during cloning.
Showing
21 changed files
with
306 additions
and
69 deletions
1 | 2007-11-26 Sergey Poznyakoff <gray@gnu.org.ua> | ||
2 | |||
3 | * configure.ac, NEWS: Add LDAP support. | ||
4 | * auth/Makefile.am (libmuauth_la_SOURCES): Add ldap.c. | ||
5 | * auth/ldap.c: New file. | ||
6 | * include/mailutils/Makefile.am (pkginclude_HEADERS): Add ldap.h. | ||
7 | * include/mailutils/ldap.h: New file. | ||
8 | * include/mailutils/libcfg.h (mu_ldap_cfg_capa): New extern. | ||
9 | * include/mailutils/mu_auth.h (mu_auth_ldap_module): New extern. | ||
10 | (MU_AUTH_REGISTER_ALL_MODULES): Register ldap. | ||
11 | * libcfg/Makefile.am (libmucfg_la_SOURCES): Add ldap. | ||
12 | * libcfg/ldap.c: New file. | ||
13 | * libcfg/init.c (cfg_capa_table): Add ldap. | ||
14 | * mailbox/gocs.c (mu_gocs_logging_init): Initialize log_facility | ||
15 | to default if not specified otherwise. Need to revise this later. | ||
16 | * mailbox/version.c (mu_conf_option): Reveal ldap, if supported. | ||
17 | |||
18 | * mailbox/mu_auth.c (mu_auth_data_alloc): Add safety | ||
19 | checks. Provide reasonable defaults for missing arguments. | ||
20 | * mailbox/mutil.c (mutil_parse_field_map): Bugfix - increment by 2 | ||
21 | on each loop. | ||
22 | |||
23 | * libargp/mu_argp.c (mu_build_argp): Do not bail out if an unknown | ||
24 | capability is requested. | ||
25 | |||
26 | * include/mailutils/assoc.h (mu_assoc_count): New function. | ||
27 | * mailbox/assoc.c: Likewise. | ||
28 | |||
29 | * auth/radius.c (_expand_query): Static | ||
30 | |||
31 | * mailbox/cfg_lexer.c: Fixed memory management during cloning. | ||
32 | |||
1 | 2007-11-24 Sergey Poznyakoff <gray@gnu.org.ua> | 33 | 2007-11-24 Sergey Poznyakoff <gray@gnu.org.ua> |
2 | 34 | ||
3 | Improve debugging. | 35 | Improve debugging. | ... | ... |
1 | GNU mailutils NEWS -- history of user-visible changes. 2007-11-19 | 1 | GNU mailutils NEWS -- history of user-visible changes. 2007-11-26 |
2 | Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. | 2 | Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. |
3 | See the end of file for copying conditions. | 3 | See the end of file for copying conditions. |
4 | 4 | ||
... | @@ -92,6 +92,8 @@ Previous versions incorrectly understood such an URL as `a/b' | ... | @@ -92,6 +92,8 @@ Previous versions incorrectly understood such an URL as `a/b' |
92 | 92 | ||
93 | * Support for new protocols: POPS (pops://) and IMAPS (imaps://), | 93 | * Support for new protocols: POPS (pops://) and IMAPS (imaps://), |
94 | 94 | ||
95 | * LDAP support (authentication and authorization). | ||
96 | |||
95 | * Fixed APOP handling. | 97 | * Fixed APOP handling. |
96 | 98 | ||
97 | * Remove v0.6 compatibility layer. | 99 | * Remove v0.6 compatibility layer. | ... | ... |
auth/ldap.c
0 → 100644
This diff is collapsed.
Click to expand it.
... | @@ -199,7 +199,7 @@ mu_radius_module_init (void *data) | ... | @@ -199,7 +199,7 @@ mu_radius_module_init (void *data) |
199 | return 0; | 199 | return 0; |
200 | } | 200 | } |
201 | 201 | ||
202 | char * | 202 | static char * |
203 | _expand_query (const char *query, const char *ustr, const char *passwd) | 203 | _expand_query (const char *query, const char *ustr, const char *passwd) |
204 | { | 204 | { |
205 | char *p, *q, *res; | 205 | char *p, *q, *res; |
... | @@ -274,7 +274,7 @@ _expand_query (const char *query, const char *ustr, const char *passwd) | ... | @@ -274,7 +274,7 @@ _expand_query (const char *query, const char *ustr, const char *passwd) |
274 | else | 274 | else |
275 | { | 275 | { |
276 | *q++ = '%'; | 276 | *q++ = '%'; |
277 | *q++ = 'u'; | 277 | *q++ = 'p'; |
278 | } | 278 | } |
279 | p++; | 279 | p++; |
280 | break; | 280 | break; | ... | ... |
... | @@ -74,6 +74,7 @@ status_dbm=no | ... | @@ -74,6 +74,7 @@ status_dbm=no |
74 | status_gsasl=no | 74 | status_gsasl=no |
75 | status_mysql=no | 75 | status_mysql=no |
76 | status_pgsql=no | 76 | status_pgsql=no |
77 | status_ldap=no | ||
77 | 78 | ||
78 | dnl Internationalization macros. | 79 | dnl Internationalization macros. |
79 | AM_GNU_GETTEXT([external], [need-ngettext]) | 80 | AM_GNU_GETTEXT([external], [need-ngettext]) |
... | @@ -677,8 +678,29 @@ if test -n "$SQL_MODULES"; then | ... | @@ -677,8 +678,29 @@ if test -n "$SQL_MODULES"; then |
677 | fi]) | 678 | fi]) |
678 | fi | 679 | fi |
679 | 680 | ||
681 | |||
682 | # LDAP support | ||
683 | AC_ARG_WITH(ldap, | ||
684 | AC_HELP_STRING([--with-ldap], | ||
685 | [Configure to work with OpenLDAP]), | ||
686 | [case $withval in | ||
687 | yes) status_ldap=maybe | ||
688 | ;; | ||
689 | no) status_ldap=no | ||
690 | ;; | ||
691 | esac], | ||
692 | [status_ldap=maybe]) | ||
693 | |||
694 | if test $status_ldap = maybe; then | ||
695 | AC_CHECK_LIB(ldap, ldap_bind,[ | ||
696 | status_ldap=yes | ||
697 | AC_DEFINE(WITH_LDAP, 1, [Define to 1 if you want to use -lldap]) | ||
698 | MU_AUTHLIBS="$MU_AUTHLIBS -lldap"], | ||
699 | [status_ldap=no]) | ||
700 | fi | ||
680 | 701 | ||
681 | dnl Virtual domain support | 702 | |
703 | # Virtual domain support | ||
682 | MU_ENABLE_SUPPORT(virtual-domains) | 704 | MU_ENABLE_SUPPORT(virtual-domains) |
683 | AC_SUBST(SITE_VIRTUAL_PWDDIR) | 705 | AC_SUBST(SITE_VIRTUAL_PWDDIR) |
684 | AC_ARG_WITH([virtual-pwddir], | 706 | AC_ARG_WITH([virtual-pwddir], |
... | @@ -709,6 +731,7 @@ MU_ENABLE_SUPPORT(mh, | ... | @@ -709,6 +731,7 @@ MU_ENABLE_SUPPORT(mh, |
709 | BUILD_MH_EXEC_HOOK=mh_finish_install]) | 731 | BUILD_MH_EXEC_HOOK=mh_finish_install]) |
710 | MU_ENABLE_SUPPORT(maildir) | 732 | MU_ENABLE_SUPPORT(maildir) |
711 | 733 | ||
734 | # FIXME: Should be --with-radius | ||
712 | MU_ENABLE_SUPPORT(radius, | 735 | MU_ENABLE_SUPPORT(radius, |
713 | [AC_CHECK_HEADERS([radius/radius.h],, | 736 | [AC_CHECK_HEADERS([radius/radius.h],, |
714 | [mu_cv_enable_radius=no]) | 737 | [mu_cv_enable_radius=no]) |
... | @@ -1051,6 +1074,7 @@ Pthread support................ $status_pthread | ... | @@ -1051,6 +1074,7 @@ Pthread support................ $status_pthread |
1051 | Readline support............... $status_readline | 1074 | Readline support............... $status_readline |
1052 | MySQL support.................. $status_mysql | 1075 | MySQL support.................. $status_mysql |
1053 | PostgreSQL support............. $status_pgsql | 1076 | PostgreSQL support............. $status_pgsql |
1077 | LDAP support................... $status_ldap | ||
1054 | Radius support................. $status_radius | 1078 | Radius support................. $status_radius |
1055 | Support for virtual domains.... $status_virtual_domains | 1079 | Support for virtual domains.... $status_virtual_domains |
1056 | 1080 | ||
... | @@ -1075,6 +1099,7 @@ EOF | ... | @@ -1075,6 +1099,7 @@ EOF |
1075 | [status_pam=$status_pam | 1099 | [status_pam=$status_pam |
1076 | status_ltdl=$status_ltdl | 1100 | status_ltdl=$status_ltdl |
1077 | status_dbm="$status_dbm" | 1101 | status_dbm="$status_dbm" |
1102 | status_ldap=$status_ldap | ||
1078 | status_gnutls=$WITH_GNUTLS | 1103 | status_gnutls=$WITH_GNUTLS |
1079 | status_gsasl=$status_gsasl | 1104 | status_gsasl=$status_gsasl |
1080 | status_gssapi=$WITH_GSSAPI | 1105 | status_gssapi=$WITH_GSSAPI | ... | ... |
... | @@ -40,7 +40,8 @@ int mu_assoc_get_iterator (mu_assoc_t assoc, mu_iterator_t *piterator); | ... | @@ -40,7 +40,8 @@ int mu_assoc_get_iterator (mu_assoc_t assoc, mu_iterator_t *piterator); |
40 | int mu_assoc_remove_ref (mu_assoc_t assoc, void *data); | 40 | int mu_assoc_remove_ref (mu_assoc_t assoc, void *data); |
41 | int mu_assoc_remove (mu_assoc_t assoc, const char *name); | 41 | int mu_assoc_remove (mu_assoc_t assoc, const char *name); |
42 | int mu_assoc_set_free (mu_assoc_t assoc, mu_assoc_free_fn fn); | 42 | int mu_assoc_set_free (mu_assoc_t assoc, mu_assoc_free_fn fn); |
43 | 43 | int mu_assoc_count (mu_assoc_t assoc, size_t *pcount); | |
44 | |||
44 | #ifdef __cplusplus | 45 | #ifdef __cplusplus |
45 | } | 46 | } |
46 | #endif | 47 | #endif | ... | ... |
include/mailutils/ldap.h
0 → 100644
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc. | ||
3 | |||
4 | This library is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU Lesser General Public | ||
6 | License as published by the Free Software Foundation; either | ||
7 | version 3 of the License, or (at your option) any later version. | ||
8 | |||
9 | This library is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | Lesser General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Lesser General | ||
15 | Public License along with this library; if not, write to the | ||
16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
17 | Boston, MA 02110-1301 USA */ | ||
18 | |||
19 | #ifndef _MAILUTILS_LDAP_H | ||
20 | #define _MAILUTILS_LDAP_H | ||
21 | |||
22 | #ifdef __cplusplus | ||
23 | extern "C" { | ||
24 | #endif | ||
25 | |||
26 | struct mu_ldap_module_config | ||
27 | { | ||
28 | int enable; | ||
29 | char *url; | ||
30 | char *base; | ||
31 | char *binddn; | ||
32 | char *passwd; | ||
33 | int tls; | ||
34 | /* FIXME: sasl */ | ||
35 | int debug; | ||
36 | char *getpwnam_filter; | ||
37 | char *getpwuid_filter; | ||
38 | mu_assoc_t field_map; | ||
39 | }; | ||
40 | |||
41 | #ifdef __cplusplus | ||
42 | } | ||
43 | #endif | ||
44 | |||
45 | #endif |
... | @@ -95,6 +95,7 @@ extern struct mu_cfg_capa mu_virtdomain_cfg_capa; | ... | @@ -95,6 +95,7 @@ extern struct mu_cfg_capa mu_virtdomain_cfg_capa; |
95 | extern struct mu_cfg_capa mu_sieve_cfg_capa; | 95 | extern struct mu_cfg_capa mu_sieve_cfg_capa; |
96 | extern struct mu_cfg_capa mu_daemon_cfg_capa; | 96 | extern struct mu_cfg_capa mu_daemon_cfg_capa; |
97 | extern struct mu_cfg_capa mu_auth_cfg_capa; | 97 | extern struct mu_cfg_capa mu_auth_cfg_capa; |
98 | extern struct mu_cfg_capa mu_ldap_cfg_capa; | ||
98 | 99 | ||
99 | #ifdef __cplusplus | 100 | #ifdef __cplusplus |
100 | } | 101 | } | ... | ... |
... | @@ -137,6 +137,7 @@ extern struct mu_auth_module mu_auth_pam_module; | ... | @@ -137,6 +137,7 @@ extern struct mu_auth_module mu_auth_pam_module; |
137 | extern struct mu_auth_module mu_auth_sql_module; | 137 | extern struct mu_auth_module mu_auth_sql_module; |
138 | extern struct mu_auth_module mu_auth_virtual_module; | 138 | extern struct mu_auth_module mu_auth_virtual_module; |
139 | extern struct mu_auth_module mu_auth_radius_module; | 139 | extern struct mu_auth_module mu_auth_radius_module; |
140 | extern struct mu_auth_module mu_auth_ldap_module; | ||
140 | 141 | ||
141 | #define MU_AUTH_REGISTER_ALL_MODULES() do {\ | 142 | #define MU_AUTH_REGISTER_ALL_MODULES() do {\ |
142 | mu_auth_register_module (&mu_auth_generic_module); \ | 143 | mu_auth_register_module (&mu_auth_generic_module); \ |
... | @@ -145,6 +146,7 @@ extern struct mu_auth_module mu_auth_radius_module; | ... | @@ -145,6 +146,7 @@ extern struct mu_auth_module mu_auth_radius_module; |
145 | mu_auth_register_module (&mu_auth_sql_module);\ | 146 | mu_auth_register_module (&mu_auth_sql_module);\ |
146 | mu_auth_register_module (&mu_auth_virtual_module);\ | 147 | mu_auth_register_module (&mu_auth_virtual_module);\ |
147 | mu_auth_register_module (&mu_auth_radius_module);\ | 148 | mu_auth_register_module (&mu_auth_radius_module);\ |
149 | mu_auth_register_module (&mu_auth_ldap_module);\ | ||
148 | } while (0) | 150 | } while (0) |
149 | 151 | ||
150 | #endif | 152 | #endif | ... | ... |
... | @@ -113,17 +113,12 @@ mu_build_argp (const struct argp *template, const char *capa[]) | ... | @@ -113,17 +113,12 @@ mu_build_argp (const struct argp *template, const char *capa[]) |
113 | for (n = 0; capa && capa[n]; n++) | 113 | for (n = 0; capa && capa[n]; n++) |
114 | { | 114 | { |
115 | struct argp_capa *cp = find_capa (capa[n]); | 115 | struct argp_capa *cp = find_capa (capa[n]); |
116 | if (!cp) | 116 | if (cp) |
117 | { | 117 | { |
118 | mu_error (_("INTERNAL ERROR: requested unknown argp " | 118 | ap[nchild] = *cp->child; |
119 | "capability %s (please report)"), | 119 | ap[nchild].group = group++; |
120 | capa[n]); | 120 | nchild++; |
121 | abort (); | ||
122 | } | 121 | } |
123 | ap[nchild] = *cp->child; | ||
124 | ap[nchild].group = group++; | ||
125 | nchild++; | ||
126 | |||
127 | } | 122 | } |
128 | ap[nchild].argp = NULL; | 123 | ap[nchild].argp = NULL; |
129 | 124 | ... | ... |
libcfg/ldap.c
0 → 100644
1 | /* This file is part of GNU Mailutils | ||
2 | Copyright (C) 2007 Free Software Foundation, Inc. | ||
3 | |||
4 | GNU Mailutils is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU General Public License as | ||
6 | published by the Free Software Foundation; either version 3, or (at | ||
7 | your option) any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, but | ||
10 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
16 | */ | ||
17 | |||
18 | #ifdef HAVE_CONFIG_H | ||
19 | # include <config.h> | ||
20 | #endif | ||
21 | #include "mailutils/libcfg.h" | ||
22 | #include "mailutils/mutil.h" | ||
23 | #include "mailutils/ldap.h" | ||
24 | |||
25 | static struct mu_ldap_module_config ldap_settings; | ||
26 | |||
27 | static int | ||
28 | cb_field_map (mu_cfg_locus_t *locus, void *data, char *arg) | ||
29 | { | ||
30 | int err; | ||
31 | int rc = mutil_parse_field_map (arg, &ldap_settings.field_map, &err); | ||
32 | if (rc) | ||
33 | mu_error (_("%s:%d: Error near element %d: %s"), | ||
34 | locus->file, locus->line, err, mu_strerror (rc)); | ||
35 | return 0; | ||
36 | } | ||
37 | |||
38 | static struct mu_cfg_param mu_ldap_param[] = { | ||
39 | { "enable", mu_cfg_bool, &ldap_settings.enable }, | ||
40 | { "url", mu_cfg_string, &ldap_settings.url }, | ||
41 | { "base", mu_cfg_string, &ldap_settings.base }, | ||
42 | { "binddn", mu_cfg_string, &ldap_settings.binddn }, | ||
43 | { "passwd", mu_cfg_string, &ldap_settings.passwd }, | ||
44 | { "tls", mu_cfg_bool, &ldap_settings.tls }, | ||
45 | { "debug", mu_cfg_int, &ldap_settings.debug }, | ||
46 | { "field-map", mu_cfg_callback, NULL, cb_field_map }, | ||
47 | { "getpwnam", mu_cfg_string, &ldap_settings.getpwnam_filter }, | ||
48 | { "getpwuid", mu_cfg_string, &ldap_settings.getpwuid_filter }, | ||
49 | { NULL } | ||
50 | }; | ||
51 | |||
52 | int | ||
53 | mu_ldap_section_parser | ||
54 | (enum mu_cfg_section_stage stage, const mu_cfg_node_t *node, | ||
55 | void *section_data, void *call_data) | ||
56 | { | ||
57 | switch (stage) | ||
58 | { | ||
59 | case mu_cfg_section_start: | ||
60 | ldap_settings.enable = 1; | ||
61 | break; | ||
62 | |||
63 | case mu_cfg_section_end: | ||
64 | mu_gocs_store ("ldap", &ldap_settings); | ||
65 | } | ||
66 | return 0; | ||
67 | } | ||
68 | |||
69 | struct mu_cfg_capa mu_ldap_cfg_capa = { | ||
70 | "ldap", mu_ldap_param, mu_ldap_section_parser | ||
71 | }; |
... | @@ -488,3 +488,26 @@ mu_assoc_get_iterator (mu_assoc_t assoc, mu_iterator_t *piterator) | ... | @@ -488,3 +488,26 @@ mu_assoc_get_iterator (mu_assoc_t assoc, mu_iterator_t *piterator) |
488 | *piterator = iterator; | 488 | *piterator = iterator; |
489 | return 0; | 489 | return 0; |
490 | } | 490 | } |
491 | |||
492 | |||
493 | |||
494 | int | ||
495 | mu_assoc_count (mu_assoc_t assoc, size_t *pcount) | ||
496 | { | ||
497 | mu_iterator_t itr; | ||
498 | int rc; | ||
499 | size_t count; | ||
500 | |||
501 | if (!assoc || !pcount) | ||
502 | return EINVAL; | ||
503 | rc = mu_assoc_get_iterator (assoc, &itr); | ||
504 | if (rc) | ||
505 | return rc; | ||
506 | for (mu_iterator_first (itr); !mu_iterator_is_done (itr); | ||
507 | mu_iterator_next (itr)) | ||
508 | count++; | ||
509 | mu_iterator_destroy (&itr); | ||
510 | *pcount = count; | ||
511 | return 0; | ||
512 | } | ||
513 | ... | ... |
... | @@ -308,18 +308,12 @@ mu_config_create_container (struct mu_cfg_cont **pcont, | ... | @@ -308,18 +308,12 @@ mu_config_create_container (struct mu_cfg_cont **pcont, |
308 | } | 308 | } |
309 | 309 | ||
310 | 310 | ||
311 | #define DUP_SHALLOW 0 | ||
312 | #define DUP_DEEP 1 | ||
313 | |||
314 | struct dup_data | 311 | struct dup_data |
315 | { | 312 | { |
316 | int duptype; | ||
317 | struct mu_cfg_cont *cont; | 313 | struct mu_cfg_cont *cont; |
318 | struct mu_cfg_section **endsect; | ||
319 | }; | 314 | }; |
320 | 315 | ||
321 | static int dup_container (struct mu_cfg_cont **pcont, | 316 | static int dup_container (struct mu_cfg_cont **pcont); |
322 | struct mu_cfg_section **endsect); | ||
323 | 317 | ||
324 | static int | 318 | static int |
325 | _dup_section_action (void *item, void *cbdata) | 319 | _dup_section_action (void *item, void *cbdata) |
... | @@ -328,17 +322,10 @@ _dup_section_action (void *item, void *cbdata) | ... | @@ -328,17 +322,10 @@ _dup_section_action (void *item, void *cbdata) |
328 | struct mu_cfg_cont *cont = item; | 322 | struct mu_cfg_cont *cont = item; |
329 | struct dup_data *pdd = cbdata; | 323 | struct dup_data *pdd = cbdata; |
330 | 324 | ||
331 | switch (pdd->duptype) | 325 | rc = dup_container (&cont); |
332 | { | 326 | if (rc) |
333 | case DUP_DEEP: | 327 | return rc; |
334 | rc = dup_container (&cont, pdd->endsect); | 328 | |
335 | if (rc) | ||
336 | return rc; | ||
337 | break; | ||
338 | |||
339 | case DUP_SHALLOW: | ||
340 | break; | ||
341 | } | ||
342 | if (!pdd->cont->v.section.subsec) | 329 | if (!pdd->cont->v.section.subsec) |
343 | { | 330 | { |
344 | int rc = mu_list_create (&pdd->cont->v.section.subsec); | 331 | int rc = mu_list_create (&pdd->cont->v.section.subsec); |
... | @@ -354,7 +341,7 @@ _dup_param_action (void *item, void *cbdata) | ... | @@ -354,7 +341,7 @@ _dup_param_action (void *item, void *cbdata) |
354 | int rc; | 341 | int rc; |
355 | struct mu_cfg_cont *cont = item; | 342 | struct mu_cfg_cont *cont = item; |
356 | struct dup_data *pdd = cbdata; | 343 | struct dup_data *pdd = cbdata; |
357 | rc = dup_container (&cont, pdd->endsect); | 344 | rc = dup_container (&cont); |
358 | if (rc) | 345 | if (rc) |
359 | return rc; | 346 | return rc; |
360 | if (!pdd->cont->v.section.param) | 347 | if (!pdd->cont->v.section.param) |
... | @@ -367,7 +354,7 @@ _dup_param_action (void *item, void *cbdata) | ... | @@ -367,7 +354,7 @@ _dup_param_action (void *item, void *cbdata) |
367 | } | 354 | } |
368 | 355 | ||
369 | static int | 356 | static int |
370 | dup_container (struct mu_cfg_cont **pcont, struct mu_cfg_section **endsect) | 357 | dup_container (struct mu_cfg_cont **pcont) |
371 | { | 358 | { |
372 | int rc; | 359 | int rc; |
373 | struct mu_cfg_cont *newcont, *oldcont = *pcont; | 360 | struct mu_cfg_cont *newcont, *oldcont = *pcont; |
... | @@ -378,7 +365,6 @@ dup_container (struct mu_cfg_cont **pcont, struct mu_cfg_section **endsect) | ... | @@ -378,7 +365,6 @@ dup_container (struct mu_cfg_cont **pcont, struct mu_cfg_section **endsect) |
378 | return rc; | 365 | return rc; |
379 | 366 | ||
380 | dd.cont = newcont; | 367 | dd.cont = newcont; |
381 | dd.endsect = endsect; | ||
382 | switch (oldcont->type) | 368 | switch (oldcont->type) |
383 | { | 369 | { |
384 | case mu_cfg_cont_section: | 370 | case mu_cfg_cont_section: |
... | @@ -387,14 +373,8 @@ dup_container (struct mu_cfg_cont **pcont, struct mu_cfg_section **endsect) | ... | @@ -387,14 +373,8 @@ dup_container (struct mu_cfg_cont **pcont, struct mu_cfg_section **endsect) |
387 | newcont->v.section.data = oldcont->v.section.data; | 373 | newcont->v.section.data = oldcont->v.section.data; |
388 | newcont->v.section.subsec = NULL; | 374 | newcont->v.section.subsec = NULL; |
389 | newcont->v.section.param = NULL; | 375 | newcont->v.section.param = NULL; |
390 | if (endsect && &oldcont->v.section == *endsect) | ||
391 | dd.duptype = DUP_SHALLOW; | ||
392 | else | ||
393 | dd.duptype = DUP_DEEP; | ||
394 | mu_list_do (oldcont->v.section.subsec, _dup_section_action, &dd); | 376 | mu_list_do (oldcont->v.section.subsec, _dup_section_action, &dd); |
395 | mu_list_do (oldcont->v.section.param, _dup_param_action, &dd); | 377 | mu_list_do (oldcont->v.section.param, _dup_param_action, &dd); |
396 | if (dd.duptype == DUP_SHALLOW) | ||
397 | *endsect = &newcont->v.section; | ||
398 | break; | 378 | break; |
399 | 379 | ||
400 | case mu_cfg_cont_param: | 380 | case mu_cfg_cont_param: |
... | @@ -406,12 +386,29 @@ dup_container (struct mu_cfg_cont **pcont, struct mu_cfg_section **endsect) | ... | @@ -406,12 +386,29 @@ dup_container (struct mu_cfg_cont **pcont, struct mu_cfg_section **endsect) |
406 | } | 386 | } |
407 | 387 | ||
408 | 388 | ||
409 | static int | 389 | static void |
410 | _destroy_container_action (void *item, void *cbdata) | 390 | destroy_list (mu_list_t *plist) |
411 | { | 391 | { |
412 | struct mu_cfg_cont *cont = item; | 392 | mu_list_t list = *plist; |
413 | mu_config_destroy_container (&cont); | 393 | mu_iterator_t itr = NULL; |
414 | return 0; | 394 | |
395 | if (!list) | ||
396 | return; | ||
397 | |||
398 | mu_list_get_iterator (list, &itr); | ||
399 | for (mu_iterator_first (itr); !mu_iterator_is_done (itr); | ||
400 | mu_iterator_next (itr)) | ||
401 | { | ||
402 | struct mu_cfg_cont *cont, *p; | ||
403 | mu_iterator_current (itr, (void**)&cont); | ||
404 | p = cont; | ||
405 | mu_config_destroy_container (&p); | ||
406 | if (!p) | ||
407 | mu_list_remove (list, cont); | ||
408 | } | ||
409 | mu_iterator_destroy (&itr); | ||
410 | if (mu_list_is_empty (list)) | ||
411 | mu_list_destroy (plist); | ||
415 | } | 412 | } |
416 | 413 | ||
417 | void | 414 | void |
... | @@ -419,13 +416,12 @@ mu_config_destroy_container (struct mu_cfg_cont **pcont) | ... | @@ -419,13 +416,12 @@ mu_config_destroy_container (struct mu_cfg_cont **pcont) |
419 | { | 416 | { |
420 | struct mu_cfg_cont *cont = *pcont; | 417 | struct mu_cfg_cont *cont = *pcont; |
421 | unsigned refcount = mu_refcount_dec (cont->refcount); | 418 | unsigned refcount = mu_refcount_dec (cont->refcount); |
419 | /* printf ("destr %p-%s: %d\n", cont, cont->v.section.ident, refcount); */ | ||
422 | switch (cont->type) | 420 | switch (cont->type) |
423 | { | 421 | { |
424 | case mu_cfg_cont_section: | 422 | case mu_cfg_cont_section: |
425 | mu_list_do (cont->v.section.subsec, _destroy_container_action, NULL); | 423 | destroy_list (&cont->v.section.subsec); |
426 | mu_list_destroy (&cont->v.section.subsec); | 424 | destroy_list (&cont->v.section.param); |
427 | mu_list_do (cont->v.section.param, _destroy_container_action, NULL); | ||
428 | mu_list_destroy (&cont->v.section.param); | ||
429 | break; | 425 | break; |
430 | 426 | ||
431 | case mu_cfg_cont_param: | 427 | case mu_cfg_cont_param: |
... | @@ -471,7 +467,8 @@ _clone_action (void *item, void *cbdata) | ... | @@ -471,7 +467,8 @@ _clone_action (void *item, void *cbdata) |
471 | int | 467 | int |
472 | mu_config_clone_container (struct mu_cfg_cont *cont) | 468 | mu_config_clone_container (struct mu_cfg_cont *cont) |
473 | { | 469 | { |
474 | mu_refcount_inc (cont->refcount); | 470 | int n = mu_refcount_inc (cont->refcount); |
471 | /* printf("clone %p-%s: %d\n", cont, cont->v.section.ident, n); */ | ||
475 | switch (cont->type) | 472 | switch (cont->type) |
476 | { | 473 | { |
477 | case mu_cfg_cont_section: | 474 | case mu_cfg_cont_section: |
... | @@ -520,9 +517,19 @@ _mu_config_register_section (struct mu_cfg_cont **proot, | ... | @@ -520,9 +517,19 @@ _mu_config_register_section (struct mu_cfg_cont **proot, |
520 | if (mu_refcount_value ((*proot)->refcount) > 1) | 517 | if (mu_refcount_value ((*proot)->refcount) > 1) |
521 | { | 518 | { |
522 | /* It is a clone, do copy-on-write */ | 519 | /* It is a clone, do copy-on-write */ |
523 | rc = dup_container (proot, &parent); | 520 | rc = dup_container (proot); |
524 | if (rc) | 521 | if (rc) |
525 | return rc; | 522 | return rc; |
523 | |||
524 | root_section = &(*proot)->v.section; | ||
525 | |||
526 | if (parent_path) | ||
527 | { | ||
528 | if (mu_cfg_find_section (root_section, parent_path, &parent)) | ||
529 | return MU_ERR_NOENT; | ||
530 | } | ||
531 | else | ||
532 | parent = root_section; | ||
526 | } | 533 | } |
527 | 534 | ||
528 | if (ident) | 535 | if (ident) |
... | @@ -730,12 +737,11 @@ _mu_parse_config (char *file, char *progname, | ... | @@ -730,12 +737,11 @@ _mu_parse_config (char *file, char *progname, |
730 | static struct mu_cfg_param empty_param = { NULL }; | 737 | static struct mu_cfg_param empty_param = { NULL }; |
731 | if (!progparam) | 738 | if (!progparam) |
732 | progparam = &empty_param; | 739 | progparam = &empty_param; |
740 | |||
733 | _mu_config_register_section (&cont, NULL, "program", prog_parser, | 741 | _mu_config_register_section (&cont, NULL, "program", prog_parser, |
734 | progname, | 742 | progname, |
735 | progparam, &prog_sect); | 743 | progparam, &prog_sect); |
736 | 744 | ||
737 | mu_config_clone_container (old_root); | ||
738 | |||
739 | if (old_root->v.section.subsec) | 745 | if (old_root->v.section.subsec) |
740 | { | 746 | { |
741 | if (!prog_sect->subsec) | 747 | if (!prog_sect->subsec) |
... | @@ -744,9 +750,9 @@ _mu_parse_config (char *file, char *progname, | ... | @@ -744,9 +750,9 @@ _mu_parse_config (char *file, char *progname, |
744 | for (mu_iterator_first (iter); !mu_iterator_is_done (iter); | 750 | for (mu_iterator_first (iter); !mu_iterator_is_done (iter); |
745 | mu_iterator_next (iter)) | 751 | mu_iterator_next (iter)) |
746 | { | 752 | { |
747 | struct mu_cfg_section *s; | 753 | struct mu_cfg_cont *c; |
748 | mu_iterator_current (iter, (void**)&s); | 754 | mu_iterator_current (iter, (void**)&c); |
749 | mu_list_append (prog_sect->subsec, s); | 755 | mu_list_append (prog_sect->subsec, c); |
750 | } | 756 | } |
751 | mu_iterator_destroy (&iter); | 757 | mu_iterator_destroy (&iter); |
752 | } | 758 | } |
... | @@ -759,9 +765,9 @@ _mu_parse_config (char *file, char *progname, | ... | @@ -759,9 +765,9 @@ _mu_parse_config (char *file, char *progname, |
759 | for (mu_iterator_first (iter); !mu_iterator_is_done (iter); | 765 | for (mu_iterator_first (iter); !mu_iterator_is_done (iter); |
760 | mu_iterator_next (iter)) | 766 | mu_iterator_next (iter)) |
761 | { | 767 | { |
762 | struct mu_cfg_param *p; | 768 | struct mu_cfg_cont *c; |
763 | mu_iterator_current (iter, (void**)&p); | 769 | mu_iterator_current (iter, (void**)&c); |
764 | mu_list_append (prog_sect->param, p); | 770 | mu_list_append (prog_sect->param, c); |
765 | } | 771 | } |
766 | mu_iterator_destroy (&iter); | 772 | mu_iterator_destroy (&iter); |
767 | } | 773 | } | ... | ... |
... | @@ -212,7 +212,11 @@ mu_gocs_logging_init (void *data) | ... | @@ -212,7 +212,11 @@ mu_gocs_logging_init (void *data) |
212 | mu_debug_default_printer = mu_debug_syslog_printer; | 212 | mu_debug_default_printer = mu_debug_syslog_printer; |
213 | } | 213 | } |
214 | else | 214 | else |
215 | mu_debug_default_printer = mu_debug_stderr_printer; | 215 | { |
216 | log_facility = LOG_FACILITY; | ||
217 | mu_debug_default_printer = mu_debug_stderr_printer; | ||
218 | } | ||
219 | |||
216 | /* FIXME: Tag */ | 220 | /* FIXME: Tag */ |
217 | return 0; | 221 | return 0; |
218 | } | 222 | } | ... | ... |
... | @@ -122,14 +122,35 @@ mu_auth_data_alloc (struct mu_auth_data **ptr, | ... | @@ -122,14 +122,35 @@ mu_auth_data_alloc (struct mu_auth_data **ptr, |
122 | const char *mailbox, | 122 | const char *mailbox, |
123 | int change_uid) | 123 | int change_uid) |
124 | { | 124 | { |
125 | size_t size = sizeof (**ptr) + | 125 | size_t size; |
126 | strlen (name) + 1 + | ||
127 | strlen (passwd) + 1 + | ||
128 | strlen (gecos) + 1 + | ||
129 | strlen (dir) + 1 + | ||
130 | strlen (shell) + 1 + | ||
131 | strlen (mailbox) + 1; | ||
132 | char *p; | 126 | char *p; |
127 | char *tmp_mailbox_name = NULL; | ||
128 | |||
129 | if (!name) | ||
130 | return EINVAL; | ||
131 | if (!passwd) | ||
132 | passwd = "x"; | ||
133 | if (!gecos) | ||
134 | gecos = ""; | ||
135 | if (!dir) | ||
136 | dir = "/nonexisting"; | ||
137 | if (!shell) | ||
138 | shell = "/dev/null"; | ||
139 | if (!mailbox) | ||
140 | { | ||
141 | rc = mu_construct_user_mailbox_url (&tmp_mailbox_name, name); | ||
142 | if (rc) | ||
143 | return rc; | ||
144 | mailbox_name = tmp_mailbox_name; | ||
145 | } | ||
146 | |||
147 | size = = sizeof (**ptr) + | ||
148 | strlen (name) + 1 + | ||
149 | strlen (passwd) + 1 + | ||
150 | strlen (gecos) + 1 + | ||
151 | strlen (dir) + 1 + | ||
152 | strlen (shell) + 1 + | ||
153 | strlen (mailbox) + 1; | ||
133 | 154 | ||
134 | *ptr = calloc (1, size); | 155 | *ptr = calloc (1, size); |
135 | if (!*ptr) | 156 | if (!*ptr) |
... | @@ -151,6 +172,8 @@ mu_auth_data_alloc (struct mu_auth_data **ptr, | ... | @@ -151,6 +172,8 @@ mu_auth_data_alloc (struct mu_auth_data **ptr, |
151 | (*ptr)->uid = uid; | 172 | (*ptr)->uid = uid; |
152 | (*ptr)->gid = gid; | 173 | (*ptr)->gid = gid; |
153 | (*ptr)->change_uid = change_uid; | 174 | (*ptr)->change_uid = change_uid; |
175 | |||
176 | free (tmp_mailbox_name); | ||
154 | return 0; | 177 | return 0; |
155 | } | 178 | } |
156 | 179 | ... | ... |
... | @@ -1449,7 +1449,7 @@ mutil_parse_field_map (const char *map, mu_assoc_t *passoc_tab, int *perr) | ... | @@ -1449,7 +1449,7 @@ mutil_parse_field_map (const char *map, mu_assoc_t *passoc_tab, int *perr) |
1449 | return rc; | 1449 | return rc; |
1450 | } | 1450 | } |
1451 | 1451 | ||
1452 | for (i = 0; i < argc; i++) | 1452 | for (i = 0; i < argc; i += 2) |
1453 | { | 1453 | { |
1454 | char *tok = argv[i]; | 1454 | char *tok = argv[i]; |
1455 | char *p = strchr (tok, '='); | 1455 | char *p = strchr (tok, '='); | ... | ... |
... | @@ -86,6 +86,9 @@ static char *mu_conf_option[] = { | ... | @@ -86,6 +86,9 @@ static char *mu_conf_option[] = { |
86 | #ifdef HAVE_PGSQL | 86 | #ifdef HAVE_PGSQL |
87 | "HAVE_PGSQL", | 87 | "HAVE_PGSQL", |
88 | #endif | 88 | #endif |
89 | #ifdef WITH_LDAP | ||
90 | "WITH_LDAP", | ||
91 | #endif | ||
89 | #ifdef ENABLE_VIRTUAL_DOMAINS | 92 | #ifdef ENABLE_VIRTUAL_DOMAINS |
90 | "ENABLE_VIRTUAL_DOMAINS", | 93 | "ENABLE_VIRTUAL_DOMAINS", |
91 | #endif | 94 | #endif | ... | ... |
-
Please register or sign in to post a comment