Fix ttyname override (better logging, look at GPG_TTY, not TTY_NAME).
authorW. Trevor King <wking@drexel.edu>
Sat, 24 Mar 2012 01:10:26 +0000 (21:10 -0400)
committerW. Trevor King <wking@drexel.edu>
Sat, 24 Mar 2012 01:10:26 +0000 (21:10 -0400)
bin/pinentry.py

index 05780fe92972189c3ceac90980d491e6e6a4d849..1840fa29faa175e642b35cb58b01b04423d6276d 100755 (executable)
@@ -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(