Commit fdbd31f1 fdbd31f1a9c16c0b71e6baead42bf2ed157fbe59 by Sergey Poznyakoff

Improve debugging.

* imap4d/login.c, pop3d/user.c: Print user db source along with
the login name.
* include/mailutils/debug.h (mu_debug_set_print): Change
prototype.
(mu_debug_printer_fp): New data type.
(mu_debug_default_printer): New extern.
(mu_debug_syslog_printer,mu_debug_stderr_printer): New prototypes.

* libproto/include/debug0.h (struct _mu_debug): Remove unused
`buffer' and `buflen'. Add `stream'. Change signature of `_print' and
rename it to `printer'.
* mailbox/debug.c: Rewrite debugging support.
(mu_debug_default_printer): New global.

* mailbox/gocs.c (mu_gocs_logging_init): Initialize
mu_debug_default_printer.

* mailbox/memory_stream.c (_memory_truncate): Bugfix.
(_memory_get_transport2): Implement method.

* mailbox/Makefile.am (libmailutils_la_SOURCES): Add dbgstderr.c
and dbgsyslog.c
* mailbox/dbgstderr.c, mailbox/dbgsyslog.c: New files.
* maidag/maidag.c, mail.local/main.c, sieve/sieve.c: Remove
_mu_debug_printer, the default implementation will do.

* mailbox/mu_auth.c: Improve debugging.

* libsieve/comparator.c, libsieve/load.c, libsieve/sieve.l:
Include ctype.h

