Yum-security plugin is not working with "Plugin security can't be imported" error

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux 5
  • Red Hat Enterprise Linux 6

Issue

  • yum commands which involve "yum-security" plugin like yum --security check-update are failing with:
# yum --security check-updates
Plugin "security" can't be imported
Loaded plugins: product-id, refresh-packagekit, subscription-manager
...skip...

Therefore, no tasks related to security updates can be completed.

Resolution

There can be several reasons for this error. Please, check each one step-by-step.

1. The plugin itself can be disabled in the plugin configuration.

Please, double-check that the security plugin is indeed enabled, the configuration file "/etc/yum/pluginconf.d/security.conf" should contain "enabled=1" in "[main]" section:

# cat /etc/yum/pluginconf.d/security.conf
[main]
enabled=1

2. One of the files which are the parts of 'yum' package can be modified or corrupted.

Please, reinstall "yum" and security plugin.

For RHEL 5:

# yum reinstall yum yum-security

For RHEL 6:

# yum reinstall yum yum-plugin-security

3. Yum cache can be corrupted on the server. Please clear yum cache.

# yum clean all

Please, double-check manually that "/var/cache/yum" directory is empty. If not, please, remove everything from it.

# rm -rf /var/cache/yum/*

Root Cause

1. The plugin itself is disabled in the plugin configuration.

2. One of the files with Python code belonging to "yum" package was incorrectly modified.
Namely, incorrect change of "/usr/lib/python2.*/site-packages/yum/update_md.py" file will lead to yum unable to import its security module.

3. Yum cache is corrupted on the server.

Diagnostic Steps

1. Check that the configuration file "/etc/yum/pluginconf.d/security.conf" contains "enabled=1" in "[main]" section.

2. Run RPM verification for "yum" package, the verification should reveal any modified files belonging to the package:

# rpm -V yum
S.5....T.    /usr/lib/python2.6/site-packages/yum/update_md.py
S.5....T.    /usr/lib/python2.6/site-packages/yum/update_md.pyc

3. Yum command returns an error similar to this one:

  File "/usr/lib/yum-plugins/security.py", line 76, in ysp_gen_metadata
    md_info.add(repo)
  File "/usr/lib/python2.4/site-packages/yum/update_md.py", line 376, in add
    for event, elem in(infile):
  File "<string>", line 64, in __iter__
SyntaxError: not well-formed (invalid token): line 421, column 55
  • Component
  • yum

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments