diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2008-02-01 10:39:45 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2008-02-01 10:39:45 +0000 |
commit | 876e353f73fce1219df9465a6e9b67c525fbb844 (patch) | |
tree | d5934cb565dfb7ef0835e520c6eb122e4be29691 | |
parent | 65aa5e539e3cd72b8b6c6d9b2656cb6d522bea53 (diff) | |
download | mailfromd-876e353f73fce1219df9465a6e9b67c525fbb844.tar.gz mailfromd-876e353f73fce1219df9465a6e9b67c525fbb844.tar.bz2 |
* smap/smap.c (version): Fix indentation.
* pies/pies.c (return_code_section_parser): Allow to use symbolic
exit codes.
(priv_setup): Exit with EX_CONFIG if the user does not exist.
(main): Catch early sigchlds as well.
* pies/progman.c (progman_cleanup): Fix notice wording.
* pies/pies.rcin: Add sample return-code section.
(component pmult): Redirect stderr/stdout to syslog.
git-svn-id: file:///svnroot/mailfromd/branches/gmach@1601 7a8a7f39-df28-0410-adc6-e0d955640f24
-rw-r--r-- | pies/pies.c | 59 | ||||
-rw-r--r-- | pies/pies.rcin | 18 | ||||
-rw-r--r-- | pies/progman.c | 2 | ||||
-rw-r--r-- | smap/smap.c | 4 |
4 files changed, 69 insertions, 14 deletions
diff --git a/pies/pies.c b/pies/pies.c index 4b5fa762..e32bc8a4 100644 --- a/pies/pies.c +++ b/pies/pies.c @@ -120,7 +120,28 @@ struct mu_cfg_param return_code_cfg_param[] = { N_("Notification message text (with headers).") }, { NULL } }; - + +static struct mu_kwd ex_kwtab[] = { +#define S(s) { #s, s } + S (EX_OK), + S (EX_USAGE), + S (EX_DATAERR), + S (EX_NOINPUT), + S (EX_NOUSER), + S (EX_NOHOST), + S (EX_UNAVAILABLE), + S (EX_SOFTWARE), + S (EX_OSERR), + S (EX_OSFILE), + S (EX_CANTCREAT), + S (EX_IOERR), + S (EX_TEMPFAIL), + S (EX_PROTOCOL), + S (EX_NOPERM), + S (EX_CONFIG), + { NULL } +}; + static int return_code_section_parser (enum mu_cfg_section_stage stage, const mu_cfg_node_t *node, @@ -155,14 +176,29 @@ return_code_section_parser (enum mu_cfg_section_stage stage, { for (i = 0; i < argc; i++) { - char *p; - int n = strtoul (argv[i], &p, 0); - if (*p) - mu_cfg_format_error (tree->debug, MU_DEBUG_ERROR, - _("%s: not a number"), p); - else if (n > MAX_RETURN_CODE) + int n; + + if (isdigit (argv[i][0])) + { + char *p; + n = strtoul (argv[i], &p, 0); + if (*p) + { + mu_cfg_format_error (tree->debug, MU_DEBUG_ERROR, + _("%s: not a number"), p); + continue; + } + } + else if (mu_kwd_xlat_name_ci (ex_kwtab, argv[i], &n)) + { + mu_cfg_format_error (tree->debug, MU_DEBUG_ERROR, + _("%s: not a return code"), argv[i]); + continue; + } + + if (n > MAX_RETURN_CODE) mu_cfg_format_error (tree->debug, MU_DEBUG_ERROR, - _("%s: invalid return code"), p); + _("%s: invalid return code"), argv[i]); else { /* Alles in ordnung */ @@ -580,7 +616,7 @@ priv_setup (struct pies_privs_data *pr) if (!pw) { mu_error (_("No such user: %s"), pr->user); - exit (EX_SOFTWARE); + exit (EX_CONFIG); } if (pw && switch_to_privs (pw->pw_uid, pw->pw_gid, pr->groups)) exit (EX_SOFTWARE); @@ -908,10 +944,11 @@ main (int argc, char **argv) signal_setup (sig_handler); progman_start (); - + while (action == ACTION_CONT) { - pause (); + if (!children_cleanup) + pause (); if (children_cleanup) { children_cleanup = 0; diff --git a/pies/pies.rcin b/pies/pies.rcin index cfef9a8d..d1ae1973 100644 --- a/pies/pies.rcin +++ b/pies/pies.rcin @@ -1,7 +1,25 @@ # Sample pies configuration for running pmult. +# Special handling for exit codes that mean the program was used incorrectly +# or misconfigured. +return-code EX_USAGE EX_CONFIG { + action disable; + notify root; + message + "From: <>\n" + "X-Agent: ${canonical-program-name} (${package} ${version})\n" + "Subject: Component ${component} disabled.\n" + "\n" + "Component \"${component}\" terminated with code ${retcode}, which means\n" + "some configuration problem.\n" + "It will not be restarted automatically. Please fix its configuration\n" + "and restart it at your earliest convenience."; +}; + component pmult { command "SBINDIR/pmult"; user meta1s; + stderr info; + stdout info; }; diff --git a/pies/progman.c b/pies/progman.c index 7d029392..7749c072 100644 --- a/pies/progman.c +++ b/pies/progman.c @@ -708,7 +708,7 @@ progman_cleanup (int expect_term) if (!prog) { mu_diag_output (MU_DIAG_NOTICE, - _("unknown child %lu finished"), + _("subprocess %lu finished"), (unsigned long) pid); continue; } diff --git a/smap/smap.c b/smap/smap.c index daabfbb6..4f85e745 100644 --- a/smap/smap.c +++ b/smap/smap.c @@ -396,9 +396,9 @@ smap_hup (int sig) } static void -version(FILE *stream, struct argp_state *state) +version (FILE *stream, struct argp_state *state) { - mailfromd_version("smap", stream); + mailfromd_version ("smap", stream); } int |