From 52d59b14a8d896806d1d5906f2a400e56871d11a Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Tue, 5 Jun 2012 16:55:58 -0600 Subject: [PATCH 1/3] avoid duplicates in points.log --- packages/mcp/service/pointsd/pointsd | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/mcp/service/pointsd/pointsd b/packages/mcp/service/pointsd/pointsd index a6fc72f..a27e152 100755 --- a/packages/mcp/service/pointsd/pointsd +++ b/packages/mcp/service/pointsd/pointsd @@ -4,8 +4,10 @@ fn=$2/$3 POINTS=/var/lib/ctf/points.log SCOREBOARD=/var/www/scoreboard.html -cat $fn >> $POINTS || break -rm $fn +# Only do this if this score hasn't yet been recorded +if ! cut -d' ' -f2- $POINTS | grep -Fqx "$(cut -d' ' -f2- $fn)"; then + cat $fn >> $POINTS && rm $fn +fi # Render scoreboard if [ $POINTS -nt $SCOREBOARD ]; then From 1f799fa9275cd5a80a9f91c2a726a35ea0666f2c Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Tue, 5 Jun 2012 23:56:29 -0600 Subject: [PATCH 2/3] merge backup into pointsd --- packages/00admin/00admin.mk | 5 +++ packages/00admin/service/sshd/run | 4 ++- packages/mcp/bin/addteam | 7 ----- packages/mcp/bin/backup | 25 --------------- packages/mcp/bin/backup-pass | 38 ----------------------- packages/mcp/bin/scoreboard | 41 ++++++++++++++----------- packages/mcp/mcp.mk | 1 + packages/mcp/service/pointsd/bkup.png | Bin 0 -> 247 bytes packages/mcp/service/pointsd/pointsd | 27 ++++++++++++---- packages/mcp/www/bkup.png | Bin 215 -> 0 bytes packages/multicaster/src/multicaster.c | 2 -- packages/router/router.mk | 2 +- 12 files changed, 54 insertions(+), 98 deletions(-) delete mode 100755 packages/mcp/bin/backup delete mode 100755 packages/mcp/bin/backup-pass create mode 100644 packages/mcp/service/pointsd/bkup.png delete mode 100644 packages/mcp/www/bkup.png diff --git a/packages/00admin/00admin.mk b/packages/00admin/00admin.mk index 33dae36..6c77dc0 100644 --- a/packages/00admin/00admin.mk +++ b/packages/00admin/00admin.mk @@ -1,7 +1,12 @@ 00ADMIN_PKGDIR = $(TARGET)/00admin +ifndef PASSWORD +$(error PASSWORD not defined) +endif + 00admin-install: $(call COPYTREE, packages/00admin/service, $(00ADMIN_PKGDIR)/service) + echo "$(PASSWORD)" > $(00ADMIN_PKGDIR)/password mkdir -p $(00ADMIN_PKGDIR)/sbin cp packages/00admin/sbin/* $(00ADMIN_PKGDIR)/sbin diff --git a/packages/00admin/service/sshd/run b/packages/00admin/service/sshd/run index f4a6692..b2e99dd 100755 --- a/packages/00admin/service/sshd/run +++ b/packages/00admin/service/sshd/run @@ -2,7 +2,9 @@ exec 2>&1 -echo 'root:$1$i/EeZyl6$5C6Z8s0ftEdTKFLUli1wP1' | chpasswd --encrypted +read password < /opt/00admin/password + +printf 'root:%s' "$password" | chpasswd --md5 # Bring up the NIC; this will get us at least a link-local address, and # hopefully a global address with stateless autoconfiguration. diff --git a/packages/mcp/bin/addteam b/packages/mcp/bin/addteam index c7db910..76694d8 100755 --- a/packages/mcp/bin/addteam +++ b/packages/mcp/bin/addteam @@ -17,13 +17,6 @@ set -C base=${CTF_BASE:-/var/lib/ctf} www=${CTF_BASE:-/var/www} -if which backup-team >/dev/null 2>&1 ; then - if [ ! -e $base/pass ]; then - echo "\nYou should consider running backup-pass or new-contest." - echo "DBTL Altocumulus™ backup system will not work without it.\n" - fi -fi - mkdir -p $base/teams/names mkdir -p $base/teams/colors diff --git a/packages/mcp/bin/backup b/packages/mcp/bin/backup deleted file mode 100755 index e4c929f..0000000 --- a/packages/mcp/bin/backup +++ /dev/null @@ -1,25 +0,0 @@ -#! /bin/sh -e - -base=${CTF_BASE:-/var/lib/ctf} -www=${CTF_BASE:-/var/www} -pass=$base/pass -img=$www/bkup.png -time=$(date +%s) -output=bkup-${time}.png - -if [ ! -e $img -o ! -e $pass ]; then - exit 0 -fi - -# clean up all other backup images -if ls $www/bkup-*.png >/dev/null 2>&1 ; then - rm $www/bkup-*.png -fi - -# This is a tested method. -#(cat $img; tar -cf - $base 2>/dev/null | gzip -c ) > $www/$output - -# This is not a tested method. -(cat $img; tar -cvf - $base 2>/dev/null | gzip -c | rc4 3< $pass) > $www/$output - -echo $output diff --git a/packages/mcp/bin/backup-pass b/packages/mcp/bin/backup-pass deleted file mode 100755 index 4c34961..0000000 --- a/packages/mcp/bin/backup-pass +++ /dev/null @@ -1,38 +0,0 @@ -#! /bin/sh -e - -trap "stty echo; echo ''; echo 'Passfile not written'; exit 42" 1 2 3 15 - -askpass () { - echo "Password: " - stty -echo - read pass1 - echo "Retype password: " - read pass2 - stty echo - if [ "${pass1}" = "${pass2}" ]; then - echo "Got it.\n" - return 0 - else - echo "Authentication token manipulation error.\n" - return 1 - fi -} - -base=${CTF_BASE:-/var/lib/ctf} -passfile=$base/pass - -if [ -e $passfile ]; then - echo "\nDanger! Danger!\n" - echo "Wipes out current passfile. It's ok as long as note the current" - echo "timestamp ($(date +%s)) and the new pass will be applied on the" - echo "next scoreboard update.\n" -fi - -echo "Enter passphrase for backups" -echo "To exit, press ctrl+c" -until askpass; do true; done - -echo -e "${pass1}" > $passfile -echo "Passfile written" -stty echo - diff --git a/packages/mcp/bin/scoreboard b/packages/mcp/bin/scoreboard index ff62e5a..cd6c21e 100755 --- a/packages/mcp/bin/scoreboard +++ b/packages/mcp/bin/scoreboard @@ -77,27 +77,31 @@ BEGIN { tslen = 0 nteams = 0; - while (1 == getline) { - time = $1 - team = $2 - cat = $3 - points = int($4) +} - if (! start) { - start = time - } +# MAINLOOP +{ + time = $1 + team = $2 + cat = $3 + points = int($4) - if (time > (outtime + interval)) { - outtime = time - output() - } - lasttime = time - - teams[team] = nteams++ - points_by_cat[cat] += points - points_by_cat_team[cat, team] += points + if (! start) { + start = time } + if (time > (outtime + interval)) { + outtime = time + output() + } + lasttime = time + + teams[team] = nteams++ + points_by_cat[cat] += points + points_by_cat_team[cat, team] += points +} + +END { output() # Get team colors and names @@ -180,7 +184,8 @@ BEGIN { print " " print " " print "

Scoreboard

" - print "

" + print "

" + print " \"\"" print " " print " " print " " diff --git a/packages/mcp/mcp.mk b/packages/mcp/mcp.mk index ed90ab2..b9bc2c8 100644 --- a/packages/mcp/mcp.mk +++ b/packages/mcp/mcp.mk @@ -31,6 +31,7 @@ mcp-install: $(MCP_BUILDDIR)/build $(call COPYTREE, packages/mcp/bin, $(MCP_PKGDIR)/bin) cp packages/mcp/src/pointscli $(MCP_PKGDIR)/bin/ cp packages/mcp/src/puzzles.cgi $(MCP_PKGDIR)/bin/ + cp packages/mcp/src/tea $(MCP_PKGDIR)/bin/ cp $(MCP_BUILDDIR)/eris/eris $(MCP_PKGDIR)/bin/ diff --git a/packages/mcp/service/pointsd/bkup.png b/packages/mcp/service/pointsd/bkup.png new file mode 100644 index 0000000000000000000000000000000000000000..aea14245355d30c1075f63870990aec2a5647af5 GIT binary patch literal 247 zcmeAS@N?(olHy`uVBq!ia0vp^%s|Y}!3HGH?)<(INUlBZdeGzF0Tp00i_>zopr0FeJirvLx| literal 0 HcmV?d00001 diff --git a/packages/mcp/service/pointsd/pointsd b/packages/mcp/service/pointsd/pointsd index a27e152..c9c9ba0 100755 --- a/packages/mcp/service/pointsd/pointsd +++ b/packages/mcp/service/pointsd/pointsd @@ -1,16 +1,31 @@ -#! /bin/sh +#! /bin/sh -e fn=$2/$3 -POINTS=/var/lib/ctf/points.log -SCOREBOARD=/var/www/scoreboard.html + +WWW=${CTF_BASE:-/var/www} +BASE=${CTF_BASE:-/var/lib/ctf} +OPT=${CTF_BASE:-/opt} + +POINTS=$BASE/points.log +BACKUP=$WWW/backup.png +SCOREBOARD=$WWW/scoreboard.html # Only do this if this score hasn't yet been recorded if ! cut -d' ' -f2- $POINTS | grep -Fqx "$(cut -d' ' -f2- $fn)"; then - cat $fn >> $POINTS && rm $fn + cat $fn >> $POINTS + rm $fn fi -# Render scoreboard if [ $POINTS -nt $SCOREBOARD ]; then - /opt/mcp/bin/scoreboard < $POINTS > $SCOREBOARD.new && mv $SCOREBOARD.new $SCOREBOARD + # Generate new backup + ( + cat bkup.png; + tar cvf - $BASE | gzip -c | $OPT/00admin/bin/tea 3< $OPT/00admin/password + ) > $BACKUP.new + mv $BACKUP.new $BACKUP + + # Render scoreboard + /opt/mcp/bin/scoreboard < $POINTS > $SCOREBOARD.new + mv $SCOREBOARD.new $SCOREBOARD fi diff --git a/packages/mcp/www/bkup.png b/packages/mcp/www/bkup.png deleted file mode 100644 index 89c959ce31cff7748a37faccf83d2ab37ca25463..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 215 zcmeAS@N?(olHy`uVBq!ia0vp^%s|Y}!3HGH?)<(INHG=%xjQkeJ16rJ$YD$Jc6VX; z4}uH!E}sk(2`_PtC~?lu%}vcKVF<~{ELH%by!;Y{M1_LVs;Zn+Jq3l3jKsWbh06R= zg|z%4g{0KXymW=cg2bW{h5R&yl8jUZm&~G)q{Q@Mg`~vf?9u{-;>zNZ)Lgw~%y!3t zR>*j|IEHXsPfj?%^v~D;2o$>ySolj8H2#-RVrcMWdNDUVO#!Hm!PC{xWt~$(699XK BLni Date: Wed, 6 Jun 2012 00:03:40 -0600 Subject: [PATCH 3/3] ignore printf build warnings --- packages/printf/src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/printf/src/Makefile b/packages/printf/src/Makefile index 5def83f..2b1fce6 100644 --- a/packages/printf/src/Makefile +++ b/packages/printf/src/Makefile @@ -1,4 +1,4 @@ -CFLAGS = -Wall -Werror +CFLAGS = -Wall LDFLAGS = -static TARGETS = printf
Overall