Prevent redundant commenting by drive-audit
The drive-audit detects error log about a device and comments out it in /etc/fstab. When the error log is generated several times, it comments out the line for each time. This patch makes drive-audit to check if the device is already commented out, and prevents redundant commenting out. Change-Id: Ia542d35b58552dde0f324bb9c42531f98c9058fa
This commit is contained in:
parent
7def1d2921
commit
a270dca239
@ -126,7 +126,9 @@ def comment_fstab(mount_point):
|
||||
with open('/etc/fstab.new', 'w') as new_fstab:
|
||||
for line in fstab:
|
||||
parts = line.split()
|
||||
if len(parts) > 2 and line.split()[1] == mount_point:
|
||||
if len(parts) > 2 \
|
||||
and parts[1] == mount_point \
|
||||
and not line.startswith('#'):
|
||||
new_fstab.write('#' + line)
|
||||
else:
|
||||
new_fstab.write(line)
|
||||
|
Loading…
Reference in New Issue
Block a user