SOURCES: chkrootkit-check - use mktemp instead of guessable tmpfil...

glen glen at pld-linux.org
Wed Nov 30 18:05:26 CET 2005


Author: glen                         Date: Wed Nov 30 17:05:26 2005 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- use mktemp instead of guessable tmpfile
- use wc -l instead of grep (should be faster)

---- Files affected:
SOURCES:
   chkrootkit-check (1.5 -> 1.6) 

---- Diffs:

================================================================
Index: SOURCES/chkrootkit-check
diff -u SOURCES/chkrootkit-check:1.5 SOURCES/chkrootkit-check:1.6
--- SOURCES/chkrootkit-check:1.5	Sat Aug 23 12:34:21 2003
+++ SOURCES/chkrootkit-check	Wed Nov 30 18:05:21 2005
@@ -3,15 +3,16 @@
 # Get service config
 [ -f /etc/sysconfig/chkrootkit ] && . /etc/sysconfig/chkrootkit
 
-DATA=`date`
+DATE=`date`
 SYSTEM=`hostname`
 
-cd /usr/bin/
-echo -n "Generated with: " > /var/tmp/$$
-/usr/bin/chkrootkit -V 2>> /var/tmp/$$
-/usr/bin/chkrootkit 2>&1 | /bin/egrep -v '(not (infected|found|promisc)|nothing (found|detected|deleted)|no suspect files|ROOTDIR is)' >> /var/tmp/$$
-LIN=`grep -c . /var/tmp/$$`
-if [ "$LIN" -gt "1" ]; then
-	mail -s "CHKROOTKIT $SYSTEM $DATA" $CHKROOTKIT_MAILTO < /var/tmp/$$
+cd /usr/bin
+t=`mktemp -d ${TMPDIR:-/tmp}/chkrootkitXXXXXX` || exit 1
+echo -n "Generated with: " > $t
+/usr/bin/chkrootkit -V 2>> $t
+/usr/bin/chkrootkit 2>&1 | /bin/egrep -v '(not (infected|found|promisc)|nothing (found|detected|deleted)|no suspect files|ROOTDIR is)' >> $t
+L=$(wc -l $t)
+if [ "${L% *}" -gt 1 ]; then
+	mail -s "CHKROOTKIT $SYSTEM $DATE" $CHKROOTKIT_MAILTO < $t
 fi
-rm -f /var/tmp/$$
+rm -f $t
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/SOURCES/chkrootkit-check?r1=1.5&r2=1.6&f=u




More information about the pld-cvs-commit mailing list