Skip to content

Commit

Permalink
fixup! fixup! fixup! Add a preliminary checker to ensure the mount po…
Browse files Browse the repository at this point in the history
…ints in /etc/fstab are in the correct order
  • Loading branch information
Mikhail Sandakov committed Nov 26, 2024
1 parent 900507a commit 953f878
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pleskdistup/common/src/mounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def get_fstab_configuration_misorderings(configpath: str) -> typing.List[typing.
if mount_point == "/":
continue

if mount_points_order["/"] > mount_points_order[mount_point]:
if "/" in mount_points_order and mount_points_order["/"] > mount_points_order[mount_point]:
misorderings.append(("/", mount_point))

parant_dir = os.path.dirname(mount_point)
Expand Down
11 changes: 11 additions & 0 deletions pleskdistup/common/tests/mountstests.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,14 @@ def test_several_different_misorderings(self):
f.write("devpts /dev/pts devpts gid=5,mode=620 0 0\n")
f.write("tmpfs /dev/shm tmpfs defaults 0 0\n")
self.assertEqual(mounts.get_fstab_configuration_misorderings(self.test_file_path), [("/", "/var"), ("/home", "/home/test")])

def test_file_without_root(self):
with open(self.test_file_path, "w") as f:
f.write("# comment\n")
f.write("/dev/sda2 /var ext4 defaults 0 1\n")
f.write("/dev/sda5 /home/test ext4 defaults 0 1\n")
f.write("/dev/sda4 /home ext4 defaults 0 1\n")
f.write("proc /proc proc defaults 0 0\n")
f.write("devpts /dev/pts devpts gid=5,mode=620 0 0\n")
f.write("tmpfs /dev/shm tmpfs defaults 0 0\n")
self.assertEqual(mounts.get_fstab_configuration_misorderings(self.test_file_path), [("/home", "/home/test")])

0 comments on commit 953f878

Please sign in to comment.