-/* $OpenBSD: syslogd.c,v 1.236 2017/04/05 15:16:12 bluhm Exp $ */
+/* $OpenBSD: syslogd.c,v 1.237 2017/04/05 19:34:49 bluhm Exp $ */
/*
* Copyright (c) 1983, 1988, 1993, 1994
void fprintlog(struct filed *, int, char *);
void init(void);
void logevent(int, const char *);
-void logerror(const char *);
-void logerrorx(const char *);
-void logerrorctx(const char *, struct tls *);
-void logerrortlsconf(const char *, struct tls_config *);
-void logerror_reason(const char *, const char *);
void logmsg(int, char *, char *, int);
struct filed *find_dup(struct filed *);
size_t parsepriority(const char *, int *);
if (socket_bind("udp", NULL, "syslog", SecureMode,
&fd_udp, &fd_udp6) == -1)
- logerrorx("socket bind *");
+ log_warnx("socket bind * failed");
if ((fd_bind = reallocarray(NULL, nbind, sizeof(*fd_bind))) == NULL)
fatal("allocate bind fd");
for (i = 0; i < nbind; i++) {
if (socket_bind("udp", bind_host[i], bind_port[i], 0,
&fd_bind[i], &fd_bind[i]) == -1)
- logerrorx("socket bind udp");
+ log_warnx("socket bind udp failed");
}
if ((fd_listen = reallocarray(NULL, nlisten, sizeof(*fd_listen)))
== NULL)
for (i = 0; i < nlisten; i++) {
if (socket_bind("tcp", listen_host[i], listen_port[i], 0,
&fd_listen[i], &fd_listen[i]) == -1)
- logerrorx("socket listen tcp");
+ log_warnx("socket listen tcp failed");
}
fd_tls = -1;
if (tls_host && socket_bind("tls", tls_host, tls_port, 0,
&fd_tls, &fd_tls) == -1)
- logerrorx("socket listen tls");
+ log_warnx("socket listen tls failed");
if ((fd_unix = reallocarray(NULL, nunix, sizeof(*fd_unix))) == NULL)
fatal("allocate unix fd");
fd_unix[i] = unix_socket(path_unix[i], SOCK_DGRAM, 0666);
if (fd_unix[i] == -1) {
if (i == 0)
- logerrorx("log socket failed");
+ log_warnx("log socket %s failed", path_unix[i]);
continue;
}
double_sockbuf(fd_unix[i], SO_RCVBUF);
}
if (socketpair(AF_UNIX, SOCK_DGRAM, PF_UNSPEC, pair) == -1) {
- logerror("socketpair");
+ log_warn("socketpair sendsyslog");
fd_sendsys = -1;
} else {
double_sockbuf(pair[0], SO_RCVBUF);
if (path_ctlsock != NULL) {
fd_ctlsock = unix_socket(path_ctlsock, SOCK_STREAM, 0600);
if (fd_ctlsock == -1) {
- log_debug("can't open %s (%d)", path_ctlsock, errno);
+ log_warnx("control socket %s failed", path_ctlsock);
} else {
if (listen(fd_ctlsock, 5) == -1) {
- logerror("ctlsock listen");
+ log_warn("listen control socket");
close(fd_ctlsock);
fd_ctlsock = -1;
}
}
if ((fd_klog = open(_PATH_KLOG, O_RDONLY, 0)) == -1) {
- log_debug("can't open %s (%d)", _PATH_KLOG, errno);
+ log_warn("open %s", _PATH_KLOG);
} else if (fd_sendsys != -1) {
if (ioctl(fd_klog, LIOCSFD, &pair[1]) == -1)
- log_debug("LIOCSFD errno %d", errno);
+ log_warn("ioctl klog LIOCSFD sendsyslog");
}
if (fd_sendsys != -1)
close(pair[1]);
if (tls_init() == -1) {
- logerrorx("tls_init");
+ log_warn("tls_init");
} else {
if ((client_config = tls_config_new()) == NULL)
- logerror("tls_config_new client");
+ log_warn("tls_config_new client");
if (tls_hostport) {
if ((server_config = tls_config_new()) == NULL)
- logerror("tls_config_new server");
+ log_warn("tls_config_new server");
if ((server_ctx = tls_server()) == NULL) {
- logerror("tls_server");
+ log_warn("tls_server");
close(fd_tls);
fd_tls = -1;
}
} else {
if (tls_config_set_ca_file(client_config,
CAfile) == -1) {
- logerrortlsconf("Load client TLS CA failed",
- client_config);
+ log_warnx("load client TLS CA: %s",
+ tls_config_error(client_config));
/* avoid reading default certs in chroot */
tls_config_set_ca_mem(client_config, "", 0);
} else
if (ClientCertfile && ClientKeyfile) {
if (tls_config_set_cert_file(client_config,
ClientCertfile) == -1)
- logerrortlsconf("Load client TLS cert failed",
- client_config);
+ log_warnx("load client TLS cert: %s",
+ tls_config_error(client_config));
else
log_debug("ClientCertfile %s", ClientCertfile);
if (tls_config_set_key_file(client_config,
ClientKeyfile) == -1)
- logerrortlsconf("Load client TLS key failed",
- client_config);
+ log_warnx("load client TLS key: %s",
+ tls_config_error(client_config));
else
log_debug("ClientKeyfile %s", ClientKeyfile);
} else if (ClientCertfile || ClientKeyfile) {
- logerrorx("options -c and -k must be used together");
+ log_warnx("options -c and -k must be used together");
}
if (tls_config_set_protocols(client_config,
TLS_PROTOCOLS_ALL) != 0)
- logerrortlsconf("Set client TLS protocols failed",
- client_config);
+ log_warnx("set client TLS protocols: %s",
+ tls_config_error(client_config));
if (tls_config_set_ciphers(client_config, "all") != 0)
- logerrortlsconf("Set client TLS ciphers failed",
- client_config);
+ log_warnx("set client TLS ciphers: %s",
+ tls_config_error(client_config));
}
if (server_config && server_ctx) {
const char *names[2];
== -1)
continue;
if (tls_config_set_key_file(server_config, p) == -1) {
- logerrortlsconf("Load server TLS key failed",
- server_config);
+ log_warnx("load server TLS key: %s",
+ tls_config_error(server_config));
free(p);
continue;
}
if (asprintf(&p, "/etc/ssl/%s.crt", names[i]) == -1)
continue;
if (tls_config_set_cert_file(server_config, p) == -1) {
- logerrortlsconf("Load server TLS cert failed",
- server_config);
+ log_warnx("load server TLS cert: %s",
+ tls_config_error(server_config));
free(p);
continue;
}
if (ServerCAfile) {
if (tls_config_set_ca_file(server_config,
ServerCAfile) == -1) {
- logerrortlsconf("Load server TLS CA failed",
- server_config);
+ log_warnx("load server TLS CA: %s",
+ tls_config_error(server_config));
/* avoid reading default certs in chroot */
tls_config_set_ca_mem(server_config, "", 0);
} else
}
if (tls_config_set_protocols(server_config,
TLS_PROTOCOLS_ALL) != 0)
- logerrortlsconf("Set server TLS protocols failed",
- server_config);
+ log_warnx("set server TLS protocols: %s",
+ tls_config_error(server_config));
if (tls_config_set_ciphers(server_config, "compat") != 0)
- logerrortlsconf("Set server TLS ciphers failed",
- server_config);
+ log_warnx("Set server TLS ciphers: %s",
+ tls_config_error(server_config));
if (tls_configure(server_ctx, server_config) != 0) {
- logerrorctx("tls_configure server", server_ctx);
+ log_warnx("tls_configure server: %s",
+ tls_error(server_ctx));
tls_free(server_ctx);
server_ctx = NULL;
close(fd_tls);
{
struct addrinfo hints, *res, *res0;
char hostname[NI_MAXHOST], servname[NI_MAXSERV];
- char ebuf[ERRBUFSIZE];
int *fdp, error, reuseaddr;
*fd = *fd6 = -1;
hints.ai_flags = AI_PASSIVE;
if ((error = getaddrinfo(host, port, &hints, &res0))) {
- snprintf(ebuf, sizeof(ebuf), "getaddrinfo "
- "proto %s, host %s, port %s: %s",
+ log_warnx("getaddrinfo proto %s, host %s, port %s: %s",
proto, host ? host : "*", port, gai_strerror(error));
- logerrorx(ebuf);
return (-1);
}
hostname[0] = servname[0] = '\0';
}
if (shutread && shutdown(*fdp, SHUT_RD) == -1) {
- snprintf(ebuf, sizeof(ebuf), "shutdown SHUT_RD "
+ log_warn("shutdown SHUT_RD "
"protocol %d, address %s, portnum %s",
res->ai_protocol, hostname, servname);
- logerror(ebuf);
close(*fdp);
*fdp = -1;
continue;
reuseaddr = 1;
if (setsockopt(*fdp, SOL_SOCKET, SO_REUSEADDR, &reuseaddr,
sizeof(reuseaddr)) == -1) {
- snprintf(ebuf, sizeof(ebuf), "setsockopt SO_REUSEADDR "
+ log_warn("setsockopt SO_REUSEADDR "
"protocol %d, address %s, portnum %s",
res->ai_protocol, hostname, servname);
- logerror(ebuf);
close(*fdp);
*fdp = -1;
continue;
}
if (bind(*fdp, res->ai_addr, res->ai_addrlen) == -1) {
- snprintf(ebuf, sizeof(ebuf), "bind "
- "protocol %d, address %s, portnum %s",
+ log_warn("bind protocol %d, address %s, portnum %s",
res->ai_protocol, hostname, servname);
- logerror(ebuf);
close(*fdp);
*fdp = -1;
continue;
}
if (!shutread && res->ai_protocol == IPPROTO_TCP &&
listen(*fdp, 10) == -1) {
- snprintf(ebuf, sizeof(ebuf), "listen "
- "protocol %d, address %s, portnum %s",
+ log_warn("listen protocol %d, address %s, portnum %s",
res->ai_protocol, hostname, servname);
- logerror(ebuf);
close(*fdp);
*fdp = -1;
continue;
linebuf[n] = '\0';
printsys(linebuf);
} else if (n < 0 && errno != EINTR) {
- logerror("klog");
+ log_warn("read klog");
event_del(ev);
}
}
log_debug("cvthname res: %s", resolve);
printline(resolve, linebuf);
} else if (n < 0 && errno != EINTR && errno != EWOULDBLOCK)
- logerror("recvfrom udp");
+ log_warn("recvfrom udp");
}
void
linebuf[n] = '\0';
printline(LocalHostName, linebuf);
} else if (n < 0 && errno != EINTR && errno != EWOULDBLOCK)
- logerror("recvfrom unix");
+ log_warn("recvfrom unix");
}
int
if (errno != ENFILE && errno != EMFILE &&
errno != EINTR && errno != EWOULDBLOCK &&
errno != ECONNABORTED)
- logerror("accept tcp socket");
+ log_warn("accept tcp socket");
return;
}
log_debug("Accepting tcp connection");
}
log_debug("Peer addresss and port %s", peername);
if ((p = malloc(sizeof(*p))) == NULL) {
- snprintf(ebuf, sizeof(ebuf), "malloc \"%s\"", peername);
- logerror(ebuf);
+ log_warn("allocate \"%s\"", peername);
close(fd);
return;
}
p->p_fd = fd;
if ((p->p_bufev = bufferevent_new(fd, tcp_readcb, NULL, tcp_closecb,
p)) == NULL) {
- snprintf(ebuf, sizeof(ebuf), "bufferevent \"%s\"", peername);
- logerror(ebuf);
+ log_warn("bufferevent \"%s\"", peername);
free(p);
close(fd);
return;
p->p_ctx = NULL;
if (usetls) {
if (tls_accept_socket(server_ctx, &p->p_ctx, fd) < 0) {
- snprintf(ebuf, sizeof(ebuf), "tls_accept_socket \"%s\"",
- peername);
- logerrorctx(ebuf, server_ctx);
+ log_warnx("tls_accept_socket \"%s\": %s",
+ peername, tls_error(server_ctx));
bufferevent_free(p->p_bufev);
free(p);
close(fd);
tcp_socket(struct filed *f)
{
int s;
- char ebuf[ERRBUFSIZE];
if ((s = socket(f->f_un.f_forw.f_addr.ss_family,
SOCK_STREAM | SOCK_NONBLOCK, IPPROTO_TCP)) == -1) {
- snprintf(ebuf, sizeof(ebuf), "socket \"%s\"",
- f->f_un.f_forw.f_loghost);
- logerror(ebuf);
+ log_warn("socket \"%s\"", f->f_un.f_forw.f_loghost);
return (-1);
}
set_sockbuf(s);
if (connect(s, (struct sockaddr *)&f->f_un.f_forw.f_addr,
f->f_un.f_forw.f_addr.ss_len) == -1 && errno != EINPROGRESS) {
- snprintf(ebuf, sizeof(ebuf), "connect \"%s\"",
- f->f_un.f_forw.f_loghost);
- logerror(ebuf);
+ log_warn("connect \"%s\"", f->f_un.f_forw.f_loghost);
close(s);
return (-1);
}
{
struct filed *f = arg;
struct bufferevent *bufev = f->f_un.f_forw.f_bufev;
- char ebuf[ERRBUFSIZE];
int s;
if ((s = tcp_socket(f)) == -1) {
if (f->f_type == F_FORWTLS) {
if ((f->f_un.f_forw.f_ctx = tls_client()) == NULL) {
- snprintf(ebuf, sizeof(ebuf), "tls_client \"%s\"",
- f->f_un.f_forw.f_loghost);
- logerror(ebuf);
+ log_warn("tls_client \"%s\"", f->f_un.f_forw.f_loghost);
goto error;
}
if (client_config &&
tls_configure(f->f_un.f_forw.f_ctx, client_config) == -1) {
- snprintf(ebuf, sizeof(ebuf), "tls_configure \"%s\"",
- f->f_un.f_forw.f_loghost);
- logerrorctx(ebuf, f->f_un.f_forw.f_ctx);
+ log_warnx("tls_configure \"%s\": %s",
+ f->f_un.f_forw.f_loghost,
+ tls_error(f->f_un.f_forw.f_ctx));
goto error;
}
if (tls_connect_socket(f->f_un.f_forw.f_ctx, s,
f->f_un.f_forw.f_host) == -1) {
- snprintf(ebuf, sizeof(ebuf), "tls_connect_socket "
- "\"%s\"", f->f_un.f_forw.f_loghost);
- logerrorctx(ebuf, f->f_un.f_forw.f_ctx);
+ log_warnx("tls_connect_socket \"%s\": %s",
+ f->f_un.f_forw.f_loghost,
+ tls_error(f->f_un.f_forw.f_ctx));
goto error;
}
log_debug("tcp connect callback: tls context success");
break;
default:
f->f_type = F_UNUSED;
- logerror("sendto");
+ log_warn("sendto \"%s\"",
+ f->f_un.f_forw.f_loghost);
break;
}
}
if (e == EAGAIN && f->f_type == F_PIPE) {
if (now.tv_sec - f->f_lasterrtime > 120) {
f->f_lasterrtime = now.tv_sec;
- logerror(f->f_un.f_fname);
+ log_warn("writev \"%s\"",
+ f->f_un.f_fname);
}
break;
}
retryonce = 1;
if (f->f_file < 0) {
f->f_type = F_UNUSED;
- logerror(f->f_un.f_fname);
+ log_warn("priv_open_tty \"%s\"",
+ f->f_un.f_fname);
} else
goto again;
} else if ((e == EPIPE || e == EBADF) &&
retryonce = 1;
if (f->f_file < 0) {
f->f_type = F_UNUSED;
- logerror(f->f_un.f_fname);
+ log_warn("priv_open_log \"%s\"",
+ f->f_un.f_fname);
} else
goto again;
} else {
f->f_type = F_UNUSED;
f->f_file = -1;
errno = e;
- logerror(f->f_un.f_fname);
+ log_warn("writev \"%s\"", f->f_un.f_fname);
}
} else if (flags & SYNC_FILE)
(void)fsync(f->f_file);
if (reenter++)
return;
if ((uf = priv_open_utmp()) == NULL) {
- logerror(_PATH_UTMP);
+ log_warn("priv_open_utmp");
reenter = 0;
return;
}
utline[sizeof(utline) - 1] = '\0';
if (f->f_type == F_WALL) {
if ((p = ttymsg(iov, 6, utline)) != NULL)
- logerrorx(p);
+ log_warnx("%s", p);
continue;
}
/* should we send the message to this user? */
if (!strncmp(f->f_un.f_uname[i], ut.ut_name,
UT_NAMESIZE)) {
if ((p = ttymsg(iov, 6, utline)) != NULL)
- logerrorx(p);
+ log_warnx("%s", p);
break;
}
}
log_debug("libevent: [%d] %s", severity, msg);
}
-void
-logerror(const char *message)
-{
- logerror_reason(message, errno ? strerror(errno) : NULL);
-}
-
-void
-logerrorx(const char *message)
-{
- logerror_reason(message, NULL);
-}
-
-void
-logerrorctx(const char *message, struct tls *ctx)
-{
- logerror_reason(message, ctx ? tls_error(ctx) : NULL);
-}
-
-void
-logerrortlsconf(const char *message, struct tls_config *config)
-{
- logerror_reason(message, config ? tls_config_error(config) : NULL);
-}
-
-void
-logerror_reason(const char *message, const char *reason)
-{
- char ebuf[ERRBUFSIZE];
-
- if (reason)
- (void)snprintf(ebuf, sizeof(ebuf), "syslogd: %s: %s",
- message, reason);
- else
- (void)snprintf(ebuf, sizeof(ebuf), "syslogd: %s", message);
- errno = 0;
- log_debug("%s", ebuf);
- if (Startup)
- fprintf(stderr, "%s\n", ebuf);
- else
- logmsg(LOG_SYSLOG|LOG_ERR, ebuf, LocalHostName, ADDDATE);
-}
-
__dead void
die(int signo)
{
logmsg(LOG_SYSLOG|LOG_WARNING, ebuf, LocalHostName, ADDDATE);
}
- if (signo) {
- log_debug("syslogd: exiting on signal %d", signo);
- (void)snprintf(ebuf, sizeof(ebuf), "exiting on signal %d",
- signo);
- logerrorx(ebuf);
- }
- log_debug("[unpriv] syslogd child about to exit");
+ if (signo)
+ log_warnx("exiting on signal %d", signo);
+ log_debug("syslogd: exited");
exit(0);
}
f->f_un.f_mb.f_rb = ringbuf_init(f->f_un.f_mb.f_len);
if (f->f_un.f_mb.f_rb == NULL) {
f->f_type = F_UNUSED;
- logerror("Failed to allocate membuf");
+ log_warn("allocate membuf");
}
} else {
log_debug("Membuf match f:%p, m:%p", f, m);
m = SIMPLEQ_FIRST(&mb);
SIMPLEQ_REMOVE_HEAD(&mb, f_next);
if (m->f_un.f_mb.f_rb != NULL) {
- logerrorx("Mismatched membuf");
+ log_warnx("mismatched membuf");
ringbuf_free(m->f_un.f_mb.f_rb);
}
log_debug("Freeing membuf %p", m);
int i, pri;
size_t rb_len;
char *bp, *p, *q, *proto, *host, *port, *ipproto;
- char buf[MAXLINE], ebuf[ERRBUFSIZE];
+ char buf[MAXLINE];
struct filed *xf, *f, *d;
struct timeval to;
pri = decode(buf, prioritynames);
if (pri < 0) {
- (void)snprintf(ebuf, sizeof ebuf,
- "unknown priority name \"%s\"", buf);
- logerrorx(ebuf);
+ log_warnx("unknown priority name \"%s\"", buf);
free(f);
return (NULL);
}
else {
i = decode(buf, facilitynames);
if (i < 0) {
- (void)snprintf(ebuf, sizeof(ebuf),
- "unknown facility name \"%s\"",
- buf);
- logerrorx(ebuf);
+ log_warnx("unknown facility name "
+ "\"%s\"", buf);
free(f);
return (NULL);
}
if ((strlcpy(f->f_un.f_forw.f_loghost, p,
sizeof(f->f_un.f_forw.f_loghost)) >=
sizeof(f->f_un.f_forw.f_loghost))) {
- snprintf(ebuf, sizeof(ebuf), "loghost too long \"%s\"",
- p);
- logerrorx(ebuf);
+ log_warnx("loghost too long \"%s\"", p);
break;
}
if (loghost_parse(++p, &proto, &host, &port) == -1) {
- snprintf(ebuf, sizeof(ebuf), "bad loghost \"%s\"",
+ log_warnx("bad loghost \"%s\"",
f->f_un.f_forw.f_loghost);
- logerrorx(ebuf);
break;
}
if (proto == NULL)
ipproto = proto;
} else if (strcmp(proto, "udp4") == 0) {
if (fd_udp == -1) {
- snprintf(ebuf, sizeof(ebuf), "no udp4 \"%s\"",
+ log_warnx("no udp4 \"%s\"",
f->f_un.f_forw.f_loghost);
- logerrorx(ebuf);
break;
}
} else if (strcmp(proto, "udp6") == 0) {
if (fd_udp6 == -1) {
- snprintf(ebuf, sizeof(ebuf), "no udp6 \"%s\"",
+ log_warnx("no udp6 \"%s\"",
f->f_un.f_forw.f_loghost);
- logerrorx(ebuf);
break;
}
} else if (strcmp(proto, "tcp") == 0 ||
} else if (strcmp(proto, "tls6") == 0) {
ipproto = "tcp6";
} else {
- snprintf(ebuf, sizeof(ebuf), "bad protocol \"%s\"",
+ log_warnx("bad protocol \"%s\"",
f->f_un.f_forw.f_loghost);
- logerrorx(ebuf);
break;
}
if (strlen(host) >= NI_MAXHOST) {
- snprintf(ebuf, sizeof(ebuf), "host too long \"%s\"",
+ log_warnx("host too long \"%s\"",
f->f_un.f_forw.f_loghost);
- logerrorx(ebuf);
break;
}
if (port == NULL)
port = strncmp(proto, "tls", 3) == 0 ?
"syslog-tls" : "syslog";
if (strlen(port) >= NI_MAXSERV) {
- snprintf(ebuf, sizeof(ebuf), "port too long \"%s\"",
+ log_warnx("port too long \"%s\"",
f->f_un.f_forw.f_loghost);
- logerrorx(ebuf);
break;
}
if (priv_getaddrinfo(ipproto, host, port,
(struct sockaddr*)&f->f_un.f_forw.f_addr,
sizeof(f->f_un.f_forw.f_addr)) != 0) {
- snprintf(ebuf, sizeof(ebuf), "bad hostname \"%s\"",
+ log_warnx("bad hostname \"%s\"",
f->f_un.f_forw.f_loghost);
- logerrorx(ebuf);
break;
}
f->f_file = -1;
} else if (strncmp(ipproto, "tcp", 3) == 0) {
if ((f->f_un.f_forw.f_bufev = bufferevent_new(-1,
tcp_dropcb, tcp_writecb, tcp_errorcb, f)) == NULL) {
- snprintf(ebuf, sizeof(ebuf),
- "bufferevent \"%s\"",
+ log_warn("bufferevent \"%s\"",
f->f_un.f_forw.f_loghost);
- logerror(ebuf);
break;
}
if (strncmp(proto, "tls", 3) == 0) {
free(f);
return (NULL);
}
- if (strcmp(p, ctty) == 0)
+ if (strcmp(p, ctty) == 0) {
f->f_file = priv_open_tty(p);
- else
+ if (f->f_file < 0)
+ log_warn("priv_open_tty \"%s\"", p);
+ } else {
f->f_file = priv_open_log(p);
+ if (f->f_file < 0)
+ log_warn("priv_open_log \"%s\"", p);
+ }
if (f->f_file < 0) {
f->f_type = F_UNUSED;
- logerror(p);
break;
}
if (isatty(f->f_file)) {
if (*p == '\0' || (errno == ERANGE && rb_len == ULONG_MAX) ||
*q != ':' || rb_len == 0) {
f->f_type = F_UNUSED;
- logerror(p);
+ log_warnx("strtoul \"%s\"", p);
break;
}
q++;
/* Error on missing or non-unique name, or bad buffer length */
if (i == 0 || rb_len > MAX_MEMBUF || xf != NULL) {
f->f_type = F_UNUSED;
- logerrorx(p);
+ log_warnx("find_dup \"%s\"", p);
break;
}
unix_socket(char *path, int type, mode_t mode)
{
struct sockaddr_un s_un;
- char ebuf[512];
int fd, optval;
mode_t old_umask;
s_un.sun_family = AF_UNIX;
if (strlcpy(s_un.sun_path, path, sizeof(s_un.sun_path)) >=
sizeof(s_un.sun_path)) {
- snprintf(ebuf, sizeof(ebuf), "socket path too long: %s", path);
- logerrorx(ebuf);
+ log_warnx("socket path too long \"%s\"", path);
return (-1);
}
if ((fd = socket(AF_UNIX, type, 0)) == -1) {
- logerror("socket");
+ log_warn("socket unix \"%s\"", path);
return (-1);
}
errno == EPROTOTYPE) {
close(fd);
errno = EISCONN;
- logerror("connect");
+ log_warn("connect unix \"%s\"", path);
return (-1);
}
}
unlink(path);
if (bind(fd, (struct sockaddr *)&s_un, sizeof(s_un)) == -1) {
- snprintf(ebuf, sizeof(ebuf), "cannot bind %s", path);
- logerror(ebuf);
+ log_warn("bind unix \"%s\"", path);
umask(old_umask);
close(fd);
return (-1);
umask(old_umask);
if (chmod(path, mode) == -1) {
- snprintf(ebuf, sizeof(ebuf), "cannot chmod %s", path);
- logerror(ebuf);
+ log_warn("chmod unix \"%s\"", path);
close(fd);
unlink(path);
return (-1);
optval = MAXLINE + PATH_MAX;
if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &optval, sizeof(optval))
== -1)
- logerror("setsockopt unix");
+ log_warn("setsockopt unix \"%s\"", path);
return (fd);
}
len = sizeof(oldsize);
if (getsockopt(fd, SOL_SOCKET, optname, &oldsize, &len) == -1)
- logerror("getsockopt bufsize");
+ log_warn("getsockopt bufsize");
len = sizeof(newsize);
newsize = MAXLINE + 128; /* data + control */
/* allow 8 full length messages */
if (newsize <= oldsize)
continue;
if (setsockopt(fd, SOL_SOCKET, optname, &newsize, len) == -1)
- logerror("setsockopt bufsize");
+ log_warn("setsockopt bufsize %d", newsize);
}
}
int size = 65536;
if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &size, sizeof(size)) == -1)
- logerror("setsockopt sndbufsize");
+ log_warn("setsockopt sndbufsize %d", size);
if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &size, sizeof(size)) == -1)
- logerror("setsockopt rcvbufsize");
+ log_warn("setsockopt rcvbufsize %d", size);
}
void
if (errno != ENFILE && errno != EMFILE &&
errno != EINTR && errno != EWOULDBLOCK &&
errno != ECONNABORTED)
- logerror("accept ctlsock");
+ log_warn("accept control socket");
return;
}
log_debug("Accepting control connection");
goto retry;
if (errno == EWOULDBLOCK)
return;
- logerror("ctlconn read");
+ log_warn("read control socket");
/* FALLTHROUGH */
case 0:
ctlconn_cleanup();
return;
if (ntohl(ctl_cmd.version) != CTL_VERSION) {
- logerrorx("Unknown client protocol version");
+ log_warnx("unknown client protocol version");
ctlconn_cleanup();
return;
}
/* Ensure that logname is \0 terminated */
if (memchr(ctl_cmd.logname, '\0', sizeof(ctl_cmd.logname)) == NULL) {
- logerrorx("Corrupt ctlsock command");
+ log_warnx("corrupt control socket command");
ctlconn_cleanup();
return;
}
strlcat(reply_text, "\n", MAX_MEMBUF);
break;
default:
- logerrorx("Unsupported ctlsock command");
+ log_warnx("unsupported control socket command");
ctlconn_cleanup();
return;
}
if (!(ctl_state == CTL_WRITING_REPLY ||
ctl_state == CTL_WRITING_CONT_REPLY)) {
/* Shouldn't be here! */
- logerrorx("ctlconn_write with bad ctl_state");
+ log_warnx("control socket write with bad state");
ctlconn_cleanup();
return;
}
if (errno == EWOULDBLOCK)
return;
if (errno != EPIPE)
- logerror("ctlconn write");
+ log_warn("write control socket");
/* FALLTHROUGH */
case 0:
ctlconn_cleanup();