A few path changes for easier local testing

This commit is contained in:
Neale Pickett 2009-10-01 18:33:21 -06:00
parent 35725ee3e5
commit 36a430e9a1
10 changed files with 78 additions and 41 deletions

View File

@ -6,10 +6,11 @@ WWWDIR = $(DESTDIR)/usr/lib/www
FAKE = fakeroot -s fake -i fake
INSTALL = $(FAKE) install
PYC = config.pyc points.pyc game.pyc teams.pyc
PYC = config.pyc points.pyc teams.pyc
PYC += register.pyc scoreboard.pyc puzzler.pyc
PYC += flagd.pyc pointsd.pyc pointscli.pyc
PYC += roshambo.pyc histogram.pyc
PYC += histogram.pyc
#PYC += roshambo.pyc game.pyc
all: ctf.tce

View File

@ -12,8 +12,8 @@ if 'home' in os.environ.get('SCRIPT_FILENAME', ''):
config = {'global':
{'data_dir': '.',
'base_url': '.',
'css_url': 'ctf.css',
'diasbled_dir': 'disabled',
'css_url': '/~neale/ctf/ctf.css',
'disabled_dir': 'disabled',
'flags_dir': 'flags',
'house_team': 'dirtbags',
'passwd': 'passwd',

51
ctf.css
View File

@ -12,6 +12,26 @@ body {
max-width: 700px;
}
/**** heading ****/
h1:first-child {
text-transform: lowercase;
font-size: 1.6em;
/* background-color: #222; */
/* opacity: 0.9; */
padding: 3px;
color: #2a2;
margin: 0 0 1em 70px;
}
h1:first-child:before {
color: #fff;
letter-spacing: -0.1em;
content: "Capture The Flag: ";
}
/**** body ****/
a img {
border: 0px;
}
@ -28,6 +48,12 @@ a:hover {
font-weight: bold;
}
h1, h2, h3 {
color: #999;
letter-spacing: -0.05em;
}
code, pre, .readme {
color: #fff;
background-color: #555;
@ -42,33 +68,12 @@ th, td {
height: 400px;
}
/**** heading ****/
h1:first-child {
text-transform: lowercase;
font-size: 1.6em;
background-color: #222;
opacity: 0.9;
padding: 3px;
color: #2a2;
margin: 0 0 1em 70px;
}
h1:first-child:before {
color: #fff;
letter-spacing: -0.1em;
content: "Capture The Flag: ";
}
/*** body ***/
p {
line-height: 1.4em;
margin-bottom: 20px;
color: #f4f4f4;
}
h1, h2, h3 {
color: #999;
letter-spacing: -0.05em;
.center {
text-align: center;
}

27
ctfd.py
View File

@ -6,21 +6,38 @@ import game
import flagd
import histogram
import config
import os
import sys
do_reap = False
def chart(s):
if not os.fork():
histogram.main(s)
sys.exit(0)
def reap():
try:
while True:
os.waitpid(0, os.WNOHANG)
except OSError:
pass
def sigchld(signum, frame):
do_reap = True
def main():
pointsrv = pointsd.start()
flagsrv = flagd.start()
if config.enabled('roshambo'):
import roshambo
roshambosrv = roshambo.start()
s = pointsrv.store
slen = 0
while True:
if do_reap:
reap()
asyncore.loop(timeout=30, use_poll=True, count=1)
if len(s) > slen:
slen = len(s)
histogram.main(s)
chart(s)
main()

View File

@ -21,7 +21,7 @@ def hexdigest(data):
flags_dir = config.get('global', 'flags_dir')
class Submitter(asyncore.dispatcher):
def __init__(self, host='localhost', port=6667):
def __init__(self, host='', port=6667):
asyncore.dispatcher.__init__(self)
self.create_socket(socket.AF_INET, socket.SOCK_DGRAM)
self.connect((host, port))
@ -70,6 +70,8 @@ class Submitter(asyncore.dispatcher):
raise ValueError(txt)
def set_flag(self, cat, team):
if not cat:
return
now = int(time.time())
team = team or teams.house

View File

@ -17,7 +17,6 @@ def main(s=None):
s = points.Storage()
plotparts = []
teams = s.teams
catscores = {}
for cat in s.categories():
@ -26,14 +25,14 @@ def main(s=None):
scoresfile = tempfile.NamedTemporaryFile('w')
fn = scoresfile.name
i = 2
for team in teams:
for team in s.teams:
plotparts.append('"%s" using 1:%d with lines linewidth 2 linetype rgb "#%s"' % (fn, i, teams.color(team)))
scores[team] = 0
i += 1
def write_scores(t):
scoresfile.write('%d' % t)
for team in teams:
for team in s.teams:
scoresfile.write('\t%f' % (scores[team]))
scoresfile.write('\n')
@ -65,7 +64,7 @@ plot %(plot)s\n''' % {'plot': ','.join(plotparts),
'pngout': pngout})
instructions.flush()
gp = os.system('gnuplot %s 2>/dev/null' % instructions.name)
gp = os.system('gnuplot %s 2>/dev/null </dev/null' % instructions.name)
if __name__ == '__main__':
main()

View File

@ -22,7 +22,10 @@ for cat in os.listdir(opts.puzzles):
for points in os.listdir(dirname):
pointsdir = os.path.join(dirname, points)
outdir = os.path.join(opts.htmldir, cat, points)
os.makedirs(outdir)
try:
os.makedirs(outdir)
except OSError:
pass
readme = ''
files = []
@ -33,6 +36,8 @@ for cat in os.listdir(opts.puzzles):
keys.append((cat, points, key))
elif fn == 'index.html':
readme = open(path, encoding='utf-8').read()
elif fn.endswith('~'):
pass
else:
files.append((fn, path))

View File

@ -28,6 +28,10 @@ def main():
<body>
<h1>Team Registration</h1>
<p>
Pick a short team name: you'll be typing it a lot.
</p>
<form method="post" action="%s">
<fieldset>
<legend>Registration information:</legend>

View File

@ -1,4 +1,4 @@
#! /bin/sh
exec /usr/lib/ctf/ctfd.py
exec envuidgid ctf /usr/lib/ctf/ctfd.py 2>&1

View File

@ -15,6 +15,7 @@ def main():
categories = [(cat, s.cat_points(cat)) for cat in s.categories()]
print('Content-type: text/html')
print('Refresh: 10')
print()
print('''<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
@ -24,7 +25,7 @@ def main():
<title>Scoreboard</title>
<link rel="stylesheet" href="%sctf.css" type="text/css" />
</head>
<body>
<body style="max-width: inherit;">
<h1>Scoreboard</h1>
''' % config.base_url)
print('<table class="scoreboard">')
@ -66,7 +67,10 @@ def main():
print('</tr>')
print('''</table>
<img src="histogram.png" alt=""/>
<p class="center">
<img src="histogram.png" alt="scores over time" />
</p>
</body>
</html>''')