aboutsummaryrefslogtreecommitdiffstats
path: root/sos/plugins/grub.py
diff options
context:
space:
mode:
authorBryn M. Reeves <bmr@redhat.com>2014-06-02 15:27:10 +0100
committerBryn M. Reeves <bmr@redhat.com>2014-06-02 15:27:10 +0100
commit6501013bb780161e941f5e078a6ed7052f670a51 (patch)
treedcdb356c986e24d84f4dd6b5f8f1ea8d65e067f6 /sos/plugins/grub.py
parent23182c4f13fbadc9b7c2ab75c1ca249d5ba987d1 (diff)
downloadsos-6501013bb780161e941f5e078a6ed7052f670a51.tar.gz
Make sure grub password regex handles all cases
The regex to match passwords in grub.conf needs to handle both the --md5 and non-md5 cases and to apply the substitution only to the secret part (password or password hash). This needs to deal with the fact that python will return 'None' for unmatched pattern groups leading to an exception in re.subn() if not all referenced groups match for a given string (in contrast to e.g. the perl approach of treating these groups as the empty string). Make this explicit by using an empty alternate in the possibly unmatched '--md5' group: r"(password\s*)(--md5\s*|\s*)(.*)", r"\1\2********" Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
Diffstat (limited to 'sos/plugins/grub.py')
-rw-r--r--sos/plugins/grub.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/sos/plugins/grub.py b/sos/plugins/grub.py
index 33b9f7a8..926439f6 100644
--- a/sos/plugins/grub.py
+++ b/sos/plugins/grub.py
@@ -33,8 +33,8 @@ class Grub(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin):
def postproc(self):
self.do_path_regex_sub(
r".*\/grub.conf",
- r"(password)\s(--md5)\s(.*)",
- r"\1 \2 ********"
+ r"(password\s*)(--md5\s*|\s*)(.*)",
+ r"\1\2********"
)
# vim: et ts=4 sw=4