From 89b87f6aa902c05fafbd657444d9f71886423678 Mon Sep 17 00:00:00 2001 From: Kelvin Zhang Date: Thu, 1 Jun 2023 10:23:05 -0700 Subject: [PATCH] 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 --- tools/releasetools/ota_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/releasetools/ota_utils.py b/tools/releasetools/ota_utils.py index fa9516edcb..63a863e95c 100644 --- a/tools/releasetools/ota_utils.py +++ b/tools/releasetools/ota_utils.py @@ -817,8 +817,8 @@ class PayloadGenerator(object): 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)])