Skip to content
This repository has been archived by the owner on Apr 19, 2021. It is now read-only.

Commit

Permalink
random cron delay should be at least 10 minutes
Browse files Browse the repository at this point in the history
  • Loading branch information
dougburks committed May 15, 2016
1 parent b2e25ba commit b348f79
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 2 deletions.
5 changes: 3 additions & 2 deletions bin/so-squert-ip2c
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ else
date > $IP2C_LOG
echo >> $IP2C_LOG

# If running from cron, pause for a random number of minutes (up to 50).
# If running from cron, pause for a random number of minutes (between 10 and 50).
if [ $# -eq 1 ] && [ $1 == "cron" ]; then
RMIN=$(($(dd if=/dev/urandom count=1 2> /dev/null | cksum | cut -d' ' -f1) % 50));
RMIN=$(($(dd if=/dev/urandom count=1 2> /dev/null | cksum | cut -d' ' -f1) % 40));
let RMIN=RMIN+10
echo "Sleeping for $RMIN minutes to avoid overwhelming sites." >> $IP2C_LOG
sleep ${RMIN}m
date >> $IP2C_LOG
Expand Down
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
securityonion-squert-cron (20120722-0ubuntu0securityonion9) trusty; urgency=medium

* random cron delay should be at least 10 minutes

-- Doug Burks <doug.burks@gmail.com> Sun, 15 May 2016 06:46:30 -0400

securityonion-squert-cron (20120722-0ubuntu0securityonion8) trusty; urgency=medium

* change $LOG to $IP2C_LOG
Expand Down
40 changes: 40 additions & 0 deletions debian/patches/random-cron-delay-should-be-at-least-10-minutes
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Description: <short summary of the patch>
TODO: Put a short summary on the line above and replace this paragraph
with a longer explanation of this change. Complete the meta-information
with other relevant fields (see below for details). To make it easier, the
information below has been extracted from the changelog. Adjust it or drop
it.
.
securityonion-squert-cron (20120722-0ubuntu0securityonion9) trusty; urgency=medium
.
* random cron delay should be at least 10 minutes
Author: Doug Burks <doug.burks@gmail.com>

---
The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: <vendor|upstream|other>, <url of original patch>
Bug: <url in upstream bugtracker>
Bug-Debian: http://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Reviewed-By: <name and email of someone who approved the patch>
Last-Update: <YYYY-MM-DD>

--- securityonion-squert-cron-20120722.orig/bin/so-squert-ip2c
+++ securityonion-squert-cron-20120722/bin/so-squert-ip2c
@@ -48,9 +48,10 @@ else
date > $IP2C_LOG
echo >> $IP2C_LOG

- # If running from cron, pause for a random number of minutes (up to 50).
+ # If running from cron, pause for a random number of minutes (between 10 and 50).
if [ $# -eq 1 ] && [ $1 == "cron" ]; then
- RMIN=$(($(dd if=/dev/urandom count=1 2> /dev/null | cksum | cut -d' ' -f1) % 50));
+ RMIN=$(($(dd if=/dev/urandom count=1 2> /dev/null | cksum | cut -d' ' -f1) % 40));
+ let RMIN=RMIN+10
echo "Sleeping for $RMIN minutes to avoid overwhelming sites." >> $IP2C_LOG
sleep ${RMIN}m
date >> $IP2C_LOG
1 change: 1 addition & 0 deletions debian/patches/series
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ Squert-ip2c-cron-job-should-run-as-a-non-root-user-and-sleep-a-random-number-of-
add-cron-option-to-force-random-delay
upload-to-git
change-$LOG-to-$IP2C_LOG
random-cron-delay-should-be-at-least-10-minutes

0 comments on commit b348f79

Please sign in to comment.