diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2008-02-06 12:21:12 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2008-02-06 12:21:12 +0000 |
commit | a1bf4e218255bf7b70cb5ef115e61064030666ba (patch) | |
tree | ce89d5a630a4e224d6c8b1fde4130faa6020169a | |
parent | f3e3db4529999f6c8a183f48edb275817990f996 (diff) | |
download | mailutils-a1bf4e218255bf7b70cb5ef115e61064030666ba.tar.gz mailutils-a1bf4e218255bf7b70cb5ef115e61064030666ba.tar.bz2 |
* NEWS: Update.
* imap4d/bye.c, imap4d/starttls.c, imap4d/util.c: Use exit codes
from sysexits.h
* imap4d/imap4d.c: Use mu_set_signals to install signals.
Use exit codes from sysexits.h.
* imap4d/imap4d.h: Include sysexits.h and muaux.h
(ERR_TERMINATE): New define.
(imap4d_sigchld,imap4d_signal): Remove.
(imap4d_master_signal,imap4d_child_signal): New prototypes.
* imap4d/signal.c (imap4d_master_signal,imap4d_child_signal): New
functions.
* pop3d/pop3d.h Include sysexits.h and muaux.h
(ERR_TERMINATE): New define.
(pop3d_signal): Remove.
(pop3d_master_signal, pop3d_child_signal): New protos.
* pop3d/signal.c (pop3d_master_signal, pop3d_child_signal): New
functions.
* pop3d/extra.c, pop3d/popauth.c
* pop3d/pop3d.c: Use mu_set_signals to install signals.
Use exit codes from sysexits.h.
* include/mailutils/server.h (mu_m_server_set_strexit): New
prototype.
* include/mailutils/types.hin (MU_ARRAY_SIZE): New define.
* lib/Makefile.am (libmuaux_la_SOURCES): Add signal.c, strexit.c.
(noinst_HEADERS): Add muaux.h
* lib/muaux.h: New file.
* libsieve/extensions/spamd.c: Add NLS markers.
* mailbox/header.c (header_readline): Minor rewrite.
* mailbox/msrv.c (struct _mu_m_server): New member `strexit'.
(mu_m_server_begin): Call alloc_children.
(mu_m_server_restore_signals): New function.
(mu_m_server_end): Call mu_m_server_restore_signals.
(m_srv_conn): Reset signals in child branch.
* po/POTFILES.in: Update.
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | NEWS | 6 | ||||
-rw-r--r-- | imap4d/bye.c | 19 | ||||
-rw-r--r-- | imap4d/imap4d.c | 53 | ||||
-rw-r--r-- | imap4d/imap4d.h | 7 | ||||
-rw-r--r-- | imap4d/signal.c | 37 | ||||
-rw-r--r-- | imap4d/starttls.c | 4 | ||||
-rw-r--r-- | imap4d/util.c | 2 | ||||
-rw-r--r-- | include/mailutils/server.h | 1 | ||||
-rw-r--r-- | include/mailutils/types.hin | 1 | ||||
-rw-r--r-- | lib/Makefile.am | 5 | ||||
-rw-r--r-- | lib/muaux.h | 21 | ||||
-rw-r--r-- | libsieve/extensions/spamd.c | 15 | ||||
-rw-r--r-- | mailbox/header.c | 14 | ||||
-rw-r--r-- | mailbox/msrv.c | 60 | ||||
-rw-r--r-- | po/POTFILES.in | 65 | ||||
-rw-r--r-- | pop3d/extra.c | 63 | ||||
-rw-r--r-- | pop3d/pop3d.c | 49 | ||||
-rw-r--r-- | pop3d/pop3d.h | 24 | ||||
-rw-r--r-- | pop3d/popauth.c | 23 | ||||
-rw-r--r-- | pop3d/signal.c | 38 |
21 files changed, 362 insertions, 149 deletions
@@ -1,5 +1,9 @@ 2008-02-05 Sergey Poznyakoff <gray@gnu.org.ua> + * pop3d/extra.c (pop3d_readline): After a failed authorization + attempt many clients simply disconnect without issuing QUIT. + Do not count this as a protocol error. + * NEWS: Update. * imap4d/bye.c, imap4d/starttls.c, imap4d/util.c: Use exit codes from sysexits.h @@ -1,5 +1,6 @@ GNU mailutils NEWS -- history of user-visible changes. 2008-02-04 -Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. +Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, +2008 Free Software Foundation, Inc. See the end of file for copying conditions. Please send mailutils bug reports to <bug-mailutils@gnu.org>. @@ -1026,7 +1027,8 @@ The first release. ---------------------------------------------------------------------- Copyright information: -Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. +Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, +2008 Free Software Foundation, Inc. Permission is granted to anyone to make or distribute verbatim copies of this document as received, in any medium, provided that the diff --git a/imap4d/bye.c b/imap4d/bye.c index 7b68744d7..85dc43ace 100644 --- a/imap4d/bye.c +++ b/imap4d/bye.c @@ -1,6 +1,6 @@ /* GNU Mailutils -- a suite of utilities for electronic mail Copyright (C) 1999, 2000, 2001, 2002, 2005, - 2007 Free Software Foundation, Inc. + 2007, 2008 Free Software Foundation, Inc. GNU Mailutils is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,7 +28,7 @@ imap4d_bye (int reason) int imap4d_bye0 (int reason, struct imap4d_command *command) { - int status = EXIT_FAILURE; + int status = EX_SOFTWARE; if (mbox) { @@ -40,15 +40,22 @@ imap4d_bye0 (int reason, struct imap4d_command *command) switch (reason) { case ERR_NO_MEM: - util_out (RESP_BYE, "Server terminating no more resources."); + util_out (RESP_BYE, "Server terminating: no more resources."); mu_diag_output (MU_DIAG_ERROR, _("Out of memory")); break; + case ERR_TERMINATE: + status = EX_OK; + util_out (RESP_BYE, "Server terminating on request."); + mu_diag_output (MU_DIAG_NOTICE, _("Terminating on request")); + break; + case ERR_SIGNAL: mu_diag_output (MU_DIAG_ERROR, _("Quitting on signal")); exit (status); case ERR_TIMEOUT: + status = EX_TEMPFAIL; util_out (RESP_BYE, "Session timed out"); if (state == STATE_NONAUTH) mu_diag_output (MU_DIAG_INFO, _("Session timed out for no user")); @@ -57,20 +64,22 @@ imap4d_bye0 (int reason, struct imap4d_command *command) break; case ERR_NO_OFILE: + status = EX_IOERR; mu_diag_output (MU_DIAG_INFO, _("No socket to send to")); break; case ERR_MAILBOX_CORRUPTED: + status = EX_OSERR; mu_diag_output (MU_DIAG_ERROR, _("Mailbox modified by third party")); break; case OK: + status = EX_OK; util_out (RESP_BYE, "Session terminating."); if (state == STATE_NONAUTH) mu_diag_output (MU_DIAG_INFO, _("Session terminating")); else mu_diag_output (MU_DIAG_INFO, _("Session terminating for user: %s"), auth_data->name); - status = EXIT_SUCCESS; break; default: @@ -79,7 +88,7 @@ imap4d_bye0 (int reason, struct imap4d_command *command) break; } - if (status == EXIT_SUCCESS && command) + if (status == EX_OK && command) util_finish (command, RESP_OK, "Completed"); util_bye (); diff --git a/imap4d/imap4d.c b/imap4d/imap4d.c index 62c19b3a2..521aba405 100644 --- a/imap4d/imap4d.c +++ b/imap4d/imap4d.c @@ -372,12 +372,12 @@ imap4d_mainloop (int fd, FILE *infile, FILE *outfile) { char *text; int debug_mode = isatty (fd); + static int sigtab[] = { SIGILL, SIGBUS, SIGFPE, SIGSEGV, SIGSTOP, SIGPIPE, + SIGABRT, SIGINT, SIGQUIT, SIGTERM, SIGHUP, SIGALRM }; - /* Reset hup to exit. */ - signal (SIGHUP, imap4d_signal); - /* Timeout alarm. */ - signal (SIGALRM, imap4d_signal); - + /* Reset signals */ + mu_set_signals (imap4d_child_signal, sigtab, MU_ARRAY_SIZE (sigtab)); + util_setio (infile, outfile); if (imap4d_preauth_setup (fd) == 0) @@ -393,7 +393,7 @@ imap4d_mainloop (int fd, FILE *infile, FILE *outfile) else { util_flush_output (); - return EXIT_SUCCESS; + return 0; } /* Greetings. */ @@ -411,7 +411,7 @@ imap4d_mainloop (int fd, FILE *infile, FILE *outfile) util_flush_output (); } - return EXIT_SUCCESS; + return 0; } int @@ -458,7 +458,9 @@ int main (int argc, char **argv) { struct group *gr; - int status = EXIT_SUCCESS; + int status = 0; + static int sigtab[] = { SIGILL, SIGBUS, SIGFPE, SIGSEGV, SIGSTOP, SIGPIPE, + SIGABRT }; /* Native Language Support */ MU_APP_INIT_NLS (); @@ -490,10 +492,11 @@ main (int argc, char **argv) /* FIXME mu_m_server_set_pidfile (); */ mu_m_server_set_default_port (server, 143); mu_m_server_set_timeout (server, 1800); /* RFC2060: 30 minutes. */ + mu_m_server_set_strexit (server, mu_strexit); if (mu_app_init (&argp, imap4d_capa, imap4d_cfg_param, argc, argv, 0, NULL, server)) - exit (1); + exit (EX_CONFIG); /* FIXME: No way to discern from EX_USAGE? */ if (login_disabled) imap4d_capability_add (IMAP_CAPA_LOGINDISABLED); @@ -514,32 +517,32 @@ main (int argc, char **argv) { /* Normal operation: */ /* First we want our group to be mail so we can access the spool. */ + errno = 0; gr = getgrnam ("mail"); if (gr == NULL) { - perror (_("Error getting mail group")); - exit (1); + if (errno == 0 || errno == ENOENT) + { + mu_error (_("%s: No such group"), "mail"); + exit (EX_CONFIG); + } + else + { + mu_error (_("Error getting mail group: %s"), + mu_strerror (errno)); + exit (EX_OSERR); + } } if (setgid (gr->gr_gid) == -1) { - perror (_("Error setting mail group")); - exit (1); + mu_error (_("Error setting mail group: %s"), mu_strerror (errno)); + exit (EX_OSERR); } } /* Set the signal handlers. */ - signal (SIGINT, imap4d_signal); - signal (SIGQUIT, imap4d_signal); - signal (SIGILL, imap4d_signal); - signal (SIGBUS, imap4d_signal); - signal (SIGFPE, imap4d_signal); - signal (SIGSEGV, imap4d_signal); - signal (SIGTERM, imap4d_signal); - signal (SIGSTOP, imap4d_signal); - signal (SIGPIPE, imap4d_signal); - /*signal (SIGPIPE, SIG_IGN); */ - signal (SIGABRT, imap4d_signal); + mu_set_signals (imap4d_master_signal, sigtab, MU_ARRAY_SIZE (sigtab)); /* Set up for syslog. */ openlog (MU_LOG_TAG (), LOG_PID, mu_log_facility); @@ -582,6 +585,6 @@ main (int argc, char **argv) /* Close the syslog connection and exit. */ closelog (); - return status != 0; + return status ? EX_SOFTWARE : EX_OK; } diff --git a/imap4d/imap4d.h b/imap4d/imap4d.h index 363b9cd73..73a14411f 100644 --- a/imap4d/imap4d.h +++ b/imap4d/imap4d.h @@ -69,6 +69,7 @@ #ifdef HAVE_PATHS_H # include <paths.h> #endif +#include <sysexits.h> #include "xalloc.h" @@ -101,6 +102,7 @@ #include <mu_asprintf.h> #include <mu_umaxtostr.h> +#include <muaux.h> #ifdef __cplusplus extern "C" { @@ -142,6 +144,7 @@ struct imap4d_command #define ERR_SIGNAL 4 #define ERR_TLS 5 #define ERR_MAILBOX_CORRUPTED 6 +#define ERR_TERMINATE 7 /* Namespace numbers */ #define NS_PRIVATE 0 @@ -243,8 +246,8 @@ extern size_t uid_to_msgno (size_t); extern void imap4d_set_observer (mu_mailbox_t mbox); /* Signal handling. */ -extern RETSIGTYPE imap4d_sigchld (int); -extern RETSIGTYPE imap4d_signal (int); +extern RETSIGTYPE imap4d_master_signal (int); +extern RETSIGTYPE imap4d_child_signal (int); extern int imap4d_bye (int); extern int imap4d_bye0 (int reason, struct imap4d_command *command); diff --git a/imap4d/signal.c b/imap4d/signal.c index 5e88102e0..607b05951 100644 --- a/imap4d/signal.c +++ b/imap4d/signal.c @@ -1,5 +1,6 @@ /* GNU Mailutils -- a suite of utilities for electronic mail - Copyright (C) 1999, 2000, 2001, 2002, 2007 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 2001, 2002, 2007, + 2008 Free Software Foundation, Inc. GNU Mailutils is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,18 +23,40 @@ /* Default signal handler to call the imap4d_bye() function */ RETSIGTYPE -imap4d_signal (int signo) +imap4d_master_signal (int signo) { - mu_diag_output (MU_DIAG_CRIT, _("Got signal %s"), strsignal (signo)); - /* Master process. */ - if (util_is_master ()) + int code; + + mu_diag_output (MU_DIAG_CRIT, _("MASTER: exiting on signal (%s)"), + strsignal (signo)); + switch (signo) { - mu_diag_output (MU_DIAG_CRIT, _("MASTER: exiting on signal")); - exit (1); /* abort(); */ + case SIGTERM: + case SIGHUP: + case SIGQUIT: + case SIGINT: + code = EX_OK; + break; + + default: + code = EX_SOFTWARE; + break; } + exit (code); +} + +RETSIGTYPE +imap4d_child_signal (int signo) +{ + mu_diag_output (MU_DIAG_CRIT, _("Got signal `%s'"), strsignal (signo)); + switch (signo) { + case SIGTERM: + case SIGHUP: + imap4d_bye (ERR_TERMINATE); + case SIGALRM: imap4d_bye (ERR_TIMEOUT); diff --git a/imap4d/starttls.c b/imap4d/starttls.c index c0572ce85..723e741c2 100644 --- a/imap4d/starttls.c +++ b/imap4d/starttls.c @@ -1,5 +1,5 @@ /* GNU Mailutils -- a suite of utilities for electronic mail - Copyright (C) 2003, 2007 Free Software Foundation, Inc. + Copyright (C) 2003, 2007, 2008 Free Software Foundation, Inc. GNU Mailutils is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -55,7 +55,7 @@ imap4d_starttls (struct imap4d_command *command, char *arg) { mu_diag_output (MU_DIAG_ERROR, _("Session terminated")); util_bye (); - exit (0); + exit (EX_OK); } return status; diff --git a/imap4d/util.c b/imap4d/util.c index 673a18491..0ee0ed0a0 100644 --- a/imap4d/util.c +++ b/imap4d/util.c @@ -1007,7 +1007,7 @@ util_localname () if (status) { mu_diag_output (MU_DIAG_CRIT, _("Cannot find out my own hostname")); - exit (1); + exit (EX_OSERR); } hp = gethostbyname (name); diff --git a/include/mailutils/server.h b/include/mailutils/server.h index fb610201b..866da282d 100644 --- a/include/mailutils/server.h +++ b/include/mailutils/server.h @@ -106,6 +106,7 @@ void mu_m_server_set_default_address (mu_m_server_t srv, struct sockaddr *sa, void mu_m_server_set_timeout (mu_m_server_t srv, time_t t); void mu_m_server_set_mode (mu_m_server_t srv, int mode); void mu_m_server_set_sigset (mu_m_server_t srv, sigset_t *sigset); +void mu_m_server_set_strexit (mu_m_server_t srv, const char *(*fun) (int)); int mu_m_server_mode (mu_m_server_t srv); int mu_m_server_foreground (mu_m_server_t srv); diff --git a/include/mailutils/types.hin b/include/mailutils/types.hin index 20c4eb69d..ea3fdc255 100644 --- a/include/mailutils/types.hin +++ b/include/mailutils/types.hin @@ -118,6 +118,7 @@ typedef struct _mu_m_server *mu_m_server_t; (MU_FOLDER_ATTRIBUTE_DIRECTORY|MU_FOLDER_ATTRIBUTE_FILE) #define mu_offsetof(s,f) ((size_t)&((s*)0)->f) +#define MU_ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0])) #ifdef __cplusplus } diff --git a/lib/Makefile.am b/lib/Makefile.am index c96395c94..66e2af1a9 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -1,7 +1,7 @@ ## Process this file with GNU Automake to create Makefile.in ## Copyright (C) 1999, 2000, 2001, 2002, 2005, -## 2007 Free Software Foundation, Inc. +## 2007, 2008 Free Software Foundation, Inc. ## ## GNU Mailutils is free software; you can redistribute it and/or ## modify it under the terms of the GNU General Public License as @@ -26,10 +26,13 @@ libmuaux_la_SOURCES += \ daemon.c\ mailcap.c\ mu_dbm.c\ + signal.c\ + strexit.c\ tcpwrap.c noinst_HEADERS +=\ mailcap.h\ + muaux.h\ mu_dbm.h\ mu_asprintf.h\ tcpwrap.h diff --git a/lib/muaux.h b/lib/muaux.h new file mode 100644 index 000000000..584b482c5 --- /dev/null +++ b/lib/muaux.h @@ -0,0 +1,21 @@ +/* GNU Mailutils -- a suite of utilities for electronic mail + Copyright (C) 2008 Free Software Foundation, Inc. + + GNU Mailutils is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + GNU Mailutils 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNU Mailutils; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + MA 02110-1301 USA */ + +void mu_set_signals (RETSIGTYPE (*handler) (int signo), int *sigv, int sigc); +const char *mu_strexit (int code); + diff --git a/libsieve/extensions/spamd.c b/libsieve/extensions/spamd.c index 70243c6fb..32470c8cb 100644 --- a/libsieve/extensions/spamd.c +++ b/libsieve/extensions/spamd.c @@ -1,5 +1,5 @@ /* GNU Mailutils -- a suite of utilities for electronic mail - Copyright (C) 2003, 2004, 2005, 2007 Free Software Foundation, Inc. + Copyright (C) 2003, 2004, 2005, 2007, 2008 Free Software Foundation, Inc. GNU Mailutils is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -32,6 +32,7 @@ #include <signal.h> #include <mailutils/libsieve.h> #include <mailutils/mu_auth.h> +#include <mailutils/nls.h> #define DEFAULT_SPAMD_PORT 783 @@ -319,20 +320,20 @@ spamd_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) if (got_sigpipe) { - mu_sieve_error (mach, "remote side has closed connection"); + mu_sieve_error (mach, _("remote side has closed connection")); spamd_abort (mach, &stream, handler); } if (sscanf (buffer, "SPAMD/%18s %d %*s", version_str, &response) != 2) { - mu_sieve_error (mach, "spamd responded with bad string '%s'", buffer); + mu_sieve_error (mach, _("spamd responded with bad string '%s'"), buffer); spamd_abort (mach, &stream, handler); } decode_float (&version, version_str, 1); if (version < 10) { - mu_sieve_error (mach, "unsupported SPAMD version: %s", version_str); + mu_sieve_error (mach, _("unsupported SPAMD version: %s"), version_str); spamd_abort (mach, &stream, handler); } @@ -345,7 +346,8 @@ spamd_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) if (sscanf (buffer, "Spam: %5s ; %20s / %20s", spam_str, score_str, threshold_str) != 3) { - mu_sieve_error (mach, "spamd responded with bad Spam header '%s'", buffer); + mu_sieve_error (mach, _("spamd responded with bad Spam header '%s'"), + buffer); spamd_abort (mach, &stream, handler); } @@ -376,7 +378,8 @@ spamd_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) rc = mu_message_get_header (msg, &hdr); if (rc) { - mu_sieve_error (mach, "cannot get message header: %s", mu_strerror (rc)); + mu_sieve_error (mach, _("cannot get message header: %s"), + mu_strerror (rc)); spamd_abort (mach, &stream, handler); } diff --git a/mailbox/header.c b/mailbox/header.c index f1b286bb0..ecea02adc 100644 --- a/mailbox/header.c +++ b/mailbox/header.c @@ -1,6 +1,6 @@ /* GNU Mailutils -- a suite of utilities for electronic mail Copyright (C) 1999, 2000, 2001, 2004, 2005, - 2007 Free Software Foundation, Inc. + 2007, 2008 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 @@ -1059,16 +1059,20 @@ header_readline (mu_stream_t is, char *buffer, size_t buflen, buflen--; /* Account for the terminating nul */ mu_hdrent_fixup (header, ent); + strsize = MU_STR_SIZE (ent->nlen, ent->vlen) - ent_off; start = MU_HDRENT_NAME (header, ent) + ent_off; end = strchr (start, '\n'); if (end) - strsize = end - start + 1; - else - strsize = strlen (start); + { + size_t len = end - start + 1; + if (len < strsize) + strsize = len; + } + if (strsize < buflen) buflen = strsize; - memcpy (buffer, MU_HDRENT_NAME (header, ent) + ent_off, buflen); + memcpy (buffer, start, buflen); buffer[buflen] = 0; mu_hdrent_unroll_fixup (header, ent); if (pnread) diff --git a/mailbox/msrv.c b/mailbox/msrv.c index 58393ec74..4f999a485 100644 --- a/mailbox/msrv.c +++ b/mailbox/msrv.c @@ -95,7 +95,7 @@ struct _mu_m_server int foreground; /* Should the server remain in foregorund? */ size_t max_children; /* Maximum number of sub-processes to run. */ - size_t num_children; /* Current number of running sub-processes. */ + size_t num_children; /* Current number of running sub-processes. */ pid_t *child_pid; char *pidfile; /* Name of a PID-file. */ struct m_default_address defaddr; /* Default address. */ @@ -105,6 +105,8 @@ struct _mu_m_server sigset_t sigmask; /* A set of signals to handle by the m-server. */ mu_sig_handler_t sigtab[NSIG]; /* Keeps old signal handlers. */ + const char *(*strexit) (int); /* Convert integer exit code to textual + description. */ }; struct m_srv_config /* Configuration data for a single TCP server. */ @@ -125,22 +127,12 @@ static mu_list_t m_server_list; #define UNUSED_PID ((pid_t)-1) static void -alloc_children (mu_m_server_t srv, size_t num) +alloc_children (mu_m_server_t srv) { int i; - size_t size = num * sizeof (srv->child_pid[0]); - size_t last; + size_t size = srv->max_children * sizeof (srv->child_pid[0]); - if (srv->child_pid) - { - srv->child_pid = realloc (srv->child_pid, size); - last = srv->max_children; - } - else - { - srv->child_pid = malloc (size); - last = 0; - } + srv->child_pid = malloc (size); if (!srv->child_pid) { @@ -148,10 +140,8 @@ alloc_children (mu_m_server_t srv, size_t num) abort (); } - for (i = last; i < num; i++) + for (i = 0; i < srv->max_children; i++) srv->child_pid[i] = UNUSED_PID; - - srv->max_children = num; } static void @@ -160,8 +150,6 @@ register_child (mu_m_server_t msrv, pid_t pid) int i; msrv->num_children++; - if (!msrv->child_pid) - alloc_children (msrv, msrv->max_children); for (i = 0; i < msrv->max_children; i++) if (msrv->child_pid[i] == UNUSED_PID) { @@ -226,9 +214,17 @@ m_server_cleanup (void *item, void *data) int code = WEXITSTATUS (datp->status); if (code == 0) prio = MU_DIAG_DEBUG; - mu_diag_output (prio, "process %lu finished with code %d", - (unsigned long) datp->pid, - code); + if (msrv->strexit) + mu_diag_output (prio, + _("process %lu finished with code %d (%s)"), + (unsigned long) datp->pid, + code, + msrv->strexit (code)); + else + mu_diag_output (prio, + _("process %lu finished with code %d"), + (unsigned long) datp->pid, + code); } else if (WIFSIGNALED (datp->status)) mu_diag_output (MU_DIAG_ERR, "process %lu terminated on signal %d", @@ -361,7 +357,7 @@ mu_m_server_set_data (mu_m_server_t srv, void *data) void mu_m_server_set_max_children (mu_m_server_t srv, size_t num) { - alloc_children (srv, num); + srv->max_children = num; } int @@ -379,6 +375,12 @@ mu_m_server_set_foreground (mu_m_server_t srv, int enable) return 0; } +void +mu_m_server_set_strexit (mu_m_server_t srv, const char *(*fun) (int)) +{ + srv->strexit = fun; +} + int mu_m_server_get_srvlist (mu_m_server_t srv, mu_list_t *plist) { @@ -507,6 +509,9 @@ mu_m_server_begin (mu_m_server_t msrv) int i, rc; size_t count = 0; + if (!msrv->child_pid) + alloc_children (msrv); + mu_list_count (msrv->srvlist, &count); if (count == 0 && msrv->defaddr.len) add_server (msrv, &msrv->defaddr.s.s_sa, msrv->defaddr.len, msrv->deftype); @@ -543,7 +548,7 @@ mu_m_server_begin (mu_m_server_t msrv) } void -mu_m_server_end (mu_m_server_t msrv) +mu_m_server_restore_signals (mu_m_server_t msrv) { int i; @@ -553,6 +558,12 @@ mu_m_server_end (mu_m_server_t msrv) } void +mu_m_server_end (mu_m_server_t msrv) +{ + mu_m_server_restore_signals (msrv); +} + +void mu_m_server_destroy (mu_m_server_t *pmsrv) { mu_m_server_t msrv = *pmsrv; @@ -726,6 +737,7 @@ m_srv_conn (int fd, struct sockaddr *sa, int salen, else if (pid == 0) /* Child. */ { mu_ip_server_shutdown (srv); /* FIXME: does it harm for MU_IP_UDP? */ + mu_m_server_restore_signals (pconf->msrv); status = pconf->msrv->conn (fd, sa, salen, pconf->msrv->data, srv, pconf->timeout, pconf->transcript); closelog (); diff --git a/po/POTFILES.in b/po/POTFILES.in index 0a0f5df8c..6f566387e 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -3,47 +3,61 @@ # Copyright (C) 2002, 2003, 2004, 2005, 2008 Free Software Foundation, Inc. # -auth/pam.c +auth/ldap.c +auth/radius.c auth/sql.c auth/tls.c -auth/virtual.c + comsat/action.c comsat/oldcfg.c comsat/comsat.c + config/mailutils-config.c + dotlock/dotlock.c + frm/common.c frm/frm.c frm/from.c + guimb/collect.c guimb/main.c guimb/util.c + +imap4d/auth_gsasl.c imap4d/auth_gss.c -imap4d/authenticate.c imap4d/bye.c +imap4d/close.c imap4d/imap4d.c -imap4d/list.c imap4d/login.c +imap4d/preauth.c imap4d/search.c imap4d/signal.c +imap4d/starttls.c imap4d/util.c + lib/argp-help.c lib/argp-parse.c lib/getopt.c lib/mailcap.c lib/tcpwrap.c lib/xmalloc.c +lib/strexit.c + libargp/auth.c libargp/cmdline.c libargp/common.c +libargp/compat.c libargp/gsasl.c libargp/mu_argp.c -libargp/muinit.c libargp/pam.c libargp/radius.c +libargp/sieve.c libargp/sql.c libargp/tls.c libargp/virtdomain.c + +libcfg/acl.c libcfg/auth.c libcfg/common.c libcfg/gsasl.c @@ -55,14 +69,22 @@ libcfg/sieve.c libcfg/sql.c libcfg/tls.c libcfg/virtdomain.c + libproto/imap/folder.c libproto/mbox/mbox.c + libsieve/actions.c libsieve/comparator.c + libsieve/extensions/list.c +libsieve/extensions/moderator.c libsieve/extensions/spamd.c libsieve/extensions/timestamp.c libsieve/extensions/vacation.c + +libsieve/actions.c +libsieve/comparator.c +libsieve/conf.c libsieve/prog.c libsieve/relational.c libsieve/require.c @@ -71,11 +93,21 @@ libsieve/sieve.l libsieve/sieve.y libsieve/tests.c libsieve/util.c + +maidag/maidag.c +maidag/deliver.c +maidag/lmtp.c maidag/maidag.c +maidag/mailquota.c +maidag/mailtmp.c +maidag/script.c + mail.local/mailquota.c mail.local/main.c mail.local/script.c + mail.remote/mail.remote.c + mail/alias.c mail/alt.c mail/cd.c @@ -102,16 +134,30 @@ mail/summary.c mail/unalias.c mail/util.c mail/z.c + +mailbox/cfg_driver.c mailbox/cfg_format.c mailbox/cfg_lexer.c +mailbox/cfg_parser.y +mailbox/debug.c +mailbox/diag.c mailbox/errors mailbox/file_stream.c mailbox/filter_iconv.c +mailbox/gdebug.c +mailbox/gocs.c mailbox/ipsrv.c mailbox/message.c +mailbox/msrv.c mailbox/mu_auth.c +mailbox/muerrno.c mailbox/mutil.c +mailbox/parsedate.y +mailbox/registrar.c +mailbox/version.c + messages/messages.c + mh/anno.c mh/fmtcheck.c mh/folder.c @@ -141,22 +187,29 @@ mh/scan.c mh/send.c mh/whatnow.c mh/whom.c + mimeview/mimetypes.l mimeview/mimetypes.y mimeview/mimeview.c + movemail/movemail.c + pop3d/apop.c +pop3d/bulletin.c pop3d/extra.c pop3d/lock.c +pop3d/logindelay.c pop3d/pop3d.c pop3d/popauth.c pop3d/quit.c pop3d/signal.c pop3d/user.c + readmsg/readmsg.c + sieve/sieve.c + sql/mysql.c -sql/postgres.c # EOF diff --git a/pop3d/extra.c b/pop3d/extra.c index b90c87e4b..808ca3d28 100644 --- a/pop3d/extra.c +++ b/pop3d/extra.c @@ -90,6 +90,8 @@ pop3d_cmd (const char *cmd) int pop3d_abquit (int reason) { + int code; + /* Unlock spool */ if (state != AUTHORIZATION) { @@ -102,52 +104,85 @@ pop3d_abquit (int reason) switch (reason) { case ERR_NO_MEM: + code = EX_SOFTWARE; pop3d_outf ("-ERR Out of memory, quitting\r\n"); mu_diag_output (MU_DIAG_ERROR, _("Out of memory")); break; case ERR_SIGNAL: + code = EX_SOFTWARE; mu_diag_output (MU_DIAG_ERROR, _("Quitting on signal")); break; + case ERR_TERMINATE: + code = EX_OK; + mu_diag_output (MU_DIAG_NOTICE, _("Terminating on request")); + break; + case ERR_TIMEOUT: + code = EX_TEMPFAIL; pop3d_outf ("-ERR Session timed out\r\n"); if (state == TRANSACTION) - mu_diag_output (MU_DIAG_INFO, _("Session timed out for user: %s"), username); + mu_diag_output (MU_DIAG_INFO, _("Session timed out for user: %s"), + username); else mu_diag_output (MU_DIAG_INFO, _("Session timed out for no user")); break; + case ERR_NO_IFILE: + code = EX_NOINPUT; + mu_diag_output (MU_DIAG_INFO, _("No input stream")); + break; + case ERR_NO_OFILE: + code = EX_IOERR; < |