Commit beb78229 beb782295ca386a70beb0f4374a890e7abfa9216 by Sergey Poznyakoff

Improve debugging in the category "auth".

* libmailutils/auth/mu_auth.c: Fix mu_debug calls. Use different levels.

Remove --debug-auth option.  Users should use --debug-level=auth instead.

* libmu_argp/auth.c: Remove.
* libmu_argp/Makefile.am (libmu_argp_a_SOURCES): Remove auth.c
* include/mailutils/libargp.h (mu_auth_cmdline): Remove.
* libmu_argp/cmdline.c (all_cmdline_capa): Remove mu_auth_cmdline.
1 parent c5f1126f
...@@ -60,7 +60,6 @@ extern struct mu_cmdline_capa mu_tls_cmdline; ...@@ -60,7 +60,6 @@ extern struct mu_cmdline_capa mu_tls_cmdline;
60 extern struct mu_cmdline_capa mu_radius_cmdline; 60 extern struct mu_cmdline_capa mu_radius_cmdline;
61 extern struct mu_cmdline_capa mu_sql_cmdline; 61 extern struct mu_cmdline_capa mu_sql_cmdline;
62 extern struct mu_cmdline_capa mu_virtdomain_cmdline; 62 extern struct mu_cmdline_capa mu_virtdomain_cmdline;
63 extern struct mu_cmdline_capa mu_auth_cmdline;
64 63
65 extern void mu_libargp_init (void); 64 extern void mu_libargp_init (void);
66 65
......
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
55 mu_debug (MU_DEBCAT_AUTH, MU_DEBUG_TRACE, \ 55 mu_debug (MU_DEBCAT_AUTH, MU_DEBUG_TRACE, \
56 ("source=%s, name=%s, passwd=%s, uid=%lu, gid=%lu, " \ 56 ("source=%s, name=%s, passwd=%s, uid=%lu, gid=%lu, " \
57 "gecos=%s, dir=%s, shell=%s, mailbox=%s, quota=%lu, " \ 57 "gecos=%s, dir=%s, shell=%s, mailbox=%s, quota=%lu, " \
58 "change_uid=%d\n", \ 58 "change_uid=%d", \
59 S ((a)->source), \ 59 S ((a)->source), \
60 S ((a)->name), \ 60 S ((a)->name), \
61 S ((a)->passwd), \ 61 S ((a)->passwd), \
...@@ -191,11 +191,11 @@ mu_auth_runlist (mu_list_t flist, struct mu_auth_data **return_data, ...@@ -191,11 +191,11 @@ mu_auth_runlist (mu_list_t flist, struct mu_auth_data **return_data,
191 mu_iterator_next (itr)) 191 mu_iterator_next (itr))
192 { 192 {
193 mu_iterator_current (itr, (void **)&ep); 193 mu_iterator_current (itr, (void **)&ep);
194 mu_debug (MU_DEBCAT_AUTH, MU_DEBUG_TRACE, 194 mu_debug (MU_DEBCAT_AUTH, MU_DEBUG_TRACE2,
195 ("Trying %s...", ep->name)); 195 ("Trying %s...", ep->name));
196 rc = ep->fun (return_data, key, ep->func_data, data); 196 rc = ep->fun (return_data, key, ep->func_data, data);
197 mu_debug (MU_DEBCAT_AUTH, MU_DEBUG_TRACE, 197 mu_debug (MU_DEBCAT_AUTH, MU_DEBUG_TRACE2,
198 ("result: %d=%s\n", rc, mu_strerror (rc))); 198 ("%s yields %d=%s", ep->name, rc, mu_strerror (rc)));
199 if (rc == 0) 199 if (rc == 0)
200 { 200 {
201 if (return_data) 201 if (return_data)
...@@ -244,13 +244,13 @@ mu_get_auth (struct mu_auth_data **auth, enum mu_auth_key_type type, ...@@ -244,13 +244,13 @@ mu_get_auth (struct mu_auth_data **auth, enum mu_auth_key_type type,
244 switch (type) 244 switch (type)
245 { 245 {
246 case mu_auth_key_name: 246 case mu_auth_key_name:
247 mu_debug (MU_DEBCAT_AUTH, MU_DEBUG_TRACE, 247 mu_debug (MU_DEBCAT_AUTH, MU_DEBUG_TRACE1,
248 ("Getting auth info for user %s", (char*) key)); 248 ("Getting auth info for user %s", (char*) key));
249 list = mu_auth_by_name_list; 249 list = mu_auth_by_name_list;
250 break; 250 break;
251 251
252 case mu_auth_key_uid: 252 case mu_auth_key_uid:
253 mu_debug (MU_DEBCAT_AUTH, MU_DEBUG_TRACE, 253 mu_debug (MU_DEBCAT_AUTH, MU_DEBUG_TRACE1,
254 ("Getting auth info for UID %lu", 254 ("Getting auth info for UID %lu",
255 (unsigned long) *(uid_t*) key)); 255 (unsigned long) *(uid_t*) key));
256 list = mu_auth_by_uid_list; 256 list = mu_auth_by_uid_list;
...@@ -289,8 +289,8 @@ mu_authenticate (struct mu_auth_data *auth_data, const char *pass) ...@@ -289,8 +289,8 @@ mu_authenticate (struct mu_auth_data *auth_data, const char *pass)
289 { 289 {
290 if (!auth_data) 290 if (!auth_data)
291 return EINVAL; 291 return EINVAL;
292 mu_debug (MU_DEBCAT_AUTH, MU_DEBUG_TRACE, 292 mu_debug (MU_DEBCAT_AUTH, MU_DEBUG_TRACE1,
293 ("mu_authenticate, user %s, source %s\n", 293 ("mu_authenticate, user %s, source %s",
294 auth_data->name, auth_data->source)); 294 auth_data->name, auth_data->source));
295 if (!mu_authenticate_list) 295 if (!mu_authenticate_list)
296 mu_auth_begin_setup (); 296 mu_auth_begin_setup ();
......
...@@ -25,7 +25,6 @@ AM_CPPFLAGS = \ ...@@ -25,7 +25,6 @@ AM_CPPFLAGS = \
25 lib_LIBRARIES = libmu_argp.a 25 lib_LIBRARIES = libmu_argp.a
26 26
27 libmu_argp_a_SOURCES =\ 27 libmu_argp_a_SOURCES =\
28 auth.c\
29 cmdline.c\ 28 cmdline.c\
30 cmdline.h\ 29 cmdline.h\
31 common.c\ 30 common.c\
......
1 /* GNU Mailutils -- a suite of utilities for electronic mail
2 Copyright (C) 2007, 2009, 2010 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, see
16 <http://www.gnu.org/licenses/>. */
17
18 #ifdef HAVE_CONFIG_H
19 # include <config.h>
20 #endif
21 #include "cmdline.h"
22 #include "mailutils/mu_auth.h"
23
24
25 /* ************************************************************************* */
26 /* Traditional configuration */
27 /* ************************************************************************* */
28
29 enum {
30 OPT_DEBUG_AUTH=256
31 };
32
33 static error_t mu_auth_argp_parser (int key, char *arg,
34 struct argp_state *state);
35
36 /* Options used by programs that use extended authentication mechanisms. */
37 static struct argp_option mu_auth_argp_option[] = {
38 { "debug-auth", OPT_DEBUG_AUTH, NULL, 0,
39 N_("debug authentication functions") },
40 { NULL, 0, NULL, 0, NULL, 0 }
41 };
42
43 static struct argp mu_auth_argp = {
44 mu_auth_argp_option,
45 mu_auth_argp_parser,
46 };
47
48 static struct argp_child mu_auth_argp_child = {
49 &mu_auth_argp,
50 0,
51 NULL,
52 0
53 };
54
55 static error_t
56 mu_auth_argp_parser (int key, char *arg, struct argp_state *state)
57 {
58 static mu_list_t lst;
59
60 switch (key)
61 {
62 case ARGP_KEY_INIT:
63 mu_argp_node_list_init (&lst);
64 break;
65
66 case ARGP_KEY_FINI:
67 mu_argp_node_list_finish (lst, "auth", NULL);
68 break;
69
70 case OPT_DEBUG_AUTH:
71 mu_debug_set_category_level (MU_DEBCAT_AUTH,
72 MU_DEBUG_LEVEL_UPTO (MU_DEBUG_TRACE7));
73 break;
74
75 default:
76 return ARGP_ERR_UNKNOWN;
77 }
78 return 0;
79 }
80
81 struct mu_cmdline_capa mu_auth_cmdline = {
82 "auth", &mu_auth_argp_child
83 };
...@@ -27,7 +27,6 @@ static struct mu_cmdline_capa *all_cmdline_capa[] = { ...@@ -27,7 +27,6 @@ static struct mu_cmdline_capa *all_cmdline_capa[] = {
27 &mu_mailer_cmdline, 27 &mu_mailer_cmdline,
28 &mu_debug_cmdline, 28 &mu_debug_cmdline,
29 &mu_tls_cmdline, 29 &mu_tls_cmdline,
30 &mu_auth_cmdline,
31 &mu_sieve_cmdline, 30 &mu_sieve_cmdline,
32 NULL 31 NULL
33 }; 32 };
......