Skip to content

Commit

Permalink
Avoid infinite loop when mount point not started with "/"
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikhail Sandakov committed Dec 10, 2024
1 parent 120f4b4 commit 7153b92
Show file tree
Hide file tree
Showing 2 changed files with 10 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 @@ -32,7 +32,7 @@ def get_fstab_configuration_misorderings(configpath: str) -> typing.List[typing.

misorderings: typing.List[typing.Tuple[str, str]] = []
for mount_point in mount_points_order.keys():
if mount_point == "/":
if mount_point == "/" or not mount_point.startswith("/"):
continue

parent_dir: str = mount_point
Expand Down
9 changes: 9 additions & 0 deletions pleskdistup/common/tests/mountstests.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,12 @@ def test_file_without_root(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), [("/home", "/home/test")])

def test_mount_point_is_swap(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 swap swap defaults 0 1\n")
f.write("/dev/sda4 /home ext4 defaults 0 1\n")

self.assertEqual(mounts.get_fstab_configuration_misorderings(self.test_file_path), [])

0 comments on commit 7153b92

Please sign in to comment.