Open ab_partitions.txt with just read access
We don't actually need write permission, so going with least privilege
principle. We have observed some mysterious permission denied errors on server environments. Without detailed logs or access to the server it's hard to pinpoint what the root cause is. This is an attempt/hypothesis to fix the permission denied error.
Test: th
Bug: 283033491
Change-Id: I52dc360d593aab57c749109994bf3e1e3625d0ce
diff --git a/tools/releasetools/ota_utils.py b/tools/releasetools/ota_utils.py
index fa9516e..63a863e 100644
--- a/tools/releasetools/ota_utils.py
+++ b/tools/releasetools/ota_utils.py
@@ -817,8 +817,8 @@
target_dir = ExtractTargetFiles(target_file)
cmd = ["delta_generator",
"--out_file", payload_file]
- with open(os.path.join(target_dir, "META", "ab_partitions.txt")) as fp:
- ab_partitions = fp.read().strip().split("\n")
+ with open(os.path.join(target_dir, "META", "ab_partitions.txt"), "r") as fp:
+ ab_partitions = fp.read().strip().splitlines()
cmd.extend(["--partition_names", ":".join(ab_partitions)])
cmd.extend(
["--new_partitions", GetPartitionImages(target_dir, ab_partitions, False)])