Opened 6 years ago

Closed 11 months ago

Last modified 11 months ago

#9623 closed defect (fixed)

IOError: (22, "invalid mode ('r') or filename")

Reported by: admin Owned by: jomae
Priority: low Component: AccountManagerPlugin
Severity: normal Keywords: needinfo IOError
Cc: Trac Release: 0.11


How to Reproduce

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

(please provide additional details here)

Request parameters:

{'__FORM_TOKEN': u'7097c8ea2f72cafa1fb30eea',
 'add': u' Add ',
 'cat_id': u'accounts',
 'email': u'',
 'name': u'vipin',
 'panel_id': u'users',
 'password': u'vipin123',
 'password_confirm': u'vipin123',
 'path_info': None,
 'username': u'vipin'}

User agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.2 Safari/535.11

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.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit (Intel)]
setuptools 0.6c11
SQLite 3.6.2
Subversion 1.6.15 (r1038135)
jQuery 1.4.2

Enabled Plugins

tracaccountmanager 0.3.2

Python Traceback

Traceback (most recent call last):
  File "build\bdist.win32\egg\trac\web\", line 511, in _dispatch_request
  File "build\bdist.win32\egg\trac\web\", line 237, in dispatch
    resp = chosen_handler.process_request(req)
  File "build\bdist.win32\egg\trac\admin\", line 116, in process_request
  File "build\bdist.win32\egg\acct_mgr\", line 137, in render_admin_panel
    return self._do_users(req)
  File "build\bdist.win32\egg\acct_mgr\", line 240, in _do_users
    _create_user(req, env, check_permissions=False)
  File "build\bdist.win32\egg\acct_mgr\", line 148, in _create_user
    acctmgr.set_password(username, password)
  File "build\bdist.win32\egg\acct_mgr\", line 292, in set_password
    if store.set_password(user, password, old_password):
  File "build\bdist.win32\egg\acct_mgr\", line 56, in set_password
    self.userline(user, password))
  File "build\bdist.win32\egg\acct_mgr\", line 106, in _update_file
    f = open(filename, 'r')
IOError: [Errno 22] invalid mode ('r') or filename: ''

Attachments (0)

Change History (19)

comment:1 Changed 6 years ago by Ryan J Ollos

Component: SELECT A HACKAccountManagerPlugin
Owner: changed from anonymous to Steffen Hoffmann

comment:2 Changed 6 years ago by Steffen Hoffmann

Keywords: needinfo added

The plugin is working fine in production elsewhere, so this seems like a local installation/configuration issue rather than a software bug, and only the last one would belong here.

Basically you may not have the required file specified for your authentication store, so the error tells ... or filename: ''. Mode 'r' can't be invalid, if the file exists.

General advise: Please use the th-users mailing-list first, and even before that see wiki:CookBook/AccountManagerPluginConfiguration or the appropriate section in wiki:AccountManagerPlugin/AuthStores for more details on available options for your authentication store. I've done rather extensive updates lately to ensure it's holding most relevant information.

Don't dare to ask for more without a single line of your configuration (trac.ini). How should we answer, if you just copy the error, but don't tell us anything about your setup?

comment:3 Changed 6 years ago by Steffen Hoffmann

Keywords: IOError added
Priority: normallow

I step this down to show my depreciation about lack of ongoing communication on this issue. Dropping something into a bug tracker and neither leaving contact information nor returning to the issue to respond on comments and updates, this suggests a lack of sense for responsibility and respect to all persons caring for the code.

Prove me wrong, would still appreciate your response with more configuration details. If this has been resolved, a note on the solution would be great too, so that someone looking for help in a similar case could pick it up here.

comment:4 Changed 5 years ago by anonymous

it doesn't accept PATH using spaces, a common python error.

comment:5 in reply to:  4 Changed 5 years ago by Steffen Hoffmann

Keywords: needinfo removed

Replying to anonymous:

it doesn't accept PATH using spaces, a common python error.

This would explain the error indeed. Thanks for the pointer. OTOH I question, who in his/her right mind would want a path with spaces. I call it a common Windows OS failure to educate/encourage users to sacrifice easy things without benefit.

