Opened 17 years ago

Last modified 16 years ago

#63 closed enhancement

support htpasswd with Windows and Python 2.3 — at Version 2

Reported by: sid|at|seegrid.com Owned by: Matt Good
Priority: high Component: AccountManagerPlugin
Severity: normal Keywords:
Cc: Matt Good Trac Release: 0.10

Description (last modified by Alec Thomas)

Change password fails on Windows if running Python 2.3:

Traceback (most recent call last):
  File "C:\Python23\Lib\site-packages\trac\web\modpython_frontend.py", line 205, in handler
    dispatch_request(mpr.path_info, mpr, env)
  File "C:\Python23\Lib\site-packages\trac\web\main.py", line 139, in dispatch_request
    dispatcher.dispatch(req)
  File "C:\Python23\Lib\site-packages\trac\web\main.py", line 107, in dispatch
    resp = chosen_handler.process_request(req)
  File "build\bdist.win32\egg\acct_mgr\web_ui.py", line 48, in process_request
  File "build\bdist.win32\egg\acct_mgr\web_ui.py", line 64, in _do_change_password
  File "build\bdist.win32\egg\acct_mgr\htfile.py", line 49, in set_password
  File "build\bdist.win32\egg\acct_mgr\htfile.py", line 102, in userline
  File "build\bdist.win32\egg\acct_mgr\htfile.py", line 75, in salt
  File "build\bdist.win32\egg\acct_mgr\htfile.py", line 30, in urandom
IOError: [Errno 2] No such file or directory: '/dev/urandom'

I saw another site hinted at using windrandom.pyd file for Windows for Python 2.3 (although it is deprecated in 2.4 in favor of os.urandom).

Change History (2)

comment:1 Changed 17 years ago by Matt Good

Status: newassigned
Summary: Change password fails on Windows with Python 2.3support htpasswd with Windows and Python 2.3
Type: defectenhancement

Ok, I didn't find a reasonable way to generate cryptographically sound random data on Windows with Python 2.3, but that winrandom module may work. Can you try it with the following patch:

  • acct_mgr/htfile.py

     
    2626try:
    2727    from os import urandom
    2828except ImportError:
    29     def urandom(n):
    30         return open('/dev/urandom').read(n)
     29    try:
     30        from winrandom import winrandom as urandom
     31    except ImportError:
     32        def urandom(n):
     33            return open('/dev/urandom').read(n)
    3134
    3235
    3336class AbstractPasswordFileStore(Component):

Also, note that htdigest does not require random data so it could be used instead of htpasswd.

comment:2 Changed 17 years ago by Alec Thomas

Description: modified (diff)
Note: See TracTickets for help on using tickets.