mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-30 23:57:20 -05:00
fix: confirm the backup holder after writing
Between the check and the creation of the run folder, retrobios-backup could be swapped for a link. The holder's device and inode are confirmed unchanged once the run folder exists. Directory file descriptors would close the window entirely but do not exist on Windows; the remaining window is the instant between that confirmation and the move.
This commit is contained in:
1 parent
a2b98af88e
commit
3164a815bc
4 files changed
+34
-7
No files matched your search
@@ -5233,6 +5233,18 @@ class AFileYouHadIsKept(unittest.TestCase):
|
||||
self.assertEqual(len(inside), 1)
|
||||
self.assertEqual((inside[0] / "x.bin").read_bytes(), self.OLD)
|
||||
|
||||
def test_a_holder_swapped_after_the_check_is_noticed(self):
|
||||
holder = self.home / install.BACKUP_DIR
|
||||
holder.mkdir()
|
||||
checked = install._check_holder(holder)
|
||||
self.assertTrue(install._same_folder(holder, checked))
|
||||
holder.rename(self.home / "moved")
|
||||
(self.home / "elsewhere").mkdir()
|
||||
holder.symlink_to(self.home / "elsewhere")
|
||||
self.assertFalse(install._same_folder(holder, checked))
|
||||
with self.assertRaises(OSError):
|
||||
install._check_holder(holder)
|
||||
|
||||
@unittest.skipUnless(hasattr(os, "getuid"), "user ids are POSIX")
|
||||
def test_a_holder_another_user_owns_is_refused(self):
|
||||
(self.home / install.BACKUP_DIR).mkdir()
|
||||
|
||||
Reference in new issue
Block a user