From 6e73a7b0822d1fd506c75a662070f447bba94afb Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Tue, 23 Feb 2016 11:36:33 +0200 Subject: 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. --- src/acl.c | 22 +++++++++++----------- src/comp.c | 10 +++++----- src/ctl.c | 5 ++--- src/diag.c | 42 ++++++++++++++---------------------------- src/inetd-bi.c | 3 ++- src/inetd.c | 8 +++++--- src/limits.c | 7 +++---- src/pies.c | 29 ++++++++++++++--------------- src/pies.h | 4 ++++ src/piesctl.c | 34 ++++++++++++++++------------------ src/progman.c | 21 +++++++++------------ src/socket.c | 20 ++++++++------------ src/sysvinit.c | 7 +++---- 13 files changed, 96 insertions(+), 116 deletions(-) (limited to 'src') diff --git a/src/acl.c b/src/acl.c index 53e5dd8..7b834c9 100644 --- a/src/acl.c +++ b/src/acl.c @@ -177,7 +177,7 @@ _parse_sockaddr (struct acl_entry *entry, const grecs_value_t *value) 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)); @@ -200,7 +200,7 @@ _parse_sockaddr (struct acl_entry *entry, const grecs_value_t *value) if (!hp) { grecs_error (&entry->locus, 0, - _("cannot resolve host name: `%s'"), string); + _("cannot resolve host name: %s"), string); if (p) *p = '/'; return 1; @@ -237,14 +237,14 @@ _parse_sockaddr (struct acl_entry *entry, const grecs_value_t *value) 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; } } @@ -281,12 +281,12 @@ _parse_from (struct acl_entry *entry, size_t argc, grecs_value_t **argv) 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; } @@ -296,7 +296,7 @@ _parse_from (struct acl_entry *entry, size_t argc, grecs_value_t **argv) if (argc == 0) { grecs_error (&entry->locus, 0, - _("unexpected end of statement after `from'")); + _("unexpected end of statement after \"from\"")); return 1; } @@ -321,7 +321,7 @@ _parse_from (struct acl_entry *entry, size_t argc, grecs_value_t **argv) 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; @@ -354,8 +354,8 @@ _parse_sub_acl (struct acl_entry *entry, size_t argc, grecs_value_t **argv) 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--; @@ -432,7 +432,7 @@ parse_acl_line (grecs_locus_t *locus, int allow, pies_acl_t acl, 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; } diff --git a/src/comp.c b/src/comp.c index 43772c2..7babae7 100644 --- a/src/comp.c +++ b/src/comp.c @@ -540,7 +540,7 @@ component_verify (struct component *comp, grecs_locus_t *locus) 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, @@ -552,7 +552,7 @@ component_verify (struct component *comp, grecs_locus_t *locus) /* 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) @@ -565,11 +565,11 @@ component_verify (struct component *comp, grecs_locus_t *locus) 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) @@ -660,7 +660,7 @@ component_verify (struct component *comp, grecs_locus_t *locus) && 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; } diff --git a/src/ctl.c b/src/ctl.c index 7d44cf1..fd7bfdc 100644 --- a/src/ctl.c +++ b/src/ctl.c @@ -1245,7 +1245,7 @@ ctl_accept (int socket, void *data) fd = accept (socket, (struct sockaddr*) &addr, &addrlen); if (fd == -1) { - logmsg (LOG_ERR, _("accept failed: %s"), strerror (errno)); + logfuncall ("accept", NULL, errno); return 1; } @@ -1289,8 +1289,7 @@ ctl_open (void) 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; } diff --git a/src/diag.c b/src/diag.c index f601daf..eaf9bed 100644 --- a/src/diag.c +++ b/src/diag.c @@ -227,38 +227,16 @@ logmsg_printf (int prio, const char *fmt, ...) } 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)); @@ -277,3 +255,11 @@ grecs_print_diag (grecs_locus_t *locus, int err, int errcode, const char *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 @@ -228,7 +228,8 @@ qotd_read (char *text) 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; } diff --git a/src/inetd.c b/src/inetd.c index ee16078..40fb6fe 100644 --- a/src/inetd.c +++ b/src/inetd.c @@ -355,8 +355,10 @@ inetd_conf_dir (const char *name) 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)) @@ -383,7 +385,7 @@ inetd_config_parse (const char *file) 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)) diff --git a/src/limits.c b/src/limits.c index 7387b9d..2893ff6 100644 --- a/src/limits.c +++ b/src/limits.c @@ -57,8 +57,8 @@ do_set_limit (int rlimit, rlim_t limit) if (setrlimit(rlimit, &rlim)) { - logmsg (LOG_NOTICE, _("error setting limit: %s"), - strerror (errno)); + //FIXME: arg? + logfuncall ("setrlimit", NULL, errno); return 1; } return 0; @@ -70,8 +70,7 @@ 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; diff --git a/src/pies.c b/src/pies.c index 3d7f593..36b869a 100644 --- a/src/pies.c +++ b/src/pies.c @@ -682,7 +682,7 @@ cb_syslog_facility (enum grecs_callback_command cmd, *(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; } @@ -711,7 +711,7 @@ _cb_redir (enum grecs_callback_command cmd, 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; } @@ -747,7 +747,7 @@ _cb_redir (enum grecs_callback_command cmd, &rp->v.prio)) { grecs_error (locus, 0, - _("unknown syslog priority `%s'"), + _("unknown syslog priority %s"), value->v.arg.v[1]->v.string); return 0; } @@ -1555,9 +1555,9 @@ 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 (); @@ -1704,8 +1704,7 @@ pidfile_read (int must_exist) 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; } @@ -1719,7 +1718,7 @@ pidfile_read (int must_exist) else { logmsg (LOG_ERR, - _("unexpected character %#03o in pidfile `%s'"), + _("unexpected character %#03o in pidfile %s"), c, pidfile); return -1; } @@ -1873,7 +1872,7 @@ check_pidfile (char *name) { 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); } @@ -1887,7 +1886,7 @@ check_pidfile (char *name) { 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); } @@ -1895,8 +1894,7 @@ check_pidfile (char *name) fclose (fp); if (unlink (pidfile)) { - logmsg (LOG_ERR, _("cannot unlink pidfile `%s': %s"), - name, strerror (errno)); + logfuncall ("unlink", name, errno); exit (EX_USAGE); } } @@ -1919,8 +1917,7 @@ void remove_pidfile (char *name) { if (unlink (name)) - logmsg (LOG_ERR, _("cannot unlink pidfile `%s': %s"), - name, strerror (errno)); + logfuncall ("unlink", name, errno); } @@ -1984,6 +1981,8 @@ main (int argc, char **argv) #endif mf_proctitle_init (argc, argv, environ); + grecs_print_diag_fun = pies_diag_printer; + pies_master_argc = argc; pies_master_argv = argv; @@ -2193,7 +2192,7 @@ main (int argc, char **argv) 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); diff --git a/src/pies.h b/src/pies.h index 93f90b1..3528e82 100644 --- a/src/pies.h +++ b/src/pies.h @@ -482,6 +482,10 @@ void diagmsg (int logf, int prio, const char *fmt, ...) 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; diff --git a/src/piesctl.c b/src/piesctl.c index 310dcc3..f4ea514 100644 --- a/src/piesctl.c +++ b/src/piesctl.c @@ -226,9 +226,10 @@ parse_config () 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); } @@ -446,10 +447,7 @@ shttp_connect (struct pies_url *url, struct grecs_sockaddr *source_addr) { 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; } } @@ -457,9 +455,7 @@ shttp_connect (struct pies_url *url, struct grecs_sockaddr *source_addr) { 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; } } @@ -499,21 +495,19 @@ shttp_connect (struct pies_url *url, struct grecs_sockaddr *source_addr) } 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)); @@ -524,15 +518,14 @@ shttp_connect (struct pies_url *url, struct grecs_sockaddr *source_addr) _("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; } @@ -540,7 +533,7 @@ shttp_connect (struct pies_url *url, struct grecs_sockaddr *source_addr) 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; } @@ -2154,6 +2147,9 @@ static struct comtab comtab[] = { { "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\ ::= \n\ @@ -2175,6 +2171,7 @@ static struct comtab comtab[] = { 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 }, @@ -2185,7 +2182,8 @@ static struct comtab comtab[] = { 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 }, diff --git a/src/progman.c b/src/progman.c index f68fe91..547f806 100644 --- a/src/progman.c +++ b/src/progman.c @@ -1005,8 +1005,7 @@ prog_start_prologue (struct prog *prog) 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"); } } @@ -1091,9 +1090,7 @@ prog_start (struct prog *prog) 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)) @@ -1324,7 +1321,7 @@ _prog_accept (struct prog *p) 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; } @@ -1848,7 +1845,7 @@ propagate_child_exit (pid_t pid) 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); } @@ -2402,7 +2399,7 @@ progman_stop_component (struct prog **progptr) 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; @@ -2422,7 +2419,7 @@ progman_stop_component (struct prog **progptr) 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; @@ -2436,7 +2433,7 @@ progman_stop_component (struct prog **progptr) destroy_prog (progptr); else logmsg (LOG_INFO, - _("stopping component `%s': component not started"), + _("stopping component %s: component not started"), prog_tag (prog)); } } @@ -2445,7 +2442,7 @@ progman_stop_component (struct prog **progptr) 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); @@ -2458,7 +2455,7 @@ 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) { diff --git a/src/socket.c b/src/socket.c index 3223a65..90833e5 100644 --- a/src/socket.c +++ b/src/socket.c @@ -136,8 +136,7 @@ create_socket (struct pies_url *url, int socket_type, { if (errno != ENOENT) { - logmsg (LOG_ERR, _("%s: cannot stat socket: %s"), - url->string, strerror (errno)); + logfuncall ("stat", url->string, errno); return -1; } } @@ -151,8 +150,7 @@ create_socket (struct pies_url *url, int socket_type, } if (/*rmsocket && */ unlink (url->path)) { - logmsg (LOG_ERR, _("%s: cannot unlink: %s"), - url->path, strerror (errno)); + logfuncall ("unlink", url->path, errno); return -1; } } @@ -204,8 +202,7 @@ create_socket (struct pies_url *url, int socket_type, 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; } @@ -214,7 +211,7 @@ create_socket (struct pies_url *url, int socket_type, && 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; @@ -228,12 +225,12 @@ create_socket (struct pies_url *url, int socket_type, 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; } @@ -354,8 +351,7 @@ pass_fd (const char *socket_name, int fd, unsigned maxtime) case EAGAIN: continue; } - logmsg (LOG_ERR, _("%s: connect failed: %s"), - socket_name, strerror (errno)); + logfuncall ("connect", socket_name, errno); break; } state = fds_connected; @@ -378,7 +374,7 @@ pass_fd (const char *socket_name, int fd, unsigned maxtime) { if (errno == EINTR) continue; - logmsg (LOG_ERR, _("select failed: %s"), strerror (errno)); + logfuncall ("select", NULL, errno); break; } state = fds_ready; diff --git a/src/sysvinit.c b/src/sysvinit.c index cc26fa9..6bc918c 100644 --- a/src/sysvinit.c +++ b/src/sysvinit.c @@ -879,7 +879,7 @@ telinit (const char *arg) fd = open (init_fifo, O_WRONLY); if (fd < 0) { - logmsg (LOG_ERR, _("can't open %s: %s"), init_fifo, strerror (errno)); + logmsg (LOG_ERR, _("cannot open %s: %s"), init_fifo, strerror (errno)); exit (EX_UNAVAILABLE); } if (write (fd, &req, sizeof (req)) != sizeof (req)) @@ -1173,11 +1173,10 @@ sysvinit_power (void) } close (fd); if (unlink (power_stat_file)) - logmsg (LOG_ERR, _("can't unlink %s: %s"), power_stat_file, - strerror (errno)); + logfuncall ("unlink", power_stat_file, errno); } else - debug (1, (_("can't open %s: %s"), power_stat_file, strerror (errno))); + debug (1, (_("cannot open %s: %s"), power_stat_file, strerror (errno))); powerfailcmd (power_stat); } -- cgit v1.2.1