Skip to content

Commit 00adc9c

Browse files
author
Richard Jones
committed
OTK generation was busted (thanks Stuart D. Gathman)
1 parent 02b1e71 commit 00adc9c

File tree

5 files changed

+21
-5
lines changed

5 files changed

+21
-5
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Fixed:
77
- MultiMapping deviated from the Zope C implementation in a number of
88
places (thanks Toby Sargeant)
99
- MySQL and Postgresql use BOOL/BOOLEAN for Boolean types
10+
- OTK generation was busted (thanks Stuart D. Gathman)
1011

1112

1213
2004-03-27 0.7.0b2

doc/index.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ Paul F. Dubois,
7979
Jeff Epler,
8080
Tom Epperly,
8181
Hernan Martinez Foffani,
82+
Stuart D. Gathman,
8283
Ajit George,
8384
Frank Gibbons,
8485
Johannes Gijsbers,

roundup/backends/sessions_dbm.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#$Id: sessions_dbm.py,v 1.4 2004-03-26 23:56:11 richard Exp $
1+
#$Id: sessions_dbm.py,v 1.5 2004-03-31 23:08:38 richard Exp $
22
"""This module defines a very basic store that's used by the CGI interface
33
to store session and one-time-key information.
44
@@ -22,6 +22,13 @@ def __init__(self, db):
2222
# ensure files are group readable and writable
2323
os.umask(0002)
2424

25+
def exists(self, infoid):
26+
db = self.opendb('c')
27+
try:
28+
return db.has_key(infoid)
29+
finally:
30+
db.close()
31+
2532
def clear(self):
2633
path = os.path.join(self.dir, self.name)
2734
if os.path.exists(path):

roundup/backends/sessions_rdbms.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#$Id: sessions_rdbms.py,v 1.1 2004-03-18 01:58:45 richard Exp $
1+
#$Id: sessions_rdbms.py,v 1.2 2004-03-31 23:08:39 richard Exp $
22
"""This module defines a very basic store that's used by the CGI interface
33
to store session and one-time-key information.
44
@@ -21,6 +21,12 @@ def __init__(self, db):
2121
def clear(self):
2222
self.cursor.execute('delete from %ss'%self.name)
2323

24+
def exists(self, infoid):
25+
n = self.name
26+
self.cursor.execute('select count(*) from %ss where %s_key=%s'%(n,
27+
n, self.db.arg), (infoid,))
28+
return self.cursor.fetchone()[0]
29+
2430
_marker = []
2531
def get(self, infoid, value, default=_marker):
2632
n = self.name

roundup/cgi/actions.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#$Id: actions.py,v 1.21 2004-03-30 06:43:08 richard Exp $
1+
#$Id: actions.py,v 1.22 2004-03-31 23:08:39 richard Exp $
22

33
import re, cgi, StringIO, urllib, Cookie, time, random
44

@@ -723,6 +723,7 @@ def handle(self):
723723
elif isinstance(proptype, hyperdb.Password):
724724
props[propname] = str(value)
725725
otks = self.db.getOTKManager()
726+
otk = ''.join([random.choice(chars) for x in range(32)])
726727
while otks.exists(otk):
727728
otk = ''.join([random.choice(chars) for x in range(32)])
728729
otks.set(otk, **props)
@@ -744,8 +745,8 @@ def handle(self):
744745
745746
""" % {'name': props['username'], 'tracker': tracker_name, 'url': self.base,
746747
'otk': otk, 'tracker_email': tracker_email}
747-
if not self.client.standard_message([props['address']], subject, body,
748-
tracker_email):
748+
if not self.client.standard_message([props['address']], subject,
749+
body, tracker_email):
749750
return
750751

751752
# commit changes to the database

0 commit comments

Comments
 (0)