Modify

Opened 5 years ago

Closed 5 years ago

#5660 closed defect (invalid)

"Trac Admins" setting in web view causes internal server error on POST

Reported by: ejucovy Owned by: k0s
Priority: normal Component: TracLegosScript
Severity: major Keywords:
Cc: Trac Release: 0.11

Description

I am using http://trac-hacks.org/svn/traclegosscript/anyrelease at r6367, but this problem existed at least as far back as r5341.

Reproduction:

  1. Start traclegos web frontend
  2. Visit /create-project
  3. Fill out all necessary fields
  4. Add user "egj" to the "Trac Admins" form field
  5. Submit the form

An internal server error results.

Traceback:

  File "/usr/local/arbezus/trac/lib/python2.5/site-packages/Paste-1.7.2-py2.5.egg/paste/urlmap.py", line 202, in __call__
    return app(environ, start_response)
  File "/usr/local/arbezus/trac/lib/python2.5/site-packages/Paste-1.7.2-py2.5.egg/paste/httpexceptions.py", line 636, in __call__
    return self.application(environ, start_response)
  File "/usr/local/arbezus/trac/src/traclegos/traclegos/web.py", line 387, in __call__
    step.transition(project_data, {})
  File "/usr/local/arbezus/trac/src/traclegos/traclegos/web.py", line 246, in transition
    subprocess.call(['trac-admin', project_dir, 'permission', 'add', admin, 'TRAC_ADMIN'])
  File "/usr/lib/python2.5/subprocess.py", line 444, in call
    return Popen(*popenargs, **kwargs).wait()
  File "/usr/lib/python2.5/subprocess.py", line 594, in __init__
    errread, errwrite)
  File "/usr/lib/python2.5/subprocess.py", line 1153, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

Attachments (0)

Change History (4)

comment:1 follow-up: Changed 5 years ago by ejucovy

It looks like the trac-admin permission add call might be happening too early -- before the project is actually created?

comment:2 in reply to: ↑ 1 Changed 5 years ago by k0s

Replying to ejucovy:

It looks like the trac-admin permission add call might be happening too early -- before the project is actually created?

No, it is done after:

        # create the project
        self.view.legos.create_project(project['vars']['project'],
                                       self.templates(project),
                                       project['vars'],
                                       database=project['database'],
                                       repository=project['repository'])

        project_dir = os.path.join(self.view.directory, project['vars']['project'])

        # write the logo_file to its new location
        logo_file = project['logo_file']
        if logo_file:
            logo_file_name = os.path.basename(project['vars']['logo'])
            filename = os.path.join(project_dir, 'htdocs', logo_file_name)
            logo = file(filename, 'wb')
            logo.write(logo_file.read())
            logo.close()
            
        # TODO: favicons from logo or alternate url

        # TODO: add authenticated user to TRAC_ADMIN of the new site
        # (and redirect to the admin panel?)
        # XXX hack for now
        for admin in project['admins']:
            subprocess.call(['trac-admin', project_dir, 'permission', 'add', admin, 'TRAC_ADMIN'])

comment:3 follow-up: Changed 5 years ago by k0s

The only way I can get this error is if trac-admin is not on my PATH. Is this the case for you? Then I get the OSError above. If there is any other failure with subprocess.call I get an IOError instead.

It is worth noting that (not this bug, but a good reason to avoid adding admins) is that if an account does not exist for the user specified (that is, you are using the AccountManagerPlugin, as in the oss_project case), you will not be able to log in as the specified user. There is no entry in the .htpasswd file for the user. However, the user "exists" in the Trac database, so the user won't be able to register. Big caveat.

comment:4 in reply to: ↑ 3 Changed 5 years ago by ejucovy

  • Resolution set to invalid
  • Status changed from new to closed

Replying to k0s:

The only way I can get this error is if trac-admin is not on my PATH. Is this the case for you? Then I get the OSError above. If there is any other failure with subprocess.call I get an IOError instead.

Aha, thanks for the tip. The bug was in my supervisord config, the virtualenv wasn't active somehow. Working now.

Add Comment

Modify Ticket

Action
as closed The owner will remain k0s.
The resolution will be deleted. Next status will be 'reopened'.
Author


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

 
Note: See TracTickets for help on using tickets.