Skip to content

Commit

Permalink
#1645: use getpass for command line mode
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@16940 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Sep 21, 2017
1 parent 6ddf953 commit 4fa208c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
17 changes: 17 additions & 0 deletions src/xpra/client/client_base.py
Expand Up @@ -554,8 +554,25 @@ def _process_connection_lost(self, _packet):
def _process_challenge(self, packet):
authlog("processing challenge: %s", packet[1:])
password = self.load_password()
if not password:
try:
if sys.stdin.isatty():
import getpass
password = getpass.getpass("%s :" % self.get_challenge_prompt())
except Exception:
authlog("password request failure", exc_info=True)
self.send_challenge_reply(packet, password)

def get_challenge_prompt(self):
text = "Please enter the password"
try:
from xpra.net.bytestreams import pretty_socket
conn = self._protocol._conn
text += " for %s server %s" % (conn.socktype, pretty_socket(conn.remote))
except:
pass
return text

def send_challenge_reply(self, packet, password):
def warn_server_and_exit(code, message, server_message="authentication failed"):
authlog.error("Error: authentication failed:")
Expand Down
9 changes: 1 addition & 8 deletions src/xpra/client/gtk_base/gtk_client_base.py
Expand Up @@ -191,14 +191,7 @@ def handle_response(dialog, response):
title = gtk.Label("Server Authentication")
title.modify_font(pango.FontDescription("sans 14"))
add(title, 16)
text = "Please enter the password"
try:
from xpra.net.bytestreams import pretty_socket
conn = self._protocol._conn
text += " for %s server %s" % (conn.socktype, pretty_socket(conn.remote))
except:
pass
add(gtk.Label(text), 10)
add(gtk.Label(self.get_challenge_prompt()), 10)
def password_activate(*_args):
handle_response(dialog, gtk.RESPONSE_ACCEPT)
password_input = gtk.Entry(max=255)
Expand Down

0 comments on commit 4fa208c

Please sign in to comment.