Revision: 7935
http://syscheck.svn.sourceforge.net/syscheck/?rev=7935&view=rev
Author: kinneh
Date: 2010-11-28 22:08:45 +0000 (Sun, 28 Nov 2010)
Log Message:
-----------
Closes #46 - change 905_publish_crl.sh to be able to warn and error depending on how long time is left
Modified Paths:
--------------
trunk/syscheck/config/905.conf
trunk/syscheck/lang/905.english
trunk/syscheck/lib/cmp_dates.pl
trunk/syscheck/related-available/905_publish_crl.sh
Modified: trunk/syscheck/config/905.conf
===================================================================
--- trunk/syscheck/config/905.conf 2010-11-28 19:05:59 UTC (rev 7934)
+++ trunk/syscheck/config/905.conf 2010-11-28 22:08:45 UTC (rev 7935)
@@ -1,6 +1,5 @@
# config for 905_publish_crl.sh
-HOURTHRESHOLD=1
CRLCANAME[0]=MSDomainLogonCA
REMOTE_HOST[0]=localhost
@@ -8,13 +7,18 @@
CRL_NAME[0]=MSDomainLogonCA.crl
SSHUSER[0]=
SSHKEY[0]=
+CRLWARNTIME[0]=4h
+CRLERRORTIME[0]=60m
+
CRLCANAME[1]=eSignCA
REMOTE_HOST[1]=localhost
CRLTO_DIR[1]='/srv/www/htdocs/crl/'
CRL_NAME[1]=eSignCA.crl
SSHUSER[1]=
SSHKEY[1]=
+CRLWARNTIME[1]=4h
+CRLERRORTIME[1]=60m
CRLCANAME[2]=ServerCA
CRLTO_DIR[2]='/srv/www/htdocs/crl/'
@@ -22,6 +26,8 @@
CRL_NAME[2]=ServerCA.crl
SSHUSER[2]=
SSHKEY[2]=
+CRLWARNTIME[2]=4h
+CRLERRORTIME[2]=60m
CRLCANAME[3]=eIDCA
CRLTO_DIR[3]='/srv/www/htdocs/crl/'
@@ -29,6 +35,8 @@
CRL_NAME[3]=eIDCA.crl
SSHUSER[3]=
SSHKEY[3]=
+CRLWARNTIME[3]=4h
+CRLERRORTIME[3]=60m
CRLCANAME[4]=MachineCertCA
CRLTO_DIR[4]='/srv/www/htdocs/crl/'
@@ -36,6 +44,8 @@
CRL_NAME[4]=MachineCertCA.crl
SSHUSER[4]=
SSHKEY[4]=
+CRLWARNTIME[4]=4h
+CRLERRORTIME[4]=60m
CRLCANAME[5]=SoftTokenCA
CRLTO_DIR[5]='/srv/www/htdocs/crl/'
@@ -43,5 +53,7 @@
CRL_NAME[5]=SoftTokenCA.crl
SSHUSER[5]=
SSHKEY[5]=
+CRLWARNTIME[5]=4h
+CRLERRORTIME[5]="60m"
### end config ###
Modified: trunk/syscheck/lang/905.english
===================================================================
--- trunk/syscheck/lang/905.english 2010-11-28 19:05:59 UTC (rev 7934)
+++ trunk/syscheck/lang/905.english 2010-11-28 22:08:45 UTC (rev 7935)
@@ -1,6 +1,6 @@
PUBL_HELP="Script to publish the CRL:s from the CA, supports local and remote publishing by SSH"
-PUBL_DESCR_1="Publish CRL run successfully (%s)"
+PUBL_DESCR_1="Publish CRL run successfully (%s) %s"
PUBL_HELP_1="No action needed"
PUBL_DESCR_2="Publish to remote host failed crl:(%s) host:(%s)"
@@ -18,8 +18,15 @@
PUBL_DESCR_6="File size of CRL is 0 (%s)"
PUBL_HELP_6="Probably some problem getting the file/or filerights"
-PUBL_DESCR_7="CRL is outdated %s (%s)"
+PUBL_DESCR_7="CRL has past error time %s (%s)"
PUBL_HELP_7="This script cant get a new CRL, check the CA-logs"
PUBL_DESCR_8="CRL:%s is published to host:%s"
PUBL_HELP_8="no action needed"
+
+PUBL_DESCR_9="CRL has past warn time %s (%s)"
+PUBL_HELP_9="This script cant get a new CRL, check the CA-logs"
+
+PUBL_DESCR_10="Retrived and checked CRL (%s) %s"
+PUBL_HELP_10="No action needed"
+
Modified: trunk/syscheck/lib/cmp_dates.pl
===================================================================
--- trunk/syscheck/lib/cmp_dates.pl 2010-11-28 19:05:59 UTC (rev 7934)
+++ trunk/syscheck/lib/cmp_dates.pl 2010-11-28 22:08:45 UTC (rev 7935)
@@ -3,7 +3,9 @@
use Date::Manip;
my $indate = $ARGV[0];
+my $returnMinutes = $ARGV[1];
+
$now = localtime;
my %mon2int = ( "Jan" => "1",
@@ -33,6 +35,12 @@
$date2 = Date_SecsSince1970($nmon,$nmday,$nyear,$nhour,$nmin,$nsec);
# diff
-my $diff=int(($date1 - $date2)/3600);
+my $diff=0;
+if ( $returnMinutes eq "--return-in-minutes"){
+ $diff=int(($date1 - $date2)/60);
+}else{
+ $diff=int(($date1 - $date2)/3600);
+}
+
print "$diff\n";
Modified: trunk/syscheck/related-available/905_publish_crl.sh
===================================================================
--- trunk/syscheck/related-available/905_publish_crl.sh 2010-11-28 19:05:59 UTC (rev 7934)
+++ trunk/syscheck/related-available/905_publish_crl.sh 2010-11-28 22:08:45 UTC (rev 7935)
@@ -38,6 +38,8 @@
ERRNO_6=${SCRIPTID}6
ERRNO_7=${SCRIPTID}7
ERRNO_8=${SCRIPTID}8
+ERRNO_9=${SCRIPTID}8
+ERRNO_10=${SCRIPTID}8
@@ -57,10 +59,11 @@
CRLFILE=$2
cd ${EJBCA_HOME}
printtoscreen "${EJBCA_HOME}/bin/ejbca.sh ca getcrl $CRLNAME $CRLFILE"
- ${EJBCA_HOME}/bin/ejbca.sh ca getcrl $CRLNAME "$CRLFILE"
+ CMD=$(${EJBCA_HOME}/bin/ejbca.sh ca getcrl $CRLNAME "$CRLFILE")
if [ $? != 0 -o ! -r $CRLFILE ] ; then
printlogmess $ERROR $ERRNO_6 "$PUBL_DESCR_6" "$CRLNAME/$CRLFILE"
fi
+ printtoscreen $CMD
}
@@ -88,8 +91,48 @@
checkcrl () {
CRLFILE=$1
+ WTIME=$2
+ ETIME=$2
+ wishour=$(echo $WTIME | grep -i "h")
+ wismin=$(echo $WTIME | grep -i "m")
+ wdigits=$(echo $WTIME| perl -ane 'm/(\d+)/,print "$1"')
+ wunit="hours"
+ wcmdopts=""
+ if [ "x$wismin" != "x" ] ; then
+ wcmdopts="--return-in-minutes"
+ wunit="minutes"
+ elif [ "x$wishour" != "x" ] ; then
+# TIME=$digits
+ wunit="hours"
+ else
+ # todo fail not known time
+ # default to use only number as before
+# TIME=$digits
+ wunit="hours"
+ fi
+ WTIME=$wdigits
+ eishour=$(echo $ETIME | grep -i "h")
+ eismin=$(echo $ETIME | grep -i "m")
+ edigits=$(echo $ETIME| perl -ane 'm/(\d+)/,print "$1"')
+ eunit="hours"
+ ecmdopts=""
+ if [ "x$eismin" != "x" ] ; then
+ ecmdopts="--return-in-minutes"
+ eunit="minutes"
+ elif [ "x$eishour" != "x" ] ; then
+# TIME=$digits
+ eunit="hours"
+ else
+ # todo fail not known time
+ # default to use only number as before
+# TIME=$digits
+ eunit="hours"
+ fi
+ ETIME=$edigits
+
+
# file not found where it should be
if [ ! -f $CRLFILE ] ; then
printlogmess $ERROR $ERRNO_4 "$PUBL_DESCR_4" $CRLFILE
@@ -112,13 +155,20 @@
# now we can check the crl:s best before date is in the future with atleast HOURTHRESHOLD hours (defined in resources)
TEMPDATE=`openssl crl -inform der -in $CRLFILE -nextupdate -noout`
DATE=${TEMPDATE:11}
- HOURSLEFT=`${SYSCHECK_HOME}/lib/cmp_dates.pl "$DATE"`
+ WTIMELEFT=$(${SYSCHECK_HOME}/lib/cmp_dates.pl "$DATE" ${wcmdopts})
+ ETIMELEFT=$(${SYSCHECK_HOME}/lib/cmp_dates.pl "$DATE" ${ecmdopts})
- if [ "$HOURSLEFT" -lt "$HOURTHRESHOLD" ] ; then
- printlogmess $ERROR $ERRNO_7 "$PUBL_DESCR_7" $CRLFILE "hoursleft: ${HOURSLEFT} limit: ${HOURTHRESHOLD}"
+ if [ "$ETIMELEFT" -lt "$ETIME" ] ; then
+ printlogmess $ERROR $ERRNO_7 "$PUBL_DESCR_7" $CRLFILE "timeleft: ${ETIMELEFT}${eunit} limit: ${ETIME}${eunit}"
return 7
+
+ elif [ "$WTIMELEFT" -lt "$WTIME" ] ; then
+ printlogmess $WARN $ERRNO_9 "$PUBL_DESCR_9" $CRLFILE "timeleft: ${WTIMELEFT}${wunit} limit: ${WTIME}${wunit}"
+ return 7
+
else
-# printlogmess $INFO $ERRNO_1 "$PUBL_DESCR_1" $CRLFILE
+ printlogmess $INFO $ERRNO_10 "$PUBL_DESCR_10" $CRLFILE "timeleft: ${WTIMELEFT}${wunit} limit: ${WTIME}${wunit}"
+ printtoscreen "$INFO $ERRNO_10 $PUBL_DESCR_10 $CRLFILE timeleft: ${WTIMELEFT}${wunit} limit: ${WTIME}${wunit}"
return 0
fi
}
@@ -132,7 +182,8 @@
CRLFILE=${tempdir}/${CRL_NAME[$i]}
get ${CRLCANAME[$i]} "${CRLFILE}"
- checkcrl "${CRLFILE}"
+ echo "${CRLFILE} ${CRLWARNTIME[$i]} ${CRLERRORTIME[$i]}"
+ checkcrl "${CRLFILE}" ${CRLWARNTIME[$i]} ${CRLERRORTIME[$i]}
if [ $? -ne 0 ] ; then
# check crl didn't pass the crl so we'll not publish this one and continue with the next
rm -rf $tempdir
@@ -142,7 +193,7 @@
if [ "x${REMOTE_HOST[$i]}" = "xlocalhost" ] ; then
cp -f ${CRLFILE} "${CRLTO_DIR[$i]}/${CRL_NAME[$i]}"
if [ $? -eq 0 ] ;then
- printlogmess $INFO $ERRNO_1 "$PUBL_DESCR_1" ${CRLCANAME[$i]}
+ printlogmess $INFO $ERRNO_1 "$PUBL_DESCR_1" ${CRLCANAME[$i]}
else
printlogmess $ERROR $ERRNO_3 "$PUBL_DESCR_3" ${CRL_NAME[$i]} "${CRLTO_DIR[$i]}/${CRL_NAME[$i]}"
fi
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|