From: Daan De Meyer Date: Wed, 9 Aug 2023 07:53:07 +0000 (+0200) Subject: Set GPGTTY when calling gpg X-Git-Tag: v15~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c77c8d13f78bd00209733e1ea7a3380bb26954f7;p=thirdparty%2Fmkosi.git Set GPGTTY when calling gpg Fixes #351 --- diff --git a/mkosi/__init__.py b/mkosi/__init__.py index 4f2c56b40..98e10e4d8 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -859,20 +859,18 @@ def calculate_signature(state: MkosiState) -> None: state.staging / state.config.output_checksum, ] + # Set the path of the keyring to use based on the environment if possible and fallback to the default + # path. Without this the keyring for the root user will instead be used which will fail for a + # non-root build. + env = dict(GNUPGHOME=os.environ.get("GNUPGHOME", os.fspath(((Path(os.environ["HOME"]) / ".gnupg"))))) + if sys.stderr.isatty(): + env |= dict(GPGTTY=os.ttyname(sys.stderr.fileno())) + run( cmdline, # Do not output warnings about keyring permissions stderr=subprocess.DEVNULL, - env={ - # Set the path of the keyring to use based on the environment - # if possible and fallback to the default path. Without this the - # keyring for the root user will instead be used which will fail - # for a non-root build. - "GNUPGHOME": os.environ.get( - "GNUPGHOME", - os.fspath(((Path(os.environ["HOME"]) / ".gnupg"))), - ) - }, + env=env, )