From 232bfc7d5f0b6182f2e42516c028b48725e894df Mon Sep 17 00:00:00 2001 From: brian Date: Wed, 14 May 2008 00:22:21 +0000 Subject: Add a -8 switch to syslogd to prevent it from mangling 8-bit data. --- usr.sbin/syslogd/syslogd.8 | 21 +++++++++++++++++++-- usr.sbin/syslogd/syslogd.c | 10 +++++++--- 2 files changed, 26 insertions(+), 5 deletions(-) (limited to 'usr.sbin') diff --git a/usr.sbin/syslogd/syslogd.8 b/usr.sbin/syslogd/syslogd.8 index c9faa01..5d8896a 100644 --- a/usr.sbin/syslogd/syslogd.8 +++ b/usr.sbin/syslogd/syslogd.8 @@ -28,7 +28,7 @@ .\" @(#)syslogd.8 8.1 (Berkeley) 6/6/93 .\" $FreeBSD$ .\" -.Dd April 13, 2005 +.Dd May 13, 2008 .Dt SYSLOGD 8 .Os .Sh NAME @@ -36,7 +36,7 @@ .Nd log systems messages .Sh SYNOPSIS .Nm -.Op Fl 46ACcdknosuv +.Op Fl 468ACcdknosuv .Op Fl a Ar allowed_peer .Op Fl b Ar bind_address .Op Fl f Ar config_file @@ -60,6 +60,23 @@ to use IPv4 addresses only. Force .Nm to use IPv6 addresses only. +.It Fl 8 +Tells +.Nm +not to interfere with 8-bit data. Normally +.Nm +will replace C1 control characters +.Pq ISO 8859 and Unicode characters +with their +.Dq M- Ns Em x +equivalent. +Note, this option does not change the way +.Nm +alters control characters +.Pq see Xr iscntrl 3 . +They will always be replaced with their +.Dq ^ Ns Em x +equivalent. .It Fl A Ordinarily, .Nm diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c index 4212ed6..7ca7061 100644 --- a/usr.sbin/syslogd/syslogd.c +++ b/usr.sbin/syslogd/syslogd.c @@ -283,6 +283,7 @@ static int family = PF_UNSPEC; /* protocol family (IPv4, IPv6 or both) */ #else static int family = PF_INET; /* protocol family (IPv4 only) */ #endif +static int mask_C1 = 1; /* mask characters from 0x80 - 0x9F */ static int send_to_all; /* send message to all IPv4/IPv6 addresses */ static int use_bootfile; /* log entire bootfile for every kern msg */ static int no_compress; /* don't compress messages (1=pipes, 2=all) */ @@ -351,7 +352,7 @@ main(int argc, char *argv[]) socklen_t len; bindhostname = NULL; - while ((ch = getopt(argc, argv, "46Aa:b:cCdf:kl:m:nop:P:sS:uv")) != -1) + while ((ch = getopt(argc, argv, "468Aa:b:cCdf:kl:m:nop:P:sS:uv")) != -1) switch (ch) { case '4': family = PF_INET; @@ -361,6 +362,9 @@ main(int argc, char *argv[]) family = PF_INET6; break; #endif + case '8': + mask_C1 = 0; + break; case 'A': send_to_all++; break; @@ -693,7 +697,7 @@ usage(void) { fprintf(stderr, "%s\n%s\n%s\n%s\n", - "usage: syslogd [-46ACcdknosuv] [-a allowed_peer]", + "usage: syslogd [-468ACcdknosuv] [-a allowed_peer]", " [-b bind_address] [-f config_file]", " [-l [mode:]path] [-m mark_interval]", " [-P pid_file] [-p log_socket]"); @@ -738,7 +742,7 @@ printline(const char *hname, char *msg) while ((c = (unsigned char)*p++) != '\0' && q < &line[sizeof(line) - 4]) { - if ((c & 0x80) && c < 0xA0) { + if (mask_C1 && (c & 0x80) && c < 0xA0) { c &= 0x7F; *q++ = 'M'; *q++ = '-'; -- cgit v1.1