summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorTom Powell <zifnab@zifnab06.net>2017-01-20 20:47:49 -0800
committerZhao Wei Liew <zhaoweiliew@gmail.com>2017-01-23 11:06:28 +0800
commitce54189f4551fda90f95d6a015bd0b897c9c73a3 (patch)
treeba9d859ddc7a6a07c714076844b22fe4cf603544 /tools
parent918ca7f98412ec2e79ac0119327db2cf7120db2b (diff)
downloadbuild-ce54189f4551fda90f95d6a015bd0b897c9c73a3.zip
build-ce54189f4551fda90f95d6a015bd0b897c9c73a3.tar.gz
build-ce54189f4551fda90f95d6a015bd0b897c9c73a3.tar.bz2
releasetools: support reading release keys out of some sort of command
key passphrases may live in some sort of secure storage, support running an arbitrary command to retrieve them. Change-Id: I49862cf60f1b73a2356e0c492e1038beef28a95f
Diffstat (limited to 'tools')
-rw-r--r--tools/releasetools/common.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py
index 32bbc68..ea7312a 100644
--- a/tools/releasetools/common.py
+++ b/tools/releasetools/common.py
@@ -863,6 +863,7 @@ class PasswordManager(object):
def __init__(self):
self.editor = os.getenv("EDITOR", None)
self.pwfile = os.getenv("ANDROID_PW_FILE", None)
+ self.secure_storage_cmd = os.getenv("ANDROID_SECURE_STORAGE_CMD", None)
def GetPasswords(self, items):
"""Get passwords corresponding to each string in 'items',
@@ -882,9 +883,23 @@ class PasswordManager(object):
missing = []
for i in items:
if i not in current or not current[i]:
- missing.append(i)
+ #Attempt to load using ANDROID_SECURE_STORAGE_CMD
+ if self.secure_storage_cmd:
+ try:
+ os.environ["TMP__KEY_FILE_NAME"] = str(i)
+ ps = subprocess.Popen(self.secure_storage_cmd, shell=True, stdout=subprocess.PIPE)
+ output = ps.communicate()[0]
+ if ps.returncode == 0:
+ current[i] = output
+ except Exception as e:
+ print(e)
+ pass
+ if i not in current or not current[i]:
+ missing.append(i)
# Are all the passwords already in the file?
if not missing:
+ if "ANDROID_SECURE_STORAGE_CMD" in os.environ:
+ del os.environ["ANDROID_SECURE_STORAGE_CMD"]
return current
for i in missing: