Edgewall Software

Opened 9 years ago

Last modified 7 years ago

#11846 closed enhancement

Prevent invalid file in Environment plugins directory from disabling Trac instance — at Version 5

Reported by: Ryan J Ollos Owned by:
Priority: normal Milestone: 1.2.3
Component: general Version:
Severity: normal Keywords: plugins
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description (last modified by Ryan J Ollos)

imp.load_source can raise a SystemExit exception when there is an invalid file in the Environment's plugins directory. A common scenario seems to be that the user will select setup.py with the plugin installation file picker on the Plugins admin panel.

The patch might be as simple as (needs more testing):

  • trac/loader.py

    diff --git a/trac/loader.py b/trac/loader.py
    index df65356..444e78d 100644
    a b def load_py_files():  
    8787                    env.log.debug('Loading file plugin %s from %s',
    8888                                  plugin_name, plugin_file)
    8989                    if plugin_name not in sys.modules:
    90                         module = imp.load_source(plugin_name, plugin_file)
     90                        try:
     91                            imp.load_source(plugin_name, plugin_file)
     92                        except SystemExit, e:
     93                            env.log.warn("Can't load file plugin %s: %s",
     94                                         plugin_file, exception_to_unicode(e))
    9195                    if path == auto_enable:
    9296                        _enable_plugin(env, plugin_name)
    9397                except Exception, e:

The issue has come up a few times recently:

Change History (5)

comment:1 by Ryan J Ollos, 9 years ago

Reporter: changed from anonymous to Ryan J Ollos

comment:2 by Ryan J Ollos, 9 years ago

Here's a relevant TODO tags/trac-1.0.2/trac/admin/web_ui.py@:500#L466. Validating the upload sounds like a good idea in addition to protecting against an invalid file in the environment plugins directory.

comment:3 by Ryan J Ollos, 9 years ago

Another report of this issue in SO:27905150.

comment:4 by Ryan J Ollos, 9 years ago

Milestone: next-stable-1.0.xnext-major-releases

comment:5 by Ryan J Ollos, 9 years ago

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