From 3691afc4a33694a937d4a67bbd95ab0c59146b9d Mon Sep 17 00:00:00 2001 From: Champ Clark III Date: Tue, 7 Oct 2014 01:26:31 +0000 Subject: [PATCH] More code cleanup --- Makefile | 20 ++++++++++---------- config.status | 14 +++++++------- src/output-plugins/sagan-external.c | 5 +++-- src/sagan-classifications.c | 3 +-- src/sagan-flowbit.c | 2 +- src/sagan-processor.c | 5 ++++- src/sagan-references.c | 3 +-- src/sagan-util.c | 5 ++--- src/sagan.h | 1 + 9 files changed, 30 insertions(+), 28 deletions(-) diff --git a/Makefile b/Makefile index 2e909228..6d5fa9c2 100644 --- a/Makefile +++ b/Makefile @@ -193,12 +193,12 @@ distuninstallcheck_listfiles = find . -type f -print am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$' distcleancheck_listfiles = find . -type f -print -ACLOCAL = ${SHELL} /home/champ/code/sagan/missing aclocal-1.14 +ACLOCAL = ${SHELL} /home/champ/code/release-1.0.0RC4/sagan/missing aclocal-1.14 AMTAR = $${TAR-tar} AM_DEFAULT_VERBOSITY = 1 -AUTOCONF = ${SHELL} /home/champ/code/sagan/missing autoconf -AUTOHEADER = ${SHELL} /home/champ/code/sagan/missing autoheader -AUTOMAKE = ${SHELL} /home/champ/code/sagan/missing automake-1.14 +AUTOCONF = ${SHELL} /home/champ/code/release-1.0.0RC4/sagan/missing autoconf +AUTOHEADER = ${SHELL} /home/champ/code/release-1.0.0RC4/sagan/missing autoheader +AUTOMAKE = ${SHELL} /home/champ/code/release-1.0.0RC4/sagan/missing automake-1.14 AWK = gawk CC = gcc CCDEPMODE = depmode=gcc3 @@ -231,7 +231,7 @@ LIBOBJS = LIBS = -ldnet -llognorm -lestr -lm -lpthread -lpcre LTLIBOBJS = MAINT = # -MAKEINFO = ${SHELL} /home/champ/code/sagan/missing makeinfo +MAKEINFO = ${SHELL} /home/champ/code/release-1.0.0RC4/sagan/missing makeinfo MKDIR_P = /bin/mkdir -p OBJEXT = o PACKAGE = sagan @@ -249,10 +249,10 @@ SET_MAKE = SHELL = /bin/sh STRIP = VERSION = 1.0.0-RC4 -abs_builddir = /home/champ/code/sagan -abs_srcdir = /home/champ/code/sagan -abs_top_builddir = /home/champ/code/sagan -abs_top_srcdir = /home/champ/code/sagan +abs_builddir = /home/champ/code/release-1.0.0RC4/sagan +abs_srcdir = /home/champ/code/release-1.0.0RC4/sagan +abs_top_builddir = /home/champ/code/release-1.0.0RC4/sagan +abs_top_srcdir = /home/champ/code/release-1.0.0RC4/sagan ac_ct_CC = gcc am__include = include am__leading_dot = . @@ -279,7 +279,7 @@ host_vendor = unknown htmldir = ${docdir} includedir = ${prefix}/include infodir = ${datarootdir}/info -install_sh = ${SHELL} /home/champ/code/sagan/install-sh +install_sh = ${SHELL} /home/champ/code/release-1.0.0RC4/sagan/install-sh libdir = ${exec_prefix}/lib libexecdir = ${exec_prefix}/libexec localedir = ${datarootdir}/locale diff --git a/config.status b/config.status index 601d46de..ba77c28a 100755 --- a/config.status +++ b/config.status @@ -437,7 +437,7 @@ Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." -ac_pwd='/home/champ/code/sagan' +ac_pwd='/home/champ/code/release-1.0.0RC4/sagan' srcdir='.' INSTALL='/usr/bin/install -c' MKDIR_P='/bin/mkdir -p' @@ -652,12 +652,12 @@ S["mkdir_p"]="$(MKDIR_P)" S["MKDIR_P"]="/bin/mkdir -p" S["INSTALL_STRIP_PROGRAM"]="$(install_sh) -c -s" S["STRIP"]="" -S["install_sh"]="${SHELL} /home/champ/code/sagan/install-sh" -S["MAKEINFO"]="${SHELL} /home/champ/code/sagan/missing makeinfo" -S["AUTOHEADER"]="${SHELL} /home/champ/code/sagan/missing autoheader" -S["AUTOMAKE"]="${SHELL} /home/champ/code/sagan/missing automake-1.14" -S["AUTOCONF"]="${SHELL} /home/champ/code/sagan/missing autoconf" -S["ACLOCAL"]="${SHELL} /home/champ/code/sagan/missing aclocal-1.14" +S["install_sh"]="${SHELL} /home/champ/code/release-1.0.0RC4/sagan/install-sh" +S["MAKEINFO"]="${SHELL} /home/champ/code/release-1.0.0RC4/sagan/missing makeinfo" +S["AUTOHEADER"]="${SHELL} /home/champ/code/release-1.0.0RC4/sagan/missing autoheader" +S["AUTOMAKE"]="${SHELL} /home/champ/code/release-1.0.0RC4/sagan/missing automake-1.14" +S["AUTOCONF"]="${SHELL} /home/champ/code/release-1.0.0RC4/sagan/missing autoconf" +S["ACLOCAL"]="${SHELL} /home/champ/code/release-1.0.0RC4/sagan/missing aclocal-1.14" S["PACKAGE"]="sagan" S["CYGPATH_W"]="echo" S["am__isrc"]="" diff --git a/src/output-plugins/sagan-external.c b/src/output-plugins/sagan-external.c index 8c5c0120..50e0b01a 100644 --- a/src/output-plugins/sagan-external.c +++ b/src/output-plugins/sagan-external.c @@ -62,7 +62,7 @@ void sagan_ext_thread ( _SaganEvent *Event ) char buf[MAX_SYSLOGMSG]; char data[MAX_SYSLOGMSG]; char tmpref[2048]; - int ret; +// int ret; char tmp[6]; if ( debug->debugexternal ) Sagan_Log(S_WARN, "[%s, line %d] In sagan_ext_thread()", __FILE__, __LINE__); @@ -128,7 +128,8 @@ void sagan_ext_thread ( _SaganEvent *Event ) close(out[0]); pthread_mutex_unlock( &ext_mutex ); - ret=execl(config->sagan_extern, config->sagan_extern, NULL, (char *)NULL); + //ret=execl(config->sagan_extern, config->sagan_extern, NULL, (char *)NULL); + execl(config->sagan_extern, config->sagan_extern, NULL, (char *)NULL); Remove_Lock_File(); Sagan_Log(S_WARN, "[%s, line %d] Cannot execute %s", __FILE__, __LINE__, config->sagan_extern); } diff --git a/src/sagan-classifications.c b/src/sagan-classifications.c index 94898360..8b5393fa 100644 --- a/src/sagan-classifications.c +++ b/src/sagan-classifications.c @@ -64,7 +64,6 @@ void Load_Classifications( const char *ruleset ) char classbuf[CLASSBUF]; char *saveptr=NULL; - char *firststring=NULL; char *tmptoken=NULL; char *laststring=NULL; char tmpbuf2[5]; @@ -94,7 +93,7 @@ void Load_Classifications( const char *ruleset ) classstruct = (_Class_Struct *) realloc(classstruct, (counters->classcount+1) * sizeof(_Class_Struct)); } - firststring = strtok_r(classbuf, ":", &saveptr); + strtok_r(classbuf, ":", &saveptr); tmptoken = strtok_r(NULL, ":" , &saveptr); laststring = strtok_r(tmptoken, ",", &saveptr); diff --git a/src/sagan-flowbit.c b/src/sagan-flowbit.c index 4764be2e..c9217557 100644 --- a/src/sagan-flowbit.c +++ b/src/sagan-flowbit.c @@ -337,7 +337,7 @@ int Sagan_Flowbit_Condition(int rule_position, char *ip_src_char, char *ip_dst_c * */ - if ( rulestruct[rule_position].flowbit_condition_count == flowbit_total_match || and_or == 1 && flowbit_total_match != 0 ) + if ( ( rulestruct[rule_position].flowbit_condition_count == flowbit_total_match ) || ( and_or == 1 && flowbit_total_match != 0 ) ) { if ( debug->debugflowbit) diff --git a/src/sagan-processor.c b/src/sagan-processor.c index 655666b9..843b597f 100644 --- a/src/sagan-processor.c +++ b/src/sagan-processor.c @@ -70,7 +70,10 @@ void Sagan_Processor ( void ) sbool ignore_flag=0; int i; - int rc; + +#ifdef WITH_WEBSENSE + int rc; /* Return code for Websense */ +#endif for (;;) { diff --git a/src/sagan-references.c b/src/sagan-references.c index ed664de6..2e06b35e 100644 --- a/src/sagan-references.c +++ b/src/sagan-references.c @@ -64,7 +64,6 @@ void Load_Reference( const char *ruleset ) char refbuf[1024]; char *saveptr=NULL; - char *firststring=NULL; char *tmptoken=NULL; char *laststring=NULL; @@ -95,7 +94,7 @@ void Load_Reference( const char *ruleset ) refstruct = (_Ref_Struct *) realloc(refstruct, (counters->refcount+1) * sizeof(_Ref_Struct)); } - firststring = strtok_r(refbuf, ":", &saveptr); + strtok_r(refbuf, ":", &saveptr); tmptoken = strtok_r(NULL, " " , &saveptr); laststring = strtok_r(tmptoken, ",", &saveptr); diff --git a/src/sagan-util.c b/src/sagan-util.c index bd708bb8..f21a2910 100644 --- a/src/sagan-util.c +++ b/src/sagan-util.c @@ -69,9 +69,8 @@ sbool daemonize; void Chroot(const char *username, const char *chrootdir ) { - struct passwd *pw = NULL; - - pw = getpwnam(username); +// struct passwd *pw = NULL; +// pw = getpwnam(username); printf("[*] Chroot to %s\n", chrootdir); diff --git a/src/sagan.h b/src/sagan.h index 4a5d4c21..2b3c0413 100644 --- a/src/sagan.h +++ b/src/sagan.h @@ -315,4 +315,5 @@ int Sagan_Validate_HEX (const char *); char *Sagan_Content_Pipe(char *, int, const char *); sbool is_rfc1918 ( char * ); char *Sagan_Replace_Sagan( char *, char *); +int Sagan_Character_Count ( char *, char *);