From f4f0a8e90319d3acee60f2ff6c346e50a5ef2ccd Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Wed, 29 Jun 2011 12:55:31 +0100 Subject: [PATCH] sh -ec is only appropriate for /etc/default/grub, not /etc/grub.d/* --- debian/apport/source_grub2.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/debian/apport/source_grub2.py b/debian/apport/source_grub2.py index 0bfc85a8e..a6c5ac477 100644 --- a/debian/apport/source_grub2.py +++ b/debian/apport/source_grub2.py @@ -14,6 +14,15 @@ import subprocess import re def check_shell_syntax(path): + ''' Check the syntax of a shell script ''' + try: + subprocess.check_call(['/bin/sh', '-n', path], + stderr=open(os.devnull,'w')) + except subprocess.CalledProcessError: + return False + return True + +def check_shell_syntax_harder(path): ''' Check the syntax of a shell script ''' try: # sh -n is tempting, but not good enough. Consider this case: @@ -57,7 +66,7 @@ def add_info(report): attach_file_if_exists(report, '/boot/grub/device.map', 'DeviceMap') invalid_grub_script = [] - if not check_shell_syntax('/etc/default/grub'): + if not check_shell_syntax_harder('/etc/default/grub'): invalid_grub_script.append('/etc/default/grub') # Check scripts in /etc/grub.d since some users directly change