-/* $OpenBSD: syslogd.c,v 1.266 2021/07/14 13:33:57 kn Exp $ */
+/* $OpenBSD: syslogd.c,v 1.267 2021/09/03 16:28:33 bluhm Exp $ */
/*
* Copyright (c) 2014-2017 Alexander Bluhm <bluhm@genua.de>
void
fprintlog(struct filed *f, int flags, char *msg)
{
- struct iovec iov[6];
- struct iovec *v;
+ struct iovec iov[IOVCNT], *v;
int l, retryonce;
char line[LOG_MAXLINE + 1], repbuf[80], greetings[500];
char ebuf[ERRBUFSIZE];
}
retryonce = 0;
again:
- if (writev(f->f_file, iov, 6) == -1) {
+ if (writev(f->f_file, iov, IOVCNT) == -1) {
int e = errno;
/* allow to recover from file system full */
strncpy(utline, ut.ut_line, sizeof(utline) - 1);
utline[sizeof(utline) - 1] = '\0';
if (f->f_type == F_WALL) {
- ttymsg(iov, 6, utline);
+ ttymsg(utline, iov);
continue;
}
/* should we send the message to this user? */
break;
if (!strncmp(f->f_un.f_uname[i], ut.ut_name,
UT_NAMESIZE)) {
- ttymsg(iov, 6, utline);
+ ttymsg(utline, iov);
break;
}
}
-/* $OpenBSD: syslogd.h,v 1.33 2019/07/05 13:23:27 bluhm Exp $ */
+/* $OpenBSD: syslogd.h,v 1.34 2021/09/03 16:28:33 bluhm Exp $ */
/*
* Copyright (c) 2014-2017 Alexander Bluhm <bluhm@genua.de>
int priv_getaddrinfo(char *, char *, char *, struct sockaddr *, size_t);
int priv_getnameinfo(struct sockaddr *, socklen_t, char *, size_t);
+#define IOVCNT 6
+
/* Terminal message */
#define TTYMSGTIME 1 /* timeout used by ttymsg */
#define TTYMAXDELAY 256 /* max events in ttymsg */
-void ttymsg(struct iovec *, int, char *);
+void ttymsg(char *, struct iovec *);
/* File descriptor send/recv */
void send_fd(int, int);
-/* $OpenBSD: ttymsg.c,v 1.18 2019/06/28 13:32:51 deraadt Exp $ */
+/* $OpenBSD: ttymsg.c,v 1.19 2021/09/03 16:28:33 bluhm Exp $ */
/* $NetBSD: ttymsg.c,v 1.3 1994/11/17 07:17:55 jtc Exp $ */
/*
#include "log.h"
#include "syslogd.h"
-#ifndef nitems
-#define nitems(_a) (sizeof((_a)) / sizeof((_a)[0]))
-#endif
-
struct tty_delay {
struct event td_event;
size_t td_length;
* seconds.
*/
void
-ttymsg(struct iovec *iov, int iovcnt, char *utline)
+ttymsg(char *utline, struct iovec *iov)
{
static char device[MAXNAMLEN] = _PATH_DEV;
+ struct iovec localiov[IOVCNT];
+ int iovcnt = IOVCNT;
int cnt, fd;
size_t left;
ssize_t wret;
- struct iovec localiov[6];
-
- if (iovcnt < 0 || (size_t)iovcnt > nitems(localiov)) {
- log_warnx("too many iov's (change code in syslogd/ttymsg.c)");
- return;
- }
/*
* Ignore lines that start with "ftp" or "uucp".