--- tools/openvas-scapdata-sync.in.orig 2017-05-02 07:32:45 UTC +++ tools/openvas-scapdata-sync.in @@ -63,7 +63,7 @@ fi # Delay between retries if [ -z "$SQL_RETRY_DELAY" ]; then - SQL_RETRY_DELAY="10m" # allowed unit suffixes: see sleep command + SQL_RETRY_DELAY="600" # allowed unit suffixes: see sleep command fi TIMESTAMP="$SCAP_DIR/timestamp" @@ -885,11 +885,11 @@ update_sec_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 @@ -958,7 +958,7 @@ update_sec_db_private () { DIR_STR_LENGTH=$((`echo "$SCAP_DIR" | wc -c` + 1)) oval_files_shortened="" - if [ 0 != "$xmlcount" ] + if [ "$xmlcount" -ne 0 ] then for ovalfile in $oval_files_sorted_private do @@ -968,7 +968,7 @@ update_sec_db_private () { fi oval_files_clause="" - if [ ! -z "$oval_files_shortened" ] + if [ "$oval_files_shortened" != "" ] then oval_files_clause="AND (xml_file NOT IN ($oval_files_shortened))" fi @@ -993,7 +993,7 @@ update_sec_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 ] @@ -1012,13 +1012,13 @@ update_sec_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 echo "[i] 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 echo "[i] File is larger than ${SPLIT_PART_SIZE}k. Splitting into multiple parts" @@ -1075,13 +1075,13 @@ update_sec_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 echo "[i] 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 echo "[i] File is larger than ${SPLIT_PART_SIZE}k. Splitting into multiple parts" @@ -1151,11 +1151,11 @@ update_sec_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 @@ -1206,7 +1206,7 @@ update_sec_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 ] do