Date: Thu, 13 Nov 1997 13:56:31 -0800 (PST) From: Sean Eric Fagan <sef@kithrup.com> To: current@freebsd.org Subject: Another logging change -- any objections to this one? Message-ID: <199711132156.NAA24310@kithrup.com>
next in thread | raw e-mail | index | archive | help
This one is to fingerd, obviously. It moves the logging section around, and
logs what the request was.
Index: fingerd.c
===================================================================
RCS file: /usr/cvs/src/libexec/fingerd/fingerd.c,v
retrieving revision 1.8
diff -u -r1.8 fingerd.c
--- fingerd.c 1997/03/28 15:48:09 1.8
+++ fingerd.c 1997/11/13 21:09:57
@@ -96,18 +96,6 @@
logerr("illegal option -- %c", ch);
}
- if (logging) {
- sval = sizeof(sin);
- if (getpeername(0, (struct sockaddr *)&sin, &sval) < 0)
- logerr("getpeername: %s", strerror(errno));
- if (hp = gethostbyaddr((char *)&sin.sin_addr.s_addr,
- sizeof(sin.sin_addr.s_addr), AF_INET))
- lp = hp->h_name;
- else
- lp = inet_ntoa(sin.sin_addr);
- syslog(LOG_NOTICE, "query from %s", lp);
- }
-
/*
* Enable server-side Transaction TCP.
*/
@@ -121,6 +109,32 @@
if (!fgets(line, sizeof(line), stdin))
exit(1);
+
+ if (logging) {
+ char *t;
+ char *end;
+
+ end = memchr(line, 0, sizeof(line));
+ if (end == NULL) {
+ t = malloc(sizeof(line) + 1);
+ memcpy(t, line, sizeof(line));
+ t[sizeof(line)] = 0;
+ } else {
+ t = strdup(line);
+ }
+ for (end = t; *end; end++)
+ if (*end == '\n' || *end == '\r')
+ *end = ' ';
+ sval = sizeof(sin);
+ if (getpeername(0, (struct sockaddr *)&sin, &sval) < 0)
+ logerr("getpeername: %s", strerror(errno));
+ if (hp = gethostbyaddr((char *)&sin.sin_addr.s_addr,
+ sizeof(sin.sin_addr.s_addr), AF_INET))
+ lp = hp->h_name;
+ else
+ lp = inet_ntoa(sin.sin_addr);
+ syslog(LOG_NOTICE, "query from %s: `%s'", lp, t);
+ }
comp = &av[1];
av[2] = "--";
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199711132156.NAA24310>