Anyway, could someone suggest a fix too? I'd even care for silly system architecture, but must rely on independent testers to encourage me to do so.

comment:6 Changed 5 years ago by Ryan J Ollos

#9967 closed as a duplicate.

comment:7 Changed 5 years ago by anonymous

I had this problem for a different reason. I was using htdigest_file instead of password_file, the documentation about (acct_mgr >= 0.4) to use htdigest_file was confusing. I thought I have downloaded AccountManagerPlugin for 0.11, which is >0.4. Wasted an hour to find out they refer to totally different thing!

Hope that helps somebody else.

comment:8 in reply to:  4 Changed 5 years ago by Steffen Hoffmann

Replying to anonymous:

it doesn't accept PATH using spaces, a common python error.

Great to know, but what is the common cure to this common mistake then? Enlighten me, please.

comment:9 Changed 5 years ago by Steffen Hoffmann

Keywords: needinfo added

Since it could likely resolved by using paths without white-space, this issue has not much importance.

And in the absence of suggestions for a fix this might even become a wont-fix.

comment:10 Changed 5 years ago by Ryan J Ollos

#10643 reports a similar issue.

comment:11 Changed 5 years ago by Ryan J Ollos

Please post the [account-manager] and [components] sections of trac.ini if you wish for us to help with further diagnosis. As comment:7 noted and as we've found in #10643, the reporter's issue is most likely due to using AccountManager 0.4.0 and later configuration options with AccountManager 0.3.2.

Based on findings in #10643, I don't think this issue is caused by whitespace in the path, but rather using htpasswd_file or htdigest_file options with AccountManager 0.3.2. With AccountManager 0.3.2, the password_file option needs to be specified . However, please don't use that as a fix, but rather just go ahead with the upgrade to 0.4.2.

comment:12 Changed 5 years ago by Ryan J Ollos

If you follow #10643 at all, you'll see that we have a resolution of worksforme, and the issue was as suggested in comment:11. I'll leave it to the discretion of hasienda, but suggest that we close this ticket with release 0.5 of AccountManagerPlugin, if no reply is heard from the original reporter.

comment:13 Changed 4 years ago by anonymous

I faced the exact same issue while upgrading the account manager plugin from v3 to v4. After some searching found that a key parameter name has changed in v4 (password_file to htpasswd_file).

If the v4 egg file is deployed, without updating the trac.ini entries, this error occurs, as the value for the new key name is not defined. Once i put a new entry for htpasswd_file, all was well.

Hope this helps.

comment:14 Changed 17 months ago by Jun Omae

#12692 was closed as duplicate.

comment:15 Changed 11 months ago by Jun Omae

#12848 was closed as duplicate.

The same issue is frequently reported to AccountManagerPlugin. I think we should raise a TracError rather than an IOError/OSError when the option is not configured:

  • accountmanagerplugin/trunk/acct_mgr/

    diff --git a/accountmanagerplugin/trunk/acct_mgr/ b/accountmanagerplugin/trunk/acct_mgr/
    index 79a48cd..1df3b62 100644
    a b class AbstractPasswordFileStore(Component): 
    8787        Returns `True` if a line matching `prefix` was updated,
    8888        `False` otherwise.
    8989        """
     90        if not self.filename:
     91            option = self.__class__.filename
     92            raise TracError(_("[%(section)s] %(name)s option for the password "
     93                              "file is not configured",
     94                              option.section,
    9095        f = None
    9196        filename = str(self.filename)
    9297        matched = False
Last edited 11 months ago by Jun Omae (previous) (diff)

comment:16 Changed 11 months ago by Ryan J Ollos

Owner: changed from Steffen Hoffmann to Ryan J Ollos
Status: newaccepted

comment:17 Changed 11 months ago by Ryan J Ollos

In 15719:

0.5dev: Show descriptive error message when password file not configured

Patch by Jun Omae.

Refs #9623.

comment:18 Changed 11 months ago by Ryan J Ollos

Resolution: fixed
Status: acceptedclosed

comment:19 Changed 11 months ago by Ryan J Ollos

Owner: changed from Ryan J Ollos to jomae

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain jomae.
The resolution will be deleted.

Add Comment

E-mail address and name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.