Opened 6 years ago

Closed 6 years ago

# IndexError: list index out of range

Reported by: Owned by: godblessyou Steffen Hoffmann highest AccountManagerPlugin blocker login, htpasswd, auth 0.12

### Description

#### How to Reproduce

While doing a POST operation on /admin/accounts/users, Trac issued an internal error.

Request parameters:

{'__FORM_TOKEN': u'fff348fb504632cf87860733',
'cat_id': u'accounts',
'email': u'aa@aa.com',
'panel_id': u'users',
'path_info': None,


User agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 (.NET CLR 3.5.30729)

#### System Information

 Trac 0.12.2 Babel 0.9.5 Genshi 0.6 mod_wsgi 3.3 (WSGIProcessGroup WSGIApplicationGroup %{GLOBAL}) pysqlite 2.6.0 Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit (Intel)] setuptools 0.6c11 SQLite 3.6.21 Subversion 1.6.15 (r1038135) jQuery 1.4.2

#### Enabled Plugins

 tracaccountmanager 0.3dev-r9923

#### Python Traceback

Traceback (most recent call last):
File "C:\Python27\lib\site-packages\trac\web\main.py", line 511, in _dispatch_request
dispatcher.dispatch(req)
File "C:\Python27\lib\site-packages\trac\web\main.py", line 237, in dispatch
resp = chosen_handler.process_request(req)
File "C:\Python27\lib\site-packages\trac\admin\web_ui.py", line 116, in process_request
path_info)
return self._do_users(req)
File "build\bdist.win32\egg\acct_mgr\admin.py", line 211, in _do_users
_create_user(req, self.env, check_permissions=False)
File "build\bdist.win32\egg\acct_mgr\web_ui.py", line 145, in _create_user
File "build\bdist.win32\egg\acct_mgr\api.py", line 263, in set_password
File "build\bdist.win32\egg\acct_mgr\htfile.py", line 53, in set_password
File "build\bdist.win32\egg\acct_mgr\htfile.py", line 107, in _update_file
if lines[0].endswith('\r') and os.linesep == '\r':
IndexError: list index out of range


### comment:1 follow-up:  4 Changed 6 years ago by Steffen Hoffmann

This is related to the changes in [9923]. Did you start with an empty password file? Otherwise the there should be at least one line and lines[0] shouldn't fail. Or it is related to Python2.7, since this code had not been tested with Python > 2.6 before. Clearly this needs a fix anyway.

What OS do you run Trac on? What where your last actions before facing this error? I just see a create_user attempt from the users admin page, right?

Thanks for taking your time to report this. I'd really like to fix this soonish, if we could work out what happened.

### comment:2 Changed 6 years ago by Steffen Hoffmann

(In [9927]) AccountManagerPlugin: Handle empty password files without exception, refs #8563.

AccountManagerPlugin terminates each line, so there's no such thing like an empty file because at least one linebreak is always retained. But other application may not equally care for proper line endings. So I've moved the existing check for data read length up to prevent reading from a possibly empty list in case of a blank file. Checking EOL style not in first but in the last line is the other change, but certainly unrelated to the issue.

### comment:3 follow-up:  5 Changed 6 years ago by Steffen Hoffmann

Status: new → assigned

Would you give the last revision a try, please?

### comment:4 in reply to:  1 Changed 6 years ago by godblessyou

This is related to the changes in [9923]. Did you start with an empty password file? Otherwise the there should be at least one line and lines[0] shouldn't fail. Or it is related to Python2.7, since this code had not been tested with Python > 2.6 before. Clearly this needs a fix anyway.

Password file was an empty. I've added new blank line on password file. Solved. Thank you :)

It needs a fix.

What OS do you run Trac on? What where your last actions before facing this error? I just see a create_user attempt from the users admin page, right?

OS is Windows XP SP3.

Thanks for taking your time to report this. I'd really like to fix this soonish, if we could work out what happened.

### comment:5 in reply to:  3 Changed 6 years ago by godblessyou

Resolution: → fixed assigned → closed

Would you give the last revision a try, please?

I've upgraded from last revision.

Thank you. Solved :D

### Modify Ticket

Change Properties