diff --git a/bin/Utils/CraftChoicePrompt.py b/bin/Utils/CraftChoicePrompt.py --- a/bin/Utils/CraftChoicePrompt.py +++ b/bin/Utils/CraftChoicePrompt.py @@ -33,6 +33,7 @@ import utils +import getpass from CraftCore import CraftCore @@ -75,6 +76,18 @@ CraftCore.log.debug(f"Returning: {out}") return out +def promptForPassword(message: str): + + utils.notify("Craft needs your attention", message, log=False) + + if CraftCore.settings.getboolean("ContinuousIntegration", "Enabled", True): + CraftCore.log.info(f"[ContinuousIntegration] Enabled = True: failing now.") + raise Exception("Password prompts for CI are not supported by Craft.") + + CraftCore.debug.new_line() + password = getpass.getpass(prompt=message+": ", stream=None) + CraftCore.log.debug(f"The user entered: {password}") + return password if __name__ == "__main__": print(promptForChoice("Test1, simple no default", ["Foo", "Bar"])) diff --git a/bin/utils.py b/bin/utils.py --- a/bin/utils.py +++ b/bin/utils.py @@ -48,6 +48,7 @@ from CraftOS.osutils import OsUtils from CraftSetupHelper import SetupHelper from CraftStandardDirs import CraftStandardDirs +from Utils import CraftChoicePrompt def abstract(): @@ -879,14 +880,19 @@ subjectName = CraftCore.settings.get("CodeSigning", "CommonName") command = [signTool, "sign", "/n", subjectName, "/tr", "http://timestamp.digicert.com", "/td", "SHA256", "/fd", "SHA256", "/a"] certFile = CraftCore.settings.get("CodeSigning", "Certificate", "") + certProtected = CraftCore.settings.getboolean("CodeSigning", "Protected", False) if certFile: command += ["/f", certFile] + if certProtected: + password = CraftChoicePrompt.promptForPassword(message='Enter the password for your package signing certificate') + command += ["/p", password] + kwargs = {'logCommand' : False} if True or CraftCore.debug.verbose() > 0: command += ["/v"] else: command += ["/q"] for args in limitCommandLineLength(command, fileNames): - if not system(args): + if not system(args, **kwargs): return False return True