* include/mailutils/libargp.h: Remove option declarations.
* include/mailutils/mu_auth.h (struct mu_auth_data): New member
`source'.
(mu_auth_set_debug): New proto.
* libargp/common.c: Define option values. New option --debug-auth.
* libargp/auth.c, libargp/gsasl.c,
libargp/pam.c, libargp/radius.c, libargp/sieve.c, libargp/sql.c,
libargp/tls.c, libargp/virtdomain.c: Define option values.
1 parent db281aca
2007-11-24 Sergey Poznyakoff <gray@gnu.org.ua>
Improve debugging.
* imap4d/login.c, pop3d/user.c: Print user db source along with
the login name.
* include/mailutils/debug.h (mu_debug_set_print): Change
prototype.
(mu_debug_printer_fp): New data type.
(mu_debug_default_printer): New extern.
(mu_debug_syslog_printer,mu_debug_stderr_printer): New prototypes.
* libproto/include/debug0.h (struct _mu_debug): Remove unused
`buffer' and `buflen'. Add `stream'. Change signature of `_print' and
rename it to `printer'.
* mailbox/debug.c: Rewrite debugging support.
(mu_debug_default_printer): New global.
* mailbox/gocs.c (mu_gocs_logging_init): Initialize
mu_debug_default_printer.
* mailbox/memory_stream.c (_memory_truncate): Bugfix.
(_memory_get_transport2): Implement method.
* mailbox/Makefile.am (libmailutils_la_SOURCES): Add dbgstderr.c
and dbgsyslog.c
* mailbox/dbgstderr.c, mailbox/dbgsyslog.c: New files.
* maidag/maidag.c, mail.local/main.c, sieve/sieve.c: Remove
_mu_debug_printer, the default implementation will do.
* mailbox/mu_auth.c: Improve debugging.
* libsieve/comparator.c, libsieve/load.c, libsieve/sieve.l:
Include ctype.h
* include/mailutils/libargp.h: Remove option declarations.
* include/mailutils/mu_auth.h (struct mu_auth_data): New member
`source'.
(mu_auth_set_debug): New proto.
* libargp/common.c: Define option values. New option --debug-auth.
* libargp/auth.c, libargp/gsasl.c,
libargp/pam.c, libargp/radius.c, libargp/sieve.c, libargp/sql.c,
libargp/tls.c, libargp/virtdomain.c: Define option values.
2007-11-22 Sergey Poznyakoff <gray@gnu.org.ua>
* libsieve/conf.c (mu_sieve_module_init): Initialize
......
......@@ -67,7 +67,8 @@ imap4d_login (struct imap4d_command *command, char *arg)
util_chdir (homedir);
namespace_init (homedir);
syslog (LOG_INFO, _("User `%s' logged in"), username);
syslog (LOG_INFO, _("User `%s' logged in (source: %s)"), username,
auth_data->source);
return util_finish (command, RESP_OK, "Completed");
}
......
......@@ -40,11 +40,17 @@ extern int mu_debug_print (mu_debug_t debug, size_t level,
const char *format, ...) MU_PRINTFLIKE(3,4);
extern int mu_debug_printv (mu_debug_t debug, size_t level,
const char *format, va_list argp);
extern int mu_debug_set_print (mu_debug_t,
int (*_print) (mu_debug_t, size_t level,
const char *, va_list),
void *owner);
typedef int (*mu_debug_printer_fp) (mu_debug_t, size_t level, const char *buf);
extern int mu_debug_set_print (mu_debug_t,
mu_debug_printer_fp printer,
void *owner);
extern mu_debug_printer_fp mu_debug_default_printer;
int mu_debug_syslog_printer (mu_debug_t, size_t, const char *);
int mu_debug_stderr_printer (mu_debug_t, size_t, const char *);
#ifdef __cplusplus
}
#endif
......
......@@ -36,50 +36,6 @@
extern "C" {
#endif
enum {
OPT_LOG_FACILITY = 256,
OPT_LOCK_FLAGS,
OPT_LOCK_RETRY_COUNT,
OPT_LOCK_RETRY_TIMEOUT,
OPT_LOCK_EXPIRE_TIMEOUT,
OPT_LOCK_EXTERNAL_PROGRAM,
OPT_SHOW_OPTIONS,
OPT_LICENSE,
OPT_MAILBOX_TYPE,
OPT_CRAM_PASSWD,
OPT_PAM_SERVICE,
OPT_AUTH_REQUEST,
OPT_GETPWNAM_REQUEST,
OPT_GETPWUID_REQUEST,
OPT_RADIUS_DIR,
OPT_SQL_INTERFACE,
OPT_SQL_GETPWNAM,
OPT_SQL_GETPWUID,
OPT_SQL_GETPASS,
OPT_SQL_HOST,
OPT_SQL_USER,
OPT_SQL_PASSWD,
OPT_SQL_DB,
OPT_SQL_PORT,
OPT_SQL_MU_PASSWORD_TYPE,
OPT_SQL_FIELD_MAP,
OPT_TLS,
OPT_SSL_CERT,
OPT_SSL_KEY,
OPT_SSL_CAFILE,
OPT_PWDDIR,
OPT_AUTHORIZATION,
OPT_AUTHENTICATION,
OPT_CLEAR_AUTHORIZATION,
OPT_CLEAR_AUTHENTICATION,
OPT_NO_USER_RCFILE,
OPT_NO_SITE_RCFILE,
OPT_RCFILE,
OPT_RCFILE_VERBOSE,
OPT_CLEAR_INCLUDE_PATH,
OPT_CLEAR_LIBRARY_PATH
};
struct mu_cmdline_capa
{
char *name;
......
......@@ -21,6 +21,7 @@
#include <mailutils/types.h>
#include <mailutils/gocs.h>
#include <mailutils/debug.h>
#define MU_AUTH_NAME "name"
#define MU_AUTH_PASSWD "passwd"
......@@ -34,6 +35,9 @@
struct mu_auth_data
{
/* Where this info comes from: */
const char *source;
/* These are from struct passwd */
char *name; /* user name */
char *passwd; /* user password */
......@@ -42,7 +46,8 @@ struct mu_auth_data
char *gecos; /* real name */
char *dir; /* home directory */
char *shell; /* shell program */
/* */
/* Additional fields */
char *mailbox;
mu_off_t quota;
......@@ -77,6 +82,9 @@ enum mu_auth_key_type
mu_auth_key_uid
};
void mu_auth_begin_setup (void);
void mu_auth_finish_setup (void);
extern int mu_auth_runlist (mu_list_t flist,
struct mu_auth_data **return_data,
const void *key, void *data);
......@@ -117,9 +125,10 @@ extern int mu_auth_data_alloc (struct mu_auth_data **ptr,
const char *shell,
const char *mailbox,
int change_uid);
void mu_auth_data_set_quota (struct mu_auth_data *ptr, mu_off_t q);
extern void mu_auth_data_set_quota (struct mu_auth_data *ptr, mu_off_t q);
extern void mu_auth_data_free (struct mu_auth_data *ptr);
extern void mu_auth_data_destroy (struct mu_auth_data **ptr);
extern mu_debug_t mu_auth_set_debug (mu_debug_t debug);
extern struct mu_auth_module mu_auth_system_module;
......
......@@ -20,12 +20,21 @@
# include <config.h>
#endif
#include "mailutils/libargp.h"
#include "mailutils/mu_auth.h"
/* ************************************************************************* */
/* Traditional configuration */
/* ************************************************************************* */
enum {
OPT_AUTHORIZATION=256,
OPT_AUTHENTICATION,
OPT_CLEAR_AUTHORIZATION,
OPT_CLEAR_AUTHENTICATION,
OPT_DEBUG_AUTH
};
static error_t mu_auth_argp_parser (int key, char *arg,
struct argp_state *state);
......@@ -39,6 +48,8 @@ static struct argp_option mu_auth_argp_option[] = {
N_("Clear the list of authorization modules"), 0 },
{ "clear-authentication", OPT_CLEAR_AUTHENTICATION, NULL, OPTION_HIDDEN,
N_("Clear the list of authentication modules"), 0 },
{ "debug-auth", OPT_DEBUG_AUTH, NULL, 0,
N_("Debug authentication functions") },
{ NULL, 0, NULL, 0, NULL, 0 }
};
......@@ -54,6 +65,18 @@ static struct argp_child mu_auth_argp_child = {
0
};
static void
auth_set_debug ()
{
mu_debug_t debug = NULL, prev;
mu_debug_create (&debug, NULL);
mu_debug_set_level (debug, MU_DEBUG_TRACE);
prev = mu_auth_set_debug (debug);
if (prev)
mu_debug_destroy (&prev, mu_debug_get_owner (prev));
}
static error_t
mu_auth_argp_parser (int key, char *arg, struct argp_state *state)
{
......@@ -80,6 +103,10 @@ mu_auth_argp_parser (int key, char *arg, struct argp_state *state)
mu_authorization_clear_list ();
break;
case OPT_DEBUG_AUTH:
auth_set_debug ();
break;
default:
return ARGP_ERR_UNKNOWN;
}
......
......@@ -62,6 +62,22 @@ assign_string (char **pstr, char *val)
/* Common */
/* ************************************************************************* */
enum {
OPT_SHOW_OPTIONS=256,
OPT_NO_USER_RCFILE,
OPT_NO_SITE_RCFILE,
OPT_RCFILE,
OPT_RCFILE_VERBOSE,
OPT_LOG_FACILITY,
OPT_LOCK_FLAGS,
OPT_LOCK_RETRY_COUNT,
OPT_LOCK_RETRY_TIMEOUT,
OPT_LOCK_EXPIRE_TIMEOUT,
OPT_LOCK_EXTERNAL_PROGRAM,
OPT_LICENSE,
OPT_MAILBOX_TYPE
};
static struct argp_option mu_common_argp_options[] =
{
{ NULL, 0, NULL, 0, N_("Common options"), 0},
......
......@@ -22,6 +22,8 @@
#include "mailutils/libargp.h"
#include <mailutils/gsasl.h>
#define OPT_CRAM_PASSWD 256
static struct argp_option _gsasl_argp_options[] = {
{"cram-passwd", OPT_CRAM_PASSWD, N_("FILE"), OPTION_HIDDEN,
N_("Specify password file for CRAM-MD5 authentication"), 0},
......
......@@ -25,6 +25,8 @@
static struct mu_gocs_pam pam_settings;
#define OPT_PAM_SERVICE 256
static error_t
mu_pam_argp_parser (int key, char *arg, struct argp_state *state)
{
......
......@@ -23,6 +23,13 @@
#include "mailutils/libargp.h"
#include <mailutils/radius.h>
enum {
OPT_AUTH_REQUEST = 256,
OPT_GETPWNAM_REQUEST,
OPT_GETPWUID_REQUEST,
OPT_RADIUS_DIR
};
static struct argp_option mu_radius_argp_option[] = {
{ "radius-auth-request", OPT_AUTH_REQUEST, N_("REQUEST"), OPTION_HIDDEN,
N_("Radius request to authenitcate the user"), 0 },
......
......@@ -23,6 +23,10 @@
#include "mailutils/libargp.h"
#include "mailutils/libsieve.h"
enum {
OPT_CLEAR_INCLUDE_PATH = 256,
OPT_CLEAR_LIBRARY_PATH
};
static struct argp_option sieve_argp_option[] = {
{ "includedir", 'I', N_("DIR"), 0,
......
......@@ -28,6 +28,20 @@ static int sql_requested;
static struct mu_sql_module_config sql_config;
/* Command-line configuration */
enum {
OPT_SQL_INTERFACE = 256,
OPT_SQL_GETPWNAM,
OPT_SQL_GETPWUID,
OPT_SQL_GETPASS,
OPT_SQL_HOST,
OPT_SQL_USER,
OPT_SQL_PASSWD,
OPT_SQL_DB,
OPT_SQL_PORT,
OPT_SQL_MU_PASSWORD_TYPE,
OPT_SQL_FIELD_MAP,
};
static struct argp_option mu_sql_argp_option[] = {
{"sql-interface", OPT_SQL_INTERFACE, N_("NAME"), OPTION_HIDDEN,
N_("Type of SQL interface to use"), },
......
......@@ -23,6 +23,13 @@
#include "mailutils/libargp.h"
#include <mailutils/tls.h>
enum {
OPT_TLS = 256,
OPT_SSL_CERT,
OPT_SSL_KEY,
OPT_SSL_CAFILE
};
static struct argp_option _tls_argp_options[] = {
{"ssl-cert", OPT_SSL_CERT, N_("FILE"), OPTION_HIDDEN,
N_("Specify SSL certificate file"), 0},
......
......@@ -24,6 +24,8 @@
static char *virtdir;
#define OPT_PWDDIR 256
static error_t
mu_virt_argp_parser (int key, char *arg, struct argp_state *state)
{
......
......@@ -24,6 +24,7 @@
#endif
#include <mailutils/debug.h>
#include <mailutils/stream.h>
#ifdef __cplusplus
extern "C" {
......@@ -32,10 +33,9 @@ extern "C" {
struct _mu_debug
{
size_t level;
char *buffer;
size_t buflen;
mu_stream_t stream;
void *owner;
int (*_print) (mu_debug_t, size_t level, const char *, va_list);
int (*printer) (mu_debug_t, size_t level, const char *buf);
};
#ifdef __cplusplus
......
......@@ -28,6 +28,7 @@
#include <sieve.h>
#include <fnmatch.h>
#include <regex.h>
#include <ctype.h>
typedef struct {
const char *name;
......
......@@ -28,6 +28,7 @@
#include <string.h>
#include <sieve.h>
#include <ltdl.h>
#include <ctype.h>
typedef int (*sieve_module_init_t) (mu_sieve_machine_t mach);
......
......@@ -29,6 +29,7 @@
#include <sys/stat.h>
#include <errno.h>
#include <string.h>
#include <ctype.h>
#include <mailutils/argcv.h>
#include <sieve.h>
#include <sieve-gram.h>
......
......@@ -271,20 +271,6 @@ struct mu_cfg_param maidag_cfg_param[] = {
/* Logging */
static int
_mu_debug_printer (mu_debug_t unused, size_t level, const char *fmt,
va_list ap)
{
if (log_to_stderr)
{
fprintf (stderr, "%s: ", (level == MU_DEBUG_ERROR) ? "ERROR" : "DEBUG");
vfprintf (stderr, fmt, ap);
fputc ('\n', stderr);
}
else
vsyslog ((level == MU_DEBUG_ERROR) ? LOG_ERR : LOG_DEBUG, fmt, ap);
return 0;
}
static int
_sieve_debug_printer (void *unused, const char *fmt, va_list ap)
......@@ -504,12 +490,6 @@ main (int argc, char *argv[])
mu_strerror (rc));
exit (EX_TEMPFAIL);
}
if ((rc = mu_debug_set_print (mudebug, _mu_debug_printer, NULL)))
{
mu_error (_("mu_debug_set_print failed: %s\n"),
mu_strerror (rc));
exit (EX_TEMPFAIL);
}
}
argc -= arg_index;
......
......@@ -265,14 +265,6 @@ struct mu_cfg_param mail_local_cfg_param[] = {
static int
_mu_debug_printer (mu_debug_t unused, size_t level, const char *fmt,
va_list ap)
{
vsyslog ((level == MU_DEBUG_ERROR) ? LOG_ERR : LOG_DEBUG, fmt, ap);
return 0;
}
static int
_sieve_debug_printer (void *unused, const char *fmt, va_list ap)
{
vsyslog (LOG_DEBUG, fmt, ap);
......@@ -396,12 +388,6 @@ main (int argc, char *argv[])
mu_strerror (rc));
exit (EX_TEMPFAIL);
}
if ((rc = mu_debug_set_print (mudebug, _mu_debug_printer, NULL)))
{
mu_error (_("mu_debug_set_print failed: %s\n"),
mu_strerror (rc));
exit (EX_TEMPFAIL);
}
}
argc -= arg_index;
......
......@@ -46,6 +46,8 @@ libmailutils_la_SOURCES = \
body.c\
daemon.c\
date.c\
dbgstderr.c\
dbgsyslog.c\
debug.c\
cfg_lexer.c\
cfg_parser.c\
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2004, 2005, 2007 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <mailutils/debug.h>
#include <stdio.h>
int
mu_debug_stderr_printer (mu_debug_t unused, size_t level, const char *str)
{
fprintf (stderr, "%s: %s",
(level == MU_DEBUG_ERROR) ? "ERROR" : "DEBUG",
str);
return 0;
}
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2004, 2005, 2007 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <mailutils/debug.h>
#include <syslog.h>
int
mu_debug_syslog_printer (mu_debug_t unused, size_t level, const char *str)
{
syslog ((level == MU_DEBUG_ERROR) ? LOG_ERR : LOG_DEBUG, "%s", str);
return 0;
}
......@@ -26,8 +26,11 @@
#include <string.h>
#include <mailutils/errno.h>
#include <mailutils/nls.h>
#include <debug0.h>
mu_debug_printer_fp mu_debug_default_printer = mu_debug_stderr_printer;
int
mu_debug_create (mu_debug_t *pdebug, void *owner)
{
......@@ -37,6 +40,7 @@ mu_debug_create (mu_debug_t *pdebug, void *owner)
debug = calloc (sizeof (*debug), 1);
if (debug == NULL)
return ENOMEM;
debug->printer = mu_debug_default_printer;
debug->owner = owner;
*pdebug = debug;
return 0;
......@@ -50,6 +54,8 @@ mu_debug_destroy (mu_debug_t *pdebug, void *owner)
mu_debug_t debug = *pdebug;
if (debug->owner == owner)
{
mu_stream_destroy (&debug->stream,
mu_stream_get_owner (debug->stream));
free (*pdebug);
*pdebug = NULL;
}
......@@ -82,15 +88,13 @@ mu_debug_get_level (mu_debug_t debug, size_t *plevel)
}
int
mu_debug_set_print (mu_debug_t debug,
int (*_print) (mu_debug_t, size_t, const char *, va_list),
void *owner)
mu_debug_set_print (mu_debug_t debug, mu_debug_printer_fp printer, void *owner)
{
if (debug == NULL)
return EINVAL;
if (debug->owner != owner)
return EACCES;
debug->_print = _print;
debug->printer = printer;
return 0;
}
......@@ -100,7 +104,7 @@ mu_debug_print (mu_debug_t debug, size_t level, const char *format, ...)
va_list ap;
va_start (ap, format);
mu_debug_printv (debug, level, format, ap);
va_end (ap);
......@@ -109,7 +113,8 @@ mu_debug_print (mu_debug_t debug, size_t level, const char *format, ...)
}
int
mu_debug_printv (mu_debug_t debug, size_t level, const char *format, va_list ap)
mu_debug_printv (mu_debug_t debug, size_t level, const char *format,
va_list ap)
{
if (debug == NULL || format == NULL)
return EINVAL;
......@@ -117,8 +122,59 @@ mu_debug_printv (mu_debug_t debug, size_t level, const char *format, va_list ap)
if (!(debug->level & level))
return 0;
if (debug->_print)
debug->_print (debug, level, format, ap);
if (debug->printer)
{
mu_off_t len;
mu_transport_t tbuf;
char *ptr, *start, *p;
size_t nseg;
if (debug->stream == NULL)
{
int rc = mu_memory_stream_create (&debug->stream, NULL, 0);
if (rc)
{
fprintf (stderr,
_("cannot create memory stream for debugging output: %s\n"),
mu_strerror (rc));
vfprintf (stderr, format, ap);
return rc;
}
}
mu_stream_sequential_vprintf (debug->stream, format, ap);
mu_stream_get_transport (debug->stream, &tbuf);
start = (char*) tbuf;
mu_stream_size (debug->stream, &len);
ptr = start;
nseg = 0;
for (p = ptr = start; p < start + len; p++)
{
if (*p == '\n')
{
int c = *++p;
*p = 0;
debug->printer (debug, level, ptr);
*p = c;
ptr = p;
nseg++;
}
}
if (nseg)
{
if (start[len - 1] != '\n')
{
size_t s = len - (ptr - start);
memmove (start, ptr, len);
}
else
len = 0;
mu_stream_truncate (debug->stream, len);
mu_stream_seek (debug->stream, len, SEEK_SET);
}
}
else
vfprintf (stderr, format, ap);
......
......@@ -30,6 +30,7 @@
#include <mailutils/error.h>
#include <mailutils/errno.h>
#include <mailutils/nls.h>
#include <mailutils/debug.h>
#include <syslog.h>
int mu_load_user_rcfile = 1;
......@@ -206,7 +207,12 @@ mu_gocs_logging_init (void *data)
}
if (p->facility)
log_facility = p->facility;
{
log_facility = p->facility;
mu_debug_default_printer = mu_debug_syslog_printer;
}
else
mu_debug_default_printer = mu_debug_stderr_printer;
/* FIXME: Tag */
return 0;
}
......
......@@ -125,21 +125,15 @@ _memory_truncate (mu_stream_t stream, mu_off_t len)
{
struct _memory_stream *mfs = mu_stream_get_owner (stream);
if (len == 0)
{
if (mfs->ptr)
free (mfs->ptr);
mfs->ptr = NULL;
}
else if (len != (mu_off_t)mfs->size)
if (len > (mu_off_t)mfs->size)
{
char *tmp = realloc (mfs->ptr, len);
if (tmp == NULL)
return ENOMEM;
mfs->ptr = tmp;
mfs->capacity = len;
}
mfs->size = len;
mfs->capacity = len;
return 0;
}
......@@ -216,6 +210,17 @@ _memory_open (mu_stream_t stream)
return status;
}
static int
_memory_get_transport2 (mu_stream_t stream,
mu_transport_t *pin, mu_transport_t *pout)
{
struct _memory_stream *mfs = mu_stream_get_owner (stream);
*pin = mfs->ptr;
if (pout)
*pout = mfs->ptr;
return 0;
}
int
mu_memory_stream_create (mu_stream_t * stream, const char *filename, int flags)
{
......@@ -260,6 +265,7 @@ mu_memory_stream_create (mu_stream_t * stream, const char *filename, int flags)
mu_stream_set_truncate (*stream, _memory_truncate, mfs);
mu_stream_set_size (*stream, _memory_size, mfs);
mu_stream_set_destroy (*stream, _memory_destroy, mfs);
mu_stream_set_get_transport2 (*stream, _memory_get_transport2, mfs);
return 0;
}
......
......@@ -25,6 +25,9 @@ pop3d_begin_session ()
{
int status;
syslog (LOG_INFO, _("POP3 login: user `%s', source %s"),
auth_data->name, auth_data->source);
if (check_login_delay (auth_data->name))
{
syslog (LOG_INFO,
......
......@@ -301,22 +301,6 @@ sieve_syslog_debug_printer (void *unused, const char *fmt, va_list ap)
return 0;
}
static int
stderr_debug_print (mu_debug_t unused, size_t level, const char *fmt,
va_list ap)
{
vfprintf ((level == MU_DEBUG_ERROR) ? stderr : stdout, fmt, ap);
return 0;
}
static int
syslog_debug_print (mu_debug_t unused, size_t level, const char *fmt,
va_list ap)
{
vsyslog ((level == MU_DEBUG_ERROR) ? LOG_ERR : LOG_DEBUG, fmt, ap);
return 0;
}
static void
stdout_action_log (void *unused,
const mu_sieve_locus_t *locus, size_t msgno, mu_message_t msg,
......@@ -379,7 +363,6 @@ main (int argc, char *argv[])
mu_debug_t debug = 0;
mu_mailbox_t mbox = 0;
int rc;
int (*debugfp) (mu_debug_t, size_t level, const char *, va_list);
/* Native Language Support */
mu_init_nls ();
......@@ -416,14 +399,12 @@ main (int argc, char *argv[])
mu_sieve_set_debug (mach, sieve_syslog_debug_printer);
if (verbose)
mu_sieve_set_logger (mach, syslog_action_log);
debugfp = syslog_debug_print;
}
else
{
mu_sieve_set_debug (mach, sieve_stderr_debug_printer);
if (verbose)
mu_sieve_set_logger (mach, stdout_action_log);
debugfp = stderr_debug_print;
}
rc = mu_sieve_compile (mach, script);
......@@ -473,12 +454,6 @@ main (int argc, char *argv[])
mu_strerror (rc));
goto cleanup;
}
if ((rc = mu_debug_set_print (debug, debugfp, mach)))
{
mu_error (_("mu_debug_set_print failed: %s"),
mu_strerror (rc));
goto cleanup;
}
}
mu_sieve_set_debug_level (mach, debug, sieve_debug);
......