Skip to content

Commit

Permalink
fstab: improved password detection and fixed parsing error
Browse files Browse the repository at this point in the history
E.g. mount.cifs can use pass= instead of password= and
cred= can alternatively be used to specify a credential file.

Continue on empty lines because the line.split() call resulted in
ValueError: not enough values to unpack (expected 6, got 0)
  • Loading branch information
exploide committed Aug 6, 2023
1 parent 8c9f962 commit 16000b9
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Linux/lazagne/softwares/sysadmin/fstab.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ def run(self):
try:
with open(path) as fstab:
for line in fstab:
if line.startswith('#'):
line = line.strip()
if not line or line.startswith('#'):
continue

filesystem, mount_point, _type, options, dump, _pass = line.strip().split()
if 'password' in options:
filesystem, mount_point, _type, options, dump, _pass = line.split()
if 'pass' in options or 'cred' in options:
pwd_found.append({
'Filesystem': filesystem,
'Mount Point': mount_point,
Expand Down

0 comments on commit 16000b9

Please sign in to comment.