--- tools/greenbone-scapdata-sync.in.orig 2015-12-08 07:09:31 UTC +++ tools/greenbone-scapdata-sync.in @@ -297,7 +297,7 @@ is_feed_current () { then log_err "Could not determine credentials, aborting synchronization." rm -rf $FEED_INFO_TEMP_DIR - exit -1 + exit 1 fi # --protocol=29 is a workaround for a known bug in rsync 3.0.3 @@ -321,12 +321,12 @@ is_feed_current () { then log_err "rsync failed, aborting synchronization." rm -rf $FEED_INFO_TEMP_DIR - exit -1 + exit 1 fi else log_err "Could not find access key, aborting synchronization." rm -rf $FEED_INFO_TEMP_DIR - exit -1 + exit 1 fi FEED_VERSION_SERVER=`cat $FEED_INFO_TEMP_DIR/timestamp` @@ -335,7 +335,7 @@ is_feed_current () { then log_err "Could not determine server feed version." rm -rf $FEED_INFO_TEMP_DIR - exit -1 + exit 1 fi # Check against FEED_VERSION @@ -962,11 +962,11 @@ update_scap_db_private () { then for ovalfile in $oval_files_sorted_private do - filedate=`stat -c "%Y" "$ovalfile" | cut -d " " -f 1 | tr -d "-"` + filedate=`stat -f "%m" "$ovalfile" | cut -d " " -f 1 | tr -d "-"` filedate=$(( $filedate - ( $filedate % 60 ) )) if [ $filedate -gt $DB_LASTUPDATE ] || [ 1 = "$REBUILD_OVAL" ] then - oval_timestamp=`xsltproc "$SCAP_RES_DIR/oval_timestamp.xsl" "$ovalfile" | date "+%s" -f -` + oval_timestamp=`date -j -f "%Y-%m-%dT%H:%M:%S" $(xsltproc "$SCAP_RES_DIR/oval_timestamp.xsl" "$ovalfile" | cut -d "." -f1) +%s` if [ 1 = "$REBUILD_OVAL" ] then @@ -1068,8 +1068,8 @@ update_scap_db_private () { fi # TODO: This is not quite accurate as it uses the timestamp of the non-private data. - LAST_UPDATE_TIMESTAMP=`sed 's/^\(.\{8\}\)/\1 /' $TIMESTAMP | date +%s -f -` - + LAST_UPDATE_TIMESTAMP=`date -j -f '%Y%m%d%H%M%S' $(sed 's/$/00/g' $TIMESTAMP) +%s` + reset_sql_tries until [ "$try_sql" -eq 0 ] do @@ -1090,12 +1090,12 @@ update_scap_db() { CPEBASE="$SCAP_DIR/official-cpe-dictionary_v2.2.xml" if [ -e $CPEBASE ] then - filedate=`stat -c "%Y" "$CPEBASE" | cut -d " " -f 1 | tr -d "-"` + filedate=`stat -f "%m" "$CPEBASE" | cut -d " " -f 1 | tr -d "-"` filedate=$(( $filedate - ( $filedate % 60 ) )) if [ $filedate -gt $DB_LASTUPDATE ] then log_info "Updating CPEs" - filesize=`stat -c "%s" "$CPEBASE"` + filesize=`stat -f "%z" "$CPEBASE"` if [ "0" -ne "$SPLIT_PART_SIZE" ] && [ "$filesize" -gt $(($SPLIT_PART_SIZE * 1024)) ] then log_info "File is larger than ${SPLIT_PART_SIZE}k. Splitting into multiple parts" @@ -1152,13 +1152,13 @@ update_scap_db() { then for cvefile in `ls $SCAP_DIR/nvdcve-2.0-*.xml` do - filedate=`stat -c "%Y" "$cvefile" | cut -d " " -f 1 | tr -d "-"` + filedate=`stat -f "%m" "$cvefile" | cut -d " " -f 1 | tr -d "-"` filedate=$(( $filedate - ( $filedate % 60 ) )) if [ $filedate -gt $DB_LASTUPDATE ] then log_info "Updating $cvefile" - filesize=`stat -c "%s" "$cvefile"` + filesize=`stat -f "%z" "$cvefile"` if [ "0" -ne "$SPLIT_PART_SIZE" ] && [ "$filesize" -gt $(($SPLIT_PART_SIZE * 1024)) ] then log_info "File is larger than ${SPLIT_PART_SIZE}k. Splitting into multiple parts" @@ -1228,11 +1228,11 @@ update_scap_db() { for ovalfile in $oval_files_sorted do - filedate=`stat -c "%Y" "$ovalfile" | cut -d " " -f 1 | tr -d "-"` + filedate=`stat -f "%m" "$ovalfile" | cut -d " " -f 1 | tr -d "-"` filedate=$(( $filedate - ( $filedate % 60 ) )) if [ $filedate -gt $DB_LASTUPDATE ] || [ 1 = "$REBUILD_OVAL" ] then - oval_timestamp=`xsltproc "$SCAP_RES_DIR/oval_timestamp.xsl" "$ovalfile" | date "+%s" -f -` + oval_timestamp=`date -j -f '%Y-%m-%dT%H:%M:%S' $(xsltproc "$SCAP_RES_DIR/oval_timestamp.xsl" "$ovalfile" | cut -d "." -f1) +%s` if [ 1 = "$REBUILD_OVAL" ] then @@ -1284,7 +1284,7 @@ update_scap_db() { update_cvss update_placeholders - LAST_UPDATE_TIMESTAMP=`sed 's/^\(.\{8\}\)/\1 /' $TIMESTAMP | env TZ="UTC" date +%s -f -` + LAST_UPDATE_TIMESTAMP=`date -j -f '%Y%m%d%H%M%S' $(sed 's/$/00/g' $TIMESTAMP) +%s` reset_sql_tries until [ "$try_sql" -eq 0 ] @@ -1469,7 +1469,7 @@ then exit 1 fi -if [ $(id -u) -ne $(stat -c %u $SCAP_DB) ] +if [ $(id -u) -ne $(stat -f %u $SCAP_DB) ] then log_err "Not synchronizing or updating the database since the current user is not the owner of the database." echo "Not synchronizing or updating the database since the current user is not the owner of the database."