From 3440869a07c38d1a22868f0bb46d9e115de5ce56 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Fri, 23 Mar 2012 21:10:26 -0400 Subject: [PATCH] Fix ttyname override (better logging, look at GPG_TTY, not TTY_NAME). --- bin/pinentry.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/bin/pinentry.py b/bin/pinentry.py index 05780fe..1840fa2 100755 --- a/bin/pinentry.py +++ b/bin/pinentry.py @@ -115,8 +115,13 @@ class PinEntry (_server.AssuanServer): self.logger.debug('options:\n{}'.format(_pprint.pformat(self.options))) tty_name = None if self.override_ttyname: - tty_name = _os.getenv('TTY_NAME') - if not tty_name: # override not requested, or fall back on undefined + tty_name = _os.getenv('GPG_TTY') + if tty_name: + self.logger.debug('override ttyname with {}'.format(tty_name)) + else: + self.logger.debug( + 'GPG_TTY not set, fallback to ttyname option') + if not tty_name: tty_name = self.options.get('ttyname', None) if tty_name: self.connection['tpgrp'] = self._get_pgrp(tty_name) @@ -346,14 +351,13 @@ if __name__ == '__main__': args = parser.parse_args() - p = PinEntry() + p = PinEntry(override_ttyname=True) if args.verbose: p.logger.setLevel(max( logging.DEBUG, p.logger.level - 10*args.verbose)) try: - p = PinEntry(override_ttyname=True) p.run() except: p.logger.error( -- 2.26.2