]> glassweightruler.freedombox.rocks Git - waydroid.git/blobdiff - tools/services/hardware_manager.py
hardware_manager: Prevent race-condition in upgrade check
[waydroid.git] / tools / services / hardware_manager.py
index b9cff466879779f1ddbd41bc71ca0264e9e2d768..9175022f02f66d97508eedc6634a1ee122c96ca1 100644 (file)
@@ -30,12 +30,18 @@ def start(args):
         helpers.lxc.start(args)
 
     def upgrade(system_zip, system_time, vendor_zip, vendor_time):
-        if os.path.exists(system_zip) and not helpers.images.validate(args, "system_ota", system_zip):
-            logging.warning("Not upgrading because system.img comes from an unverified source")
-            return
-        if os.path.exists(vendor_zip) and not helpers.images.validate(args, "vendor_ota", vendor_zip):
-            logging.warning("Not upgrading because vendor.img comes from an unverified source")
-            return
+        if os.path.exists(system_zip):
+            if not helpers.images.validate(args, "system_ota", system_zip):
+                logging.warning("Not upgrading because system.img comes from an unverified source")
+                return
+        else:
+            system_zip = "" # Race prevention
+        if os.path.exists(vendor_zip):
+            if not helpers.images.validate(args, "vendor_ota", vendor_zip):
+                logging.warning("Not upgrading because vendor.img comes from an unverified source")
+                return
+        else:
+            vendor_zip = "" # Race prevention
         helpers.lxc.stop(args)
         helpers.images.umount_rootfs(args)
         helpers.images.replace(args, system_zip, system_time,