Summary: | logger not sending hostname or timestamp to loghost when using capsicum | ||
---|---|---|---|
Product: | Base System | Reporter: | Gunther Schadow <raj> |
Component: | bin | Assignee: | freebsd-bugs (Nobody) <bugs> |
Status: | New --- | ||
Severity: | Affects Some People | CC: | bdrewery, oshogbo |
Priority: | --- | ||
Version: | Unspecified | ||
Hardware: | Any | ||
OS: | Any |
Description
Gunther Schadow
2020-12-24 03:09:24 UTC
The problem is that logger((1) uses capsicum now which ends up forwarding the entire message to syslog(3) which then adds its own hostname. syslog(3) does not support passing a hostname. If using logger -h then capsicum is disabled and the hostname is sent in a direct socket. static void logmessage(int pri, const char *timestamp, const char *hostname, const char *tag, struct socks *sk, ssize_t nsock, const char *buf) { char *line; int len, i, lsent; // nsock != 0 when -h is given if (nsock == 0) { cap_syslog(capsyslog, pri, "%s", buf); return; } // no capsicum, use custom format with hostname if ((len = asprintf(&line, "<%d>%s %s %s: %s", pri, timestamp, hostname, tag, buf)) == -1) errx(1, "asprintf"); lsent = -1; for (i = 0; i < nsock; i++) { lsent = sendto(sk[i].sk_sock, line, len, 0, sstosa(&sk[i].sk_addr), sk[i].sk_addrlen); Actually tag is sent in cap_opensyslog. Unsure if timestamp obeys environment TZ via capsicum. I think a possible fix would be to add an API for passing hostname to syslog(3). Naming is just an example: openlog2(const char *ident, int logopt, int facility, const char *hostname) This could be kept set like the tag and facility already are. Then capsicum's syslog API could learn of it as well. |