From 4bb46f5ff8424fa34997cc7acb6c55a4b4111c42 Mon Sep 17 00:00:00 2001 From: Nathan Gibbs Date: Tue, 7 Apr 2015 18:14:27 +0000 Subject: [PATCH] TCP & UDP Log message cleanup & standardization. Debian init script fix. --- ChangeLog | 7 ++++++- NEWS | 5 +++++ README | 2 +- TODO | 2 +- configure | 2 +- iplog.init | 12 +++++++++++- src/iplog_ident.c | 12 ++++++------ src/iplog_tcp.c | 6 +++--- src/iplog_udp.c | 4 ++-- 9 files changed, 36 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 506901b..8068fdf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,11 @@ +11-05-2014 + Released as version 2.2.5 + TCP & UDP Log message cleanup & standardization. + Debian init script fix. + 06-17-2013 Released as version 2.2.4 - Some code tweaks to get it to compile on debian Wheezy. + Some code tweaks to get it to compile on Debian Wheezy. Added debian startup script 05-16-2013 diff --git a/NEWS b/NEWS index 1992e81..4fe188d 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,8 @@ +CHANGES IN IPLOG 2.2.5 +---------------------- +* TCP & UDP Log message cleanup & standardization. +* Debian init script fix. + CHANGES IN IPLOG 2.2.4 ---------------------- * Code tweaks to allow compilation on debian wheezy. diff --git a/README b/README index 642429c..e7dbd10 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -iplog 2.2.4 by Ryan McCabe +iplog by Ryan McCabe Continued by Nathan Gibbs nathan@cmpublishers.com ------------------------------------------ diff --git a/TODO b/TODO index 1af471f..639862c 100644 --- a/TODO +++ b/TODO @@ -30,4 +30,4 @@ Other Stuff or provide access so I can do this, I'd be awfully grateful. Nathan's TODO - 1. Clean up the format of the log messages + 1. Clean up logging code. diff --git a/configure b/configure index 4ec1405..979b667 100755 --- a/configure +++ b/configure @@ -705,7 +705,7 @@ fi PACKAGE=$PACKAGE -VERSION=2.2.4 +VERSION=2.2.5 if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then { echo "configure: error: source directory already configured; run "make distclean" there first" 1>&2; exit 1; } diff --git a/iplog.init b/iplog.init index 0092e6f..48eb1c1 100755 --- a/iplog.init +++ b/iplog.init @@ -20,7 +20,7 @@ DESC="IP Logging Service" NAME=iplog DAEMON=/usr/local/sbin/$NAME DAEMON_ARGS="" -PIDFILE=/var/run/$NAME.pid +PIDFILE=/var/run/iplog/$NAME.pid SCRIPTNAME=/etc/init.d/$NAME # Exit if the package is not installed @@ -99,8 +99,18 @@ do_reload() { return 0 } +setup_run_dir() { + # Create the PrivSep empty dir if necessary + if [ ! -d /var/run/iplog ]; then + mkdir /var/run/iplog + chown nobody:nogroup /var/run/iplog + chmod 0755 /var/run/iplog + fi +} + case "$1" in start) + setup_run_dir [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" do_start case "$?" in diff --git a/src/iplog_ident.c b/src/iplog_ident.c index d379277..6db5bf3 100644 --- a/src/iplog_ident.c +++ b/src/iplog_ident.c @@ -106,14 +106,14 @@ void *get_ident_data(void *data) { if (opt_enabled(LOG_DEST)) { u_char lbuf2[MAX_HSTLEN]; - mysyslog("TCP: %s connection attempt to %s from %s@%s:%u", - serv_lookup(tcp->th_dport, "tcp", sbuf, sizeof(sbuf)), + mysyslog("TCP: %s:%s from %s@%s:%u", host_lookup(&ip->ip_dst, tcp_res(), lbuf2, sizeof(lbuf2)), + serv_lookup(tcp->th_dport, "tcp", sbuf, sizeof(sbuf)), remote_user, host_lookup(&ip->ip_src, tcp_res(), lbuf, sizeof(lbuf)), ntohs(tcp->th_sport)); } else { - mysyslog("TCP: %s connection attempt from %s@%s:%u", + mysyslog("TCP: to %s from %s@%s:%u", serv_lookup(tcp->th_dport, "tcp", sbuf, sizeof(sbuf)), remote_user, host_lookup(&ip->ip_src, tcp_res(), lbuf, sizeof(lbuf)), ntohs(tcp->th_sport)); @@ -129,13 +129,13 @@ void *get_ident_data(void *data) { if (opt_enabled(LOG_DEST)) { u_char lbuf2[MAX_HSTLEN]; - mysyslog("TCP: %s connection attempt to %s from %s:%u", - serv_lookup(tcp->th_dport, "tcp", sbuf, sizeof(sbuf)), + mysyslog("TCP: to %s:%s from %s:%u", host_lookup(&ip->ip_dst, tcp_res(), lbuf2, sizeof(lbuf2)), + serv_lookup(tcp->th_dport, "tcp", sbuf, sizeof(sbuf)), host_lookup(&ip->ip_src, tcp_res(), lbuf, sizeof(lbuf)), ntohs(tcp->th_sport)); } else { - mysyslog("TCP: %s connection attempt from %s:%u", + mysyslog("TCP: to %s from %s:%u", serv_lookup(tcp->th_dport, "tcp", sbuf, sizeof(sbuf)), host_lookup(&ip->ip_src, tcp_res(), lbuf, sizeof(lbuf)), ntohs(tcp->th_sport)); diff --git a/src/iplog_tcp.c b/src/iplog_tcp.c index f29993b..6b0756a 100644 --- a/src/iplog_tcp.c +++ b/src/iplog_tcp.c @@ -270,10 +270,10 @@ int tcp_parser(const struct ip *ip) { host_lookup(&ip->ip_dst, tcp_res(), lbuf2, sizeof(lbuf2)); - mysyslog("TCP: %s connection attempt to %s from %s:%u", - sbuf, lbuf2, lbuf, ntohs(tcp->th_sport)); + mysyslog("TCP: to %s:%s from %s:%u", + lbuf2, sbuf, lbuf, ntohs(tcp->th_sport)); } else { - mysyslog("TCP: %s connection attempt from %s:%u", + mysyslog("TCP: to %s from %s:%u", sbuf, lbuf, ntohs(tcp->th_sport)); } } diff --git a/src/iplog_udp.c b/src/iplog_udp.c index 462e91d..c7a75bc 100644 --- a/src/iplog_udp.c +++ b/src/iplog_udp.c @@ -118,11 +118,11 @@ int udp_parser(const struct ip *ip) { u_char buf2[MAX_HSTLEN]; host_lookup(&ip->ip_dst, udp_res(), buf2, sizeof(buf2)); - mysyslog("UDP: dgram to %s:%s from %s:%u (%lu data bytes)", + mysyslog("UDP: to %s:%s from %s:%u (%lu data bytes)", buf2, sbuf, buf, ntohs(udp->uh_sport), ntohs(udp->uh_ulen) - sizeof(*udp)); } else { - mysyslog("UDP: dgram to %s from %s:%u (%lu data bytes)", + mysyslog("UDP: to %s from %s:%u (%lu data bytes)", sbuf, buf, ntohs(udp->uh_sport), ntohs(udp->uh_ulen) - sizeof(*udp)); }