diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2016-02-23 11:36:33 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2016-02-23 12:25:47 +0200 |
commit | 6e73a7b0822d1fd506c75a662070f447bba94afb (patch) | |
tree | e121c440aff73316cb43ec05295e2c32492bf5dc /src | |
parent | 584266f8215d913ce0c226f63da51c77d1074f09 (diff) | |
download | pies-6e73a7b0822d1fd506c75a662070f447bba94afb.tar.gz pies-6e73a7b0822d1fd506c75a662070f447bba94afb.tar.bz2 |
Improve logging
* po/POTFILES.in: Add missing source files.
* grecs: Upgrade.
* src/diag.c (pies_diag_printer): New function.
(logfuncall): New function.
* src/pies.h: Add new prototypes.
* src/pies.c (main): Initialize grecs_print_diag_fun
* src/acl.c: Uniformly use double-quotes in messages. Use
logfuncall where applicable.
* src/comp.c: Likewise.
* src/ctl.c: Likewise.
* src/inetd-bi.c: Likewise.
* src/inetd.c: Likewise.
* src/limits.c: Likewise.
* src/piesctl.c: Likewise.
* src/progman.c: Likewise.
* src/socket.c: Likewise.
* src/sysvinit.c: Likewise.
Diffstat (limited to 'src')
-rw-r--r-- | src/acl.c | 22 | ||||
-rw-r--r-- | src/comp.c | 10 | ||||
-rw-r--r-- | src/ctl.c | 5 | ||||
-rw-r--r-- | src/diag.c | 42 | ||||
-rw-r--r-- | src/inetd-bi.c | 3 | ||||
-rw-r--r-- | src/inetd.c | 8 | ||||
-rw-r--r-- | src/limits.c | 7 | ||||
-rw-r--r-- | src/pies.c | 29 | ||||
-rw-r--r-- | src/pies.h | 4 | ||||
-rw-r--r-- | src/piesctl.c | 34 | ||||
-rw-r--r-- | src/progman.c | 21 | ||||
-rw-r--r-- | src/socket.c | 20 | ||||
-rw-r--r-- | src/sysvinit.c | 7 |
13 files changed, 96 insertions, 116 deletions
@@ -174,13 +174,13 @@ _parse_sockaddr (struct acl_entry *entry, const grecs_value_t *value) struct sockaddr_un *s_un; len = strlen (string); if (len >= sizeof (s_un->sun_path)) { grecs_error (&entry->locus, 0, - _("socket name too long: `%s'"), string); + _("socket name too long: %s"), string); return 1; } sptr = create_acl_sockaddr (AF_UNIX, sizeof (s_un)); s_un = (struct sockaddr_un *) &sptr->sa; memcpy (s_un->sun_path, string, len); s_un->sun_path[len] = 0; @@ -197,13 +197,13 @@ _parse_sockaddr (struct acl_entry *entry, const grecs_value_t *value) if (inet_aton (string, &addr) == 0) { struct hostent *hp = gethostbyname (string); if (!hp) { grecs_error (&entry->locus, 0, - _("cannot resolve host name: `%s'"), string); + _("cannot resolve host name: %s"), string); if (p) *p = '/'; return 1; } memcpy (&addr.s_addr, hp->h_addr, sizeof (addr.s_addr)); } @@ -234,20 +234,20 @@ _parse_sockaddr (struct acl_entry *entry, const grecs_value_t *value) { struct in_addr addr; if (inet_aton (p, &addr) == 0) { grecs_error (&entry->locus, 0, - _("invalid netmask: `%s'"), p); + _("invalid netmask: %s"), p); return 1; } sptr->netmask = addr.s_addr; } else { - grecs_error (&entry->locus, 0, _("invalid netmask: `%s'"), p); + grecs_error (&entry->locus, 0, _("invalid netmask: %s"), p); return 1; } } else sptr->netmask = 0xfffffffful; } @@ -278,28 +278,28 @@ static int _parse_from (struct acl_entry *entry, size_t argc, grecs_value_t **argv) { if (argc == 0) return 0; else if (argv[0]->type == GRECS_TYPE_LIST) { - grecs_error (&entry->locus, 0, _("expected `from', but found list")); + grecs_error (&entry->locus, 0, _("expected \"from\", but found list")); return 1; } else if (strcmp (argv[0]->v.string, "from")) { - grecs_error (&entry->locus, 0, _("expected `from', but found `%s'"), + grecs_error (&entry->locus, 0, _("expected \"from\", but found \"%s\""), argv[0]->v.string); return 1; } argc--; argv++; if (argc == 0) { grecs_error (&entry->locus, 0, - _("unexpected end of statement after `from'")); + _("unexpected end of statement after \"from\"")); return 1; } entry->sockaddrs = grecs_list_create (); entry->sockaddrs->cmp = sockaddr_cmp; entry->sockaddrs->free_entry = sockaddr_free; @@ -318,13 +318,13 @@ _parse_from (struct acl_entry *entry, size_t argc, grecs_value_t **argv) if (rc) return rc; } if (argc - 1) { - grecs_warning (&entry->locus, 0, _("junk after `from' list")); + grecs_warning (&entry->locus, 0, _("junk after from-list")); return 1; } return 0; } static int @@ -351,14 +351,14 @@ _parse_sub_acl (struct acl_entry *entry, size_t argc, grecs_value_t **argv) } entry->acl = pies_acl_lookup (argv[0]->v.string); if (!entry->acl) { - grecs_error (&entry->locus, 0, _("ACL not defined: `%s'"), - argv[0]->v.string); + grecs_error (&entry->locus, 0, _("ACL not defined: %s"), + argv[0]->v.string); return 1; } argc--; argv++; } return _parse_from (entry, argc, argv); @@ -429,13 +429,13 @@ parse_acl_line (grecs_locus_t *locus, int allow, pies_acl_t acl, if (value) switch (value->type) { case GRECS_TYPE_STRING: if (_parse_token (entry, value)) { - grecs_error (&entry->locus, 0, _("unknown word `%s'"), + grecs_error (&entry->locus, 0, _("unknown word: %s"), value->v.string); return 1; } break; case GRECS_TYPE_ARRAY: @@ -537,42 +537,42 @@ component_verify (struct component *comp, grecs_locus_t *locus) if (comp->flags & CF_INTERNAL) { comp->mode = pies_comp_inetd; if (!comp->service) /* TRANSLATORS: do not translate quoted words, they are keywords. */ COMPERR (grecs_error, - "%s", _("`internal' used without `service'")); + "%s", _("\"internal\" used without \"service\"")); else { comp->builtin = inetd_builtin_lookup (comp->service, comp->socket_type); if (!comp->builtin) COMPERR (grecs_error, "%s", _("unknown internal service")); if (comp->argv) /* TRANSLATORS: do not translate quoted words, they are keywords. */ COMPERR (grecs_error, - "%s", _("`internal' used with `command'")); + "%s", _("\"internal\" used with \"command\"")); } } else if (!comp->argv) COMPERR (grecs_error, "%s", _("missing command line")); if (ISCF_TCPMUX (comp->flags)) { comp->mode = pies_comp_inetd; if ((comp->flags & (CF_TCPMUX | CF_TCPMUXPLUS)) == (CF_TCPMUX | CF_TCPMUXPLUS)) COMPERR (grecs_error, - "%s", _("both `tcpmux' and `tcpmuxplus' used")); + "%s", _("both \"tcpmux\" and \"tcpmuxplus\" used")); else if (!comp->service) /* TRANSLATORS: do not translate quoted words, they are keywords. */ COMPERR (grecs_error, - "%s", _("`internal' used without `service'")); + "%s", _("\"internal\" used without \"service\"")); } if (comp->pass_fd_socket && comp->mode != pies_comp_pass_fd) COMPERR (grecs_error, "%s", _("pass-fd-socket ignored: wrong mode")); switch (comp->mode) @@ -657,13 +657,13 @@ component_verify (struct component *comp, grecs_locus_t *locus) } if (comp->mode != pies_comp_exec && comp->redir[RETR_OUT].type != redir_null) { COMPERR (grecs_error, - "%s", _("stdout translation invalid in this mode")); + "%s", _("stdout redirection invalid in this mode")); comp->redir[RETR_OUT].type = redir_null; } for (i = RETR_OUT; i <= RETR_ERR; i++) { if (comp->redir[i].type == redir_file @@ -1242,13 +1242,13 @@ ctl_accept (int socket, void *data) socklen_t addrlen = sizeof addr; struct ctlio *io; fd = accept (socket, (struct sockaddr*) &addr, &addrlen); if (fd == -1) { - logmsg (LOG_ERR, _("accept failed: %s"), strerror (errno)); + logfuncall ("accept", NULL, errno); return 1; } if (debug_level >= 1) { char *s = sockaddr_to_astr ((struct sockaddr *)&addr, addrlen); @@ -1286,14 +1286,13 @@ ctl_open (void) control.url->string); return -1; } if (listen (fd, 8)) { - logmsg (LOG_CRIT, _("can't listen on control socket %s: %s"), - control.url->string, strerror (errno)); + logfuncall ("listen", control.url->string, errno); return -1; } register_socket (fd, ctl_accept, NULL, NULL, NULL); return 0; @@ -224,44 +224,22 @@ logmsg_printf (int prio, const char *fmt, ...) va_start (ap, fmt); logmsg_vprintf (prio, fmt, ap); va_end (ap); } void -grecs_print_diag (grecs_locus_t *locus, int err, int errcode, const char *msg) +pies_diag_printer (grecs_locus_t const *locus, int err, int errcode, + const char *msg) { - char *locstr = NULL; - if (locus) { - size_t size = 0; + char *locstr = NULL; + size_t locsize = 0; + + grecs_asprint_locus (&locstr, &locsize, locus); - if (locus->beg.col == 0) - grecs_asprintf (&locstr, &size, "%s:%u", - locus->beg.file, - locus->beg.line); - else if (strcmp (locus->beg.file, locus->end.file)) - grecs_asprintf (&locstr, &size, "%s:%u.%u-%s:%u.%u", - locus->beg.file, - locus->beg.line, locus->beg.col, - locus->end.file, - locus->end.line, locus->end.col); - else if (locus->beg.line != locus->end.line) - grecs_asprintf (&locstr, &size, "%s:%u.%u-%u.%u", - locus->beg.file, - locus->beg.line, locus->beg.col, - locus->end.line, locus->end.col); - else - grecs_asprintf (&locstr, &size, "%s:%u.%u-%u", - locus->beg.file, - locus->beg.line, locus->beg.col, - locus->end.col); - } - - if (locstr) - { if (errcode) logmsg (err ? LOG_ERR : LOG_WARNING, "%s: %s: %s", locstr, msg, strerror (errcode)); else logmsg (err ? LOG_ERR : LOG_WARNING, "%s: %s", locstr, msg); @@ -274,6 +252,14 @@ grecs_print_diag (grecs_locus_t *locus, int err, int errcode, const char *msg) strerror (errcode)); else logmsg (err ? LOG_ERR : LOG_WARNING, "%s", msg); } } +void +logfuncall (const char *fun, const char *arg, int err) +{ + if (arg) + grecs_error (NULL, err, _("%s: %s failed"), arg, fun); + else + grecs_error (NULL, err, _("%s failed"), fun); +} diff --git a/src/inetd-bi.c b/src/inetd-bi.c index 7ce4b39..2032123 100644 --- a/src/inetd-bi.c +++ b/src/inetd-bi.c @@ -225,13 +225,14 @@ static size_t qotd_read (char *text) { ssize_t rc; int fd = open (qotdfile, O_RDONLY); if (fd == -1) { - logmsg (LOG_ERR, _("cannot open %s: %s"), qotdfile, strerror (errno)); + logmsg (LOG_ERR, _("cannot open file %s: %s"), qotdfile, + strerror (errno)); strncpy (text, QOTD_DEF, QOTD_MAX); rc = QOTD_MAX; } else { rc = read (fd, text, QOTD_MAX); diff --git a/src/inetd.c b/src/inetd.c index ee16078..40fb6fe 100644 --- a/src/inetd.c +++ b/src/inetd.c @@ -352,14 +352,16 @@ inetd_conf_dir (const char *name) while ((ent = readdir (dir))) { struct stat st; if (stat (ent->d_name, &st)) { - logmsg (LOG_ERR, _("cannot stat %s/%s: %s"), - name, ent->d_name, strerror (errno)); + int ec = errno; + char *name = mkfilename (name, ent->d_name, NULL); + logfuncall ("stat", name, ec); + free (name); errs |= 1; } else if (S_ISREG (st.st_mode) || S_ISLNK (st.st_mode)) { size_t len = strlen (ent->d_name); if (namelen + len >= namebufsize) @@ -380,13 +382,13 @@ int inetd_config_parse (const char *file) { struct stat st; if (stat (file, &st)) { - logmsg (LOG_ERR, _("cannot stat %s: %s"), file, strerror (errno)); + logfuncall ("stat", file, errno); return 1; } if (S_ISDIR (st.st_mode)) return inetd_conf_dir (file); return inetd_conf_file (file); diff --git a/src/limits.c b/src/limits.c index 7387b9d..2893ff6 100644 --- a/src/limits.c +++ b/src/limits.c @@ -54,27 +54,26 @@ do_set_limit (int rlimit, rlim_t limit) debug (1, ("setting limit %d to %lu", rlimit, (unsigned long) limit)); rlim.rlim_cur = limit; rlim.rlim_max = limit; if (setrlimit(rlimit, &rlim)) { - logmsg (LOG_NOTICE, _("error setting limit: %s"), - strerror (errno)); + //FIXME: arg? + logfuncall ("setrlimit", NULL, errno); return 1; } return 0; } static int set_prio (int prio) { debug (2, ("Setting priority to %d", prio)); if (setpriority (PRIO_PROCESS, 0, prio)) { - logmsg (LOG_NOTICE, _("error setting priority: %s"), - strerror (errno)); + logfuncall ("setpriority", NULL, errno); return 1; } return 0; } /* Counts the number of user logins and check against the limit */ @@ -679,13 +679,13 @@ cb_syslog_facility (enum grecs_callback_command cmd, grecs_error (locus, 0, _("expected facility number or symbolic name")); else *(int *) varptr = n; } else if (string_to_syslog_facility (str, varptr)) - grecs_error (locus, 0, _("unknown syslog facility `%s'"), str); + grecs_error (locus, 0, _("unknown syslog facility %s"), str); return 0; } static int _cb_redir (enum grecs_callback_command cmd, grecs_locus_t *locus, @@ -708,13 +708,13 @@ _cb_redir (enum grecs_callback_command cmd, rp->type = redir_null; break; } rp->type = redir_syslog; if (string_to_syslog_priority (value->v.string, &rp->v.prio)) { - grecs_error (locus, 0, _("unknown syslog priority `%s'"), + grecs_error (locus, 0, _("unknown syslog priority %s"), value->v.string); return 0; } break; case GRECS_TYPE_ARRAY: @@ -744,13 +744,13 @@ _cb_redir (enum grecs_callback_command cmd, case redir_syslog: if (string_to_syslog_priority (value->v.arg.v[1]->v.string, &rp->v.prio)) { grecs_error (locus, 0, - _("unknown syslog priority `%s'"), + _("unknown syslog priority %s"), value->v.arg.v[1]->v.string); return 0; } break; case redir_file: @@ -1552,15 +1552,15 @@ pies_config_parse (char const *name) } void config_help () { static char docstring[] = - /* TRANSLATORS: do not translate words between ` and ' */ + /* TRANSLATORS: do not translate words in quotes */ N_("Configuration file structure for pies.\n" - "For more information, use `info pies configuration'."); + "For more information, use command \"info pies configuration\"."); grecs_print_docstring (docstring, 0, stdout); grecs_print_statement_array (pies_keywords, 1, 0, stdout); pies_config_identity_mechanisms_help (); } int @@ -1701,14 +1701,13 @@ pidfile_read (int must_exist) int c; pid_t n = 0; FILE *fp = fopen (pidfile, "r"); if (!fp) { if (must_exist && errno != ENOENT) - logmsg (LOG_ERR, - _("cannot open pid file `%s': %s"), + logmsg (LOG_ERR, _("cannot open file %s: %s"), pidfile, strerror (errno)); return -1; } while ((c = fgetc (fp)) != EOF) { @@ -1716,13 +1715,13 @@ pidfile_read (int must_exist) n = n * 10 + c - '0'; else if (c == '\n') break; else { logmsg (LOG_ERR, - _("unexpected character %#03o in pidfile `%s'"), + _("unexpected character %#03o in pidfile %s"), c, pidfile); return -1; } } fclose (fp); if (n && kill (n, 0)) @@ -1870,13 +1869,13 @@ check_pidfile (char *name) unsigned long pid; FILE *fp = fopen (name, "r"); if (!fp) { if (errno == ENOENT) return; - logmsg (LOG_ERR, _("cannot open pidfile `%s': %s"), + logmsg (LOG_ERR, _("cannot open file %s: %s"), name, strerror (errno)); exit (EX_TEMPFAIL); } if (fscanf (fp, "%lu", &pid) != 1) { logmsg (LOG_ERR, ("cannot get pid from pidfile `%s'"), name); @@ -1884,22 +1883,21 @@ check_pidfile (char *name) else { if (kill (pid, 0) == 0) { logmsg (LOG_ERR, _ - ("%s appears to run with pid %lu. If it does not, remove `%s' and retry."), + ("%s appears to run with pid %lu. If it does not, remove %s and retry."), program_name, pid, name); exit (EX_USAGE); } } fclose (fp); if (unlink (pidfile)) { - logmsg (LOG_ERR, _("cannot unlink pidfile `%s': %s"), - name, strerror (errno)); + logfuncall ("unlink", name, errno); exit (EX_USAGE); } } void create_pidfile (char *name) @@ -1916,14 +1914,13 @@ create_pidfile (char *name) } void remove_pidfile (char *name) { if (unlink (name)) - logmsg (LOG_ERR, _("cannot unlink pidfile `%s': %s"), - name, strerror (errno)); + logfuncall ("unlink", name, errno); } static void set_mailer_argcv () { @@ -1981,12 +1978,14 @@ main (int argc, char **argv) setlocale (LC_ALL, ""); bindtextdomain (PACKAGE, LOCALEDIR); textdomain (PACKAGE); #endif mf_proctitle_init (argc, argv, environ); + grecs_print_diag_fun = pies_diag_printer; + pies_master_argc = argc; pies_master_argv = argv; set_quoting_style (NULL, shell_quoting_style); init_process = getpid () == 1; @@ -2190,13 +2189,13 @@ main (int argc, char **argv) if (!foreground) { check_pidfile (pidfile); if (daemon (0, 0) == -1) { - logmsg (LOG_ERR, _("cannot become a daemon: %s"), strerror (errno)); + logfuncall ("daemon", NULL, errno); exit (EX_SOFTWARE); } diag_setup (DIAG_TO_SYSLOG); } if (!init_process) @@ -479,12 +479,16 @@ void diag_setup (int flags); void diagmsg (int logf, int prio, const char *fmt, ...) PIES_PRINTFLIKE(3,4); void logmsg (int prio, const char *fmt, ...) PIES_PRINTFLIKE(2,3); void logmsg_printf (int prio, const char *fmt, ...) PIES_PRINTFLIKE(2,3); void logmsg_vprintf (int prio, const char *fmt, va_list ap); +void logfuncall (const char *fun, const char *arg, int err); + +void pies_diag_printer (grecs_locus_t const *locus, int err, int errcode, + const char *msg); extern unsigned debug_level; extern int source_info_option; void debug_msg (const char *fmt, ...) PIES_PRINTFLIKE(1,2); #define debug(lev, args) \ diff --git a/src/piesctl.c b/src/piesctl.c index 310dcc3..f4ea514 100644 --- a/src/piesctl.c +++ b/src/piesctl.c @@ -223,15 +223,16 @@ parse_config () printf (_("%s: using URL %s\n"), program_name, client.url->string); } static void config_help (void) { + /* TRANSLATORS: do not translate words in quotes */ static char docstring[] = N_("Configuration file structure for piesctl.\n" - "For more information, use `info piesctl configuration'."); + "For more information, use command \"info piesctl configuration\"."); grecs_print_docstring (docstring, 0, stdout); grecs_print_statement_array (piesctl_keywords, 1, 0, stdout); } static void piesctl_diag (grecs_locus_t const *locus, int err, int errcode, @@ -443,26 +444,21 @@ shttp_connect (struct pies_url *url, struct grecs_sockaddr *source_addr) strcpy (addr.s_un.sun_path, url->path); if (stat (url->path, &st)) { if (errno != ENOENT) { - grecs_error (NULL, 0, - _("%s: cannot stat socket: %s"), - url->path, - strerror (errno)); + grecs_error (NULL, errno, _("%s: %s failed"), url->path, "stat"); return NULL; } } else { if (!S_ISSOCK (st.st_mode)) { - grecs_error (NULL, 0, - _("%s: not a socket"), - url->path); + grecs_error (NULL, 0, _("%s: not a socket"), url->path); return NULL; } } } else if (strcmp (url->scheme, "inet") == 0) { @@ -496,54 +492,51 @@ shttp_connect (struct pies_url *url, struct grecs_sockaddr *source_addr) url->string); return NULL; } } else { - grecs_error (NULL, 0, _("%s: unsupported protocol"), - url->string); + grecs_error (NULL, 0, _("%s: unsupported protocol"), url->string); return NULL; } fd = socket (addr.s.sa_family, SOCK_STREAM, 0); if (fd == -1) { - grecs_error (NULL, 0, _("%s: unable to create socket: %s"), - url->string, strerror(errno)); + grecs_error (NULL, errno, _("%s: %s failed"), url->string, "socket"); return NULL; } if ((flags = fcntl (fd, F_GETFD, 0)) == -1 - || fcntl (fd, F_SETFD, flags | FD_CLOEXEC) == -1) + || fcntl (fd, F_SETFD, flags | FD_CLOEXEC) == -1) grecs_error (NULL, 0, _("%s: cannot set close-on-exec: %s"), url->string, strerror (errno)); if (source_addr) { if (source_addr->sa->sa_family != addr.s.sa_family) grecs_error (NULL, 0, _("source and destination address family differ")); else if (bind (fd, source_addr->sa, source_addr->len) < 0) { - grecs_error (NULL, errno, _("failed to bind")); + grecs_error (NULL, errno, _("%s: %s failed"), url->string, "bind"); exit (EX_UNAVAILABLE); } } if (connect (fd, &addr.s, socklen)) { - grecs_error (NULL, 0, _("%s: cannot connect: %s"), - url->string, strerror (errno)); + grecs_error (NULL, errno, _("%s: %s failed"), url->string, "connect"); close (fd); return NULL; } fp = fdopen (fd, "w+"); if (!fp) { - grecs_error (NULL, 0, "fdopen: %s", strerror (errno)); + grecs_error (NULL, errno, _("%s: %s failed"), url->string, "fdopen"); close (fd); return NULL; } conn = grecs_zalloc (sizeof (*conn)); conn->fp = fp; @@ -2151,12 +2144,15 @@ static struct comtab comtab[] = { N_("stop components"), com_stop }, { "start", N_("CONDITION"), N_("start components"), com_start }, { "restart", N_("CONDITION"), N_("restart components"), com_restart }, { NULL, NULL, + /* TRANSLATORS: You can leave the BNF below untranslated. If you + chose to translate it, please do not translate words in double + quotes. */ N_("CONDITION is defined as follows:\ \n\ <condition> ::= <disjunction>\n\ <disjunction> ::= <conjunction> | <conjunction> \"or\" <disjunction>\n\ <conjunction> ::= <unary> | <unary> \"and\" <conjunction>\n\ <unary> ::= <term> | \"not\" <condition> | \"(\" <condition> \")\"\n\ @@ -2172,23 +2168,25 @@ static struct comtab comtab[] = { NULL }, { "id", N_("[KEYWORDS...]"), N_("show info about the running GNU Pies instance"), com_id }, { NULL, NULL, + /* TRANSLATORS: Please don't translate the keywords. */ N_("Available KEYWORDS are: package, version, instance, binary, argv, PID"), NULL }, { "shutdown", "", N_("stop running pies instance"), com_shutdown }, { "reboot", "", N_("restart pies instance"), com_reboot }, { "config", "reload", N_("reload configuration"), com_config }, { NULL, "file clear", N_("clear configuration file list"), NULL }, - { NULL, "file add SYNTAX FILE", + /* TRANSLATORS: Translate only words in upper case */ + { NULL, N_("file add SYNTAX FILE"), N_("add FILE of given SYNTAX to the list of configuration files"), NULL }, { NULL, "file del[ete] NAME [NAME...]", N_("remove listed names from the list of configuration files"), NULL }, { NULL, "file list", N_("list configuration files"), NULL }, diff --git a/src/progman.c b/src/progman.c index f68fe91..547f806 100644 --- a/src/progman.c +++ b/src/progman.c @@ -1002,14 +1002,13 @@ prog_start_prologue (struct prog *prog) { int i; struct component *comp = prog->v.p.comp; logmsg_printf (LOG_DEBUG, "executing"); for (i = 0; i < comp->argc; i++) - logmsg_printf (LOG_DEBUG, " %s", - quotearg (comp->argv[i])); + logmsg_printf (LOG_DEBUG, " %s", quotearg (comp->argv[i])); logmsg_printf (LOG_DEBUG, "\n"); } } static void prog_execute (struct prog *prog) @@ -1088,15 +1087,13 @@ prog_start (struct prog *prog) case pies_comp_pass_fd: if (check_spawn_rate (prog)) return; debug (1, (_("unlinking %s"), prog->v.p.comp->pass_fd_socket)); if (unlink (prog->v.p.comp->pass_fd_socket) && errno != ENOENT) { - logmsg (LOG_ERR, _("cannot unlink %s: %s"), - prog->v.p.comp->pass_fd_socket, - strerror (errno)); + logfuncall ("unlink", prog->v.p.comp->pass_fd_socket, errno); return; } if (prog_open_socket (prog)) return; break; @@ -1321,13 +1318,13 @@ _prog_accept (struct prog *p) socklen_t addrlen = sizeof addr; struct conn_class *pcclass; fd = accept (p->v.p.socket, (struct sockaddr*) &addr, &addrlen); if (fd == -1) { - logmsg (LOG_ERR, _("accept failed: %s"), strerror (errno)); + logfuncall ("accept", NULL, errno); return 1; } if (debug_level >= 1) { char *s = sockaddr_to_astr ((struct sockaddr *)&addr, addrlen); @@ -1845,13 +1842,13 @@ propagate_child_exit (pid_t pid) { int wait_status; while (waitpid (pid, &wait_status, 0) == -1) if (errno != EINTR) { - logmsg (LOG_ERR, _("waitpid failed: %s"), strerror (errno)); + logfuncall ("waitpid", NULL, errno); exit (EX_OSERR); } if (WIFSIGNALED (wait_status)) { int sig = WTERMSIG (wait_status); @@ -2399,13 +2396,13 @@ progman_stop_component (struct prog **progptr) struct prog *prog = *progptr; if (prog && IS_COMPONENT (prog)) { switch (prog->v.p.status) { case status_running: - logmsg (LOG_INFO, _("stopping component `%s'"), prog_tag (prog)); + logmsg (LOG_INFO, _("stopping component %s"), prog_tag (prog)); prog_stop (prog, SIGTERM); break; case status_listener: prog_deactivate_listener (prog); /* fall through */ @@ -2419,13 +2416,13 @@ progman_stop_component (struct prog **progptr) if (!component_is_active (prog->v.p.comp)) destroy_prog (progptr); else if (prog->v.p.stop) prog->v.p.stop = 0; else { - logmsg (LOG_INFO, _("waking up component `%s'"), prog_tag (prog)); + logmsg (LOG_INFO, _("waking up component %s"), prog_tag (prog)); prog->v.p.failcount = 0; } break; case status_stopping: break; @@ -2433,35 +2430,35 @@ progman_stop_component (struct prog **progptr) case status_finished: prog->v.p.stop = 0; if (!component_is_active (prog->v.p.comp)) destroy_prog (progptr); else logmsg (LOG_INFO, - _("stopping component `%s': component not started"), + _("stopping component %s: component not started"), prog_tag (prog)); } } } void prog_deactivate_listener (struct prog *prog) { - logmsg (LOG_INFO, _("deactivating listener `%s'"), prog_tag (prog)); + logmsg (LOG_INFO, _("deactivating listener %s"), prog_tag (prog)); if (prog->v.p.socket != -1) { deregister_socket (prog->v.p.socket); prog->v.p.socket = -1; } } int prog_activate_listener (struct prog *prog) { struct component *comp = prog->v.p.comp; - logmsg (LOG_INFO, _("activating listener `%s'"), prog_tag (prog)); + logmsg (LOG_INFO, _("activating listener %s"), prog_tag (prog)); if (comp->mode == pies_comp_inetd && !ISCF_TCPMUX (comp->flags) && prog->v.p.socket == -1) { int fd = create_socket (comp->socket_url, comp->socket_type, comp->privs.user, comp->umask); diff --git a/src/socket.c b/src/socket.c index 3223a65..90833e5 100644 --- a/src/socket.c +++ b/src/socket.c @@ -133,14 +133,13 @@ create_socket (struct pies_url *url, int socket_type, socklen = sizeof (addr.s_un); strcpy (addr.s_un.sun_path, url->path); if (stat (url->path, &st)) { if (errno != ENOENT) { - logmsg (LOG_ERR, _("%s: cannot stat socket: %s"), - url->string, strerror (errno)); + logfuncall ("stat", url->string, errno); return -1; } } else { /* FIXME: Check permissions? */ @@ -148,14 +147,13 @@ create_socket (struct pies_url *url, int socket_type, { logmsg (LOG_ERR, _("%s: not a socket"), url->string); return -1; } if (/*rmsocket && */ unlink (url->path)) { - logmsg (LOG_ERR, _("%s: cannot unlink: %s"), - url->path, strerror (errno)); + logfuncall ("unlink", url->path, errno); return -1; } } } else if (strcmp (url->scheme, "inet") == 0) { @@ -201,23 +199,22 @@ create_socket (struct pies_url *url, int socket_type, return -1; } fd = socket (addr.sa.sa_family, socket_type, url->proto); if (fd == -1) { - logmsg (LOG_ERR, _("%s: cannot create socket: %s"), - url->string, strerror (errno)); + logfuncall ("socket", url->string, errno); return -1; } rc = 1; if (addr.sa.sa_family != PF_UNIX && setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (void *) &rc, sizeof (rc)) == -1) { - logmsg (LOG_ERR, _("%s: set reuseaddr failed (%s)"), + logmsg (LOG_ERR, _("%s: set reuseaddr failed: %s"), url->string, strerror (errno)); close (fd); return -1; } if (uid || gid || umaskval) @@ -225,18 +222,18 @@ create_socket (struct pies_url *url, int socket_type, switch_eids (&uid, &gid, &umaskval); switch_back = 1; } else switch_back = 0; rc = bind (fd, &addr.sa, socklen); + if (rc < 0) + logfuncall ("bind", NULL, errno); if (switch_back) switch_eids (&uid, &gid, &umaskval); if (rc < 0) { - logmsg (LOG_ERR, _("%s: cannot bind: %s"), - url->string, strerror (errno)); close (fd); return -1; } return fd; } @@ -351,14 +348,13 @@ pass_fd (const char *socket_name, int fd, unsigned maxtime) { case EINTR: case ECONNREFUSED: case EAGAIN: continue; } - logmsg (LOG_ERR, _("%s: connect failed: %s"), - socket_name, strerror (errno)); + logfuncall ("connect", socket_name, errno); break; } state = fds_connected; } if (state == fds_connected) @@ -375,13 +371,13 @@ pass_fd (const char *socket_name, int fd, unsigned maxtime) if (rc == 0) continue; if (rc < 0) { if (errno == EINTR) continue; - logmsg (LOG_ERR, _("select failed: %s"), strerror (errno)); |