Edgewall Software

Ticket #7458: trac-0.11-hashlib.2.patch

File trac-0.11-hashlib.2.patch, 5.2 KB (added by mad, 6 months ago)

Updated version with sha module replacement and fixed login href

  • contrib/htdigest.py

    diff -Nurp Trac-0.11.orig/contrib/htdigest.py Trac-0.11/contrib/htdigest.py
    old new  
    1717 
    1818import errno 
    1919import fileinput 
    20 import md5 
     20import hashlib 
    2121import sys 
    2222from optparse import OptionParser 
    2323from getpass import getpass 
     
    3636    return make_digest(userprefix, password) 
    3737 
    3838def make_digest(userprefix, password): 
    39     return userprefix + md5.new(userprefix + password).hexdigest() 
     39    return userprefix + hashlib.md5(userprefix + password).hexdigest() 
    4040 
    4141usage = "%prog [-c] [-b] passwordfile realm username" 
    4242parser = OptionParser(usage=usage) 
  • trac/ticket/notification.py

    diff -Nurp Trac-0.11.orig/trac/ticket/notification.py Trac-0.11/trac/ticket/notification.py
    old new  
    1616# Author: Daniel Lundin <daniel@edgewall.com> 
    1717# 
    1818 
    19 import md5 
     19import hashlib 
    2020 
    2121from trac import __version__ 
    2222from trac.core import * 
     
    284284        s = '%s.%08d.%d.%s' % (self.config.get('project', 'url'), 
    285285                               int(self.ticket.id), to_timestamp(modtime), 
    286286                               rcpt.encode('ascii', 'ignore')) 
    287         dig = md5.new(s).hexdigest() 
     287        dig = hashlib.md5(s).hexdigest() 
    288288        host = self.from_email[self.from_email.find('@') + 1:] 
    289289        msgid = '<%03d.%s@%s>' % (len(s), dig, host) 
    290290        return msgid 
  • trac/util/__init__.py

    diff -Nurp Trac-0.11.orig/trac/util/__init__.py Trac-0.11/trac/util/__init__.py
    old new  
    1818#         Matthew Good <trac@matt-good.net> 
    1919 
    2020import locale 
    21 import md5 
     21import hashlib 
    2222import os 
    2323import re 
    2424import sys 
     
    255255# -- crypto utils 
    256256 
    257257def hex_entropy(bytes=32): 
    258     import sha 
    259258    import random 
    260     return sha.new(str(random.random())).hexdigest()[:bytes] 
     259    return hashlib.sha1(str(random.random())).hexdigest()[:bytes] 
    261260 
    262261 
    263262# Original license for md5crypt: 
     
    271270    # /* The password first, since that is what is most unknown */ 
    272271    # /* Then our magic string */ 
    273272    # /* Then the raw salt */ 
    274     m = md5.new() 
     273    m = hashlib.md5() 
    275274    m.update(password + magic + salt) 
    276275 
    277276    # /* Then just as many characters of the MD5(pw,salt,pw) */ 
    278     mixin = md5.md5(password + salt + password).digest() 
     277    mixin = hashlib.md5(password + salt + password).digest() 
    279278    for i in range(0, len(password)): 
    280279        m.update(mixin[i % 16]) 
    281280 
     
    293292 
    294293    # /* and now, just to make sure things don't run too fast */ 
    295294    for i in range(1000): 
    296         m2 = md5.md5() 
     295        m2 = hashlib.md5() 
    297296        if i & 1: 
    298297            m2.update(password) 
    299298        else: 
  • trac/web/api.py

    diff -Nurp Trac-0.11.orig/trac/web/api.py Trac-0.11/trac/web/api.py
    old new  
    243243        so that consecutive requests can be cached. 
    244244        """ 
    245245        if isinstance(extra, list): 
    246             import md5 
    247             m = md5.new() 
     246            import hashlib 
     247            m = hashlib.md5() 
    248248            for elt in extra: 
    249249                m.update(repr(elt)) 
    250250            extra = m.hexdigest() 
  • trac/web/auth.py

    diff -Nurp Trac-0.11.orig/trac/web/auth.py Trac-0.11/trac/web/auth.py
    old new  
    2222    import threading 
    2323except ImportError: 
    2424    import dummy_threading as threading 
    25 import md5 
     25import hashlib 
    2626import os 
    2727import re 
    2828import sys 
     
    367367            self.send_auth_request(environ, start_response) 
    368368            return None 
    369369 
    370         kd = lambda x: md5.md5(':'.join(x)).hexdigest() 
     370        kd = lambda x: hashlib.md5(':'.join(x)).hexdigest() 
    371371        a1 = self.hash[auth['username']] 
    372372        a2 = kd([environ['REQUEST_METHOD'], auth['uri']]) 
    373373        # Is the response correct? 
  • trac/wiki/default-pages/TracStandalone

    diff -Nurp Trac-0.11.orig/trac/wiki/default-pages/TracStandalone Trac-0.11/trac/wiki/default-pages/TracStandalone
    old new  
    111111{{{ 
    112112#!python 
    113113from optparse import OptionParser 
    114 import md5 
     114import hashlib 
    115115 
    116116# build the options 
    117117usage = "usage: %prog [options]" 
     
    128128    
    129129# Generate the string to enter into the htdigest file 
    130130realm = 'trac' 
    131 kd = lambda x: md5.md5(':'.join(x)).hexdigest() 
     131kd = lambda x: hashlib.md5(':'.join(x)).hexdigest() 
    132132print ':'.join((options.username, realm, kd([options.username, realm, options.password]))) 
    133133}}} 
    134134