Mercurial > hg
comparison mercurial/ui.py @ 21195:9336bc7dca8e stable
cmdserver: forcibly use L channel to read password input (issue3161)
Command server is designed to use the channel protocol even if the server
process is accessible to tty, whereas vanilla hg should be able to read
password from tty in that case. So it isn't enough to swap sys.stdin:
# works only if the server process is detached from the console
sys.stdin = self.fin
getpass.getpass('')
sys.stdin = oldin
or test isatty:
# vanilla hg can't talk to tty if stdin is redirected
if self._isatty(self.fin):
return getpass.getpass('')
else:
...
Since ui.nontty flag is undocumented and command-server channels don't provide
isatty(), this change won't affect the other uses of ui._isatty().
issue3161 also suggests to provide some context of messages. I think it can
be implemented by using the generic templating function.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 26 Apr 2014 18:13:06 +0900 |
parents | 350dc24a553d |
children | 6dfb78f18bdb |
comparison
equal
deleted
inserted
replaced
21194:476069509e72 | 21195:9336bc7dca8e |
---|---|
687 def getpass(self, prompt=None, default=None): | 687 def getpass(self, prompt=None, default=None): |
688 if not self.interactive(): | 688 if not self.interactive(): |
689 return default | 689 return default |
690 try: | 690 try: |
691 self.write_err(self.label(prompt or _('password: '), 'ui.prompt')) | 691 self.write_err(self.label(prompt or _('password: '), 'ui.prompt')) |
692 return getpass.getpass('') | 692 # disable getpass() only if explicitly specified. it's still valid |
693 # to interact with tty even if fin is not a tty. | |
694 if self.configbool('ui', 'nontty'): | |
695 return self.fin.readline().rstrip('\n') | |
696 else: | |
697 return getpass.getpass('') | |
693 except EOFError: | 698 except EOFError: |
694 raise util.Abort(_('response expected')) | 699 raise util.Abort(_('response expected')) |
695 def status(self, *msg, **opts): | 700 def status(self, *msg, **opts): |
696 '''write status message to output (if ui.quiet is False) | 701 '''write status message to output (if ui.quiet is False) |
697 | 702 |