sh -ec is only appropriate for /etc/default/grub, not /etc/grub.d/*

This commit is contained in:
Colin Watson 2011-06-29 12:55:31 +01:00
parent a5cee8c7d7
commit f4f0a8e903

View File

@ -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