Removed supybot.databases.users.hash. Now we always hash by default, though the configuration file still supports unhashed passwords (useful for allowing owners to change passwords by editing the file).

This commit is contained in:
Jeremy Fincher 2004-12-20 19:47:53 +00:00
parent 07435be632
commit a82e806a2d
4 changed files with 20 additions and 29 deletions

View File

@ -1,3 +1,8 @@
* Changed the supybot.user configuration variable so that if it
isn't configured, the user will stay up-to-date with the current
version of the bot. To take advantage of this, set your
supybot.user configuration variable to ""
* Fixed a bug with AutoMode's auto-banning feature; a variable * Fixed a bug with AutoMode's auto-banning feature; a variable
was misspelled. was misspelled.

View File

@ -259,31 +259,24 @@ class User(callbacks.Privmsg):
removehostmask = wrap(removehostmask, ['private', 'otherUser', 'something', removehostmask = wrap(removehostmask, ['private', 'otherUser', 'something',
additional('something', '')]) additional('something', '')])
def setpassword(self, irc, msg, args, optlist, user, password,newpassword): def setpassword(self, irc, msg, args, user, password,newpassword):
"""[--hashed] <name> <old password> <new password> """<name> <old password> <new password>
Sets the new password for the user specified by <name> to Sets the new password for the user specified by <name> to
<new password>. Obviously this message must be sent to the bot <new password>. Obviously this message must be sent to the bot
privately (not in a channel). If --hashed is given, the password will privately (not in a channel). If the requesting user is an owner user
be hashed on disk (rather than being stored in plaintext. If the (and the user whose password is being changed isn't that same owner
requesting user is an owner user (and the user whose password is being user), then <old password> needn't be correct.
changed isn't that same owner user), then <old password> needn't be
correct.
""" """
hashed = conf.supybot.databases.users.hash()
for (option, arg) in optlist:
if option == 'hashed':
hashed = True
u = ircdb.users.getUser(msg.prefix) u = ircdb.users.getUser(msg.prefix)
if user.checkPassword(password) or \ if user.checkPassword(password) or \
(u.checkCapability('owner') and not u == user): (u.checkCapability('owner') and not u == user):
user.setPassword(newpassword, hashed=hashed) user.setPassword(newpassword)
ircdb.users.setUser(user) ircdb.users.setUser(user)
irc.replySuccess() irc.replySuccess()
else: else:
irc.error(conf.supybot.replies.incorrectAuthentication()) irc.error(conf.supybot.replies.incorrectAuthentication())
setpassword = wrap(setpassword, [getopts({'hashed':''}), 'otherUser', setpassword = wrap(setpassword, ['otherUser', 'something', 'something'])
'something', 'something'])
def username(self, irc, msg, args, hostmask): def username(self, irc, msg, args, hostmask):
"""<hostmask|nick> """<hostmask|nick>

View File

@ -755,8 +755,7 @@ class UsersDictionary(utils.IterableMap):
def newUser(self): def newUser(self):
"""Allocates a new user in the database and returns it and its id.""" """Allocates a new user in the database and returns it and its id."""
hashed = conf.supybot.databases.users.hash() user = IrcUser(hashed=True)
user = IrcUser(hashed=hashed)
self.nextId += 1 self.nextId += 1
id = self.nextId id = self.nextId
self.users[id] = user self.users[id] = user

View File

@ -87,19 +87,13 @@ class UserTestCase(PluginTestCase, PluginDocumentation):
self.assertNotError('changename foo baz') self.assertNotError('changename foo baz')
def testSetpassword(self): def testSetpassword(self):
orig = conf.supybot.databases.users.hash() self.prefix = self.prefix1
try: self.assertNotError('register foo bar')
conf.supybot.databases.users.hash.setValue(False) password = ircdb.users.getUser(self.prefix).password
self.prefix = self.prefix1 self.assertNotEqual(password, 'bar')
self.assertNotError('register foo bar') self.assertNotError('setpassword foo bar baz')
self.assertEqual(ircdb.users.getUser(self.prefix).password, 'bar') self.assertNotEqual(ircdb.users.getUser(self.prefix).password,password)
self.assertNotError('setpassword foo bar baz') self.assertNotEqual(ircdb.users.getUser(self.prefix).password, 'baz')
self.assertEqual(ircdb.users.getUser(self.prefix).password, 'baz')
self.assertNotError('setpassword --hashed foo baz biff')
self.assertNotEqual(ircdb.users.getUser(self.prefix).password,
'biff')
finally:
conf.supybot.databases.users.hash.setValue(orig)
def testStats(self): def testStats(self):
self.assertNotError('user stats') self.assertNotError('user stats')