diff options
author | Avery Pennarun <apenwarr@gmail.com> | 2011-01-18 20:05:22 -0800 |
---|---|---|
committer | Avery Pennarun <apenwarr@gmail.com> | 2011-01-22 16:44:11 -0800 |
commit | da7a490cd7ce98906c86cccc73cbffa4802669d5 (patch) | |
tree | a5d653388345cf4d726fb94bead65001d276a0ea | |
parent | 342ce128402b9e0dc155e76fa99a62267a279232 (diff) |
ui-macos: Actually prompt for passwords instead of assuming a default.
-rw-r--r--[-rwxr-xr-x] | ui-macos/askpass.py | 49 | ||||
-rw-r--r-- | ui-macos/main.py | 4 | ||||
-rwxr-xr-x | ui-macos/prime-sudo.sh | 4 |
3 files changed, 25 insertions, 32 deletions
diff --git a/ui-macos/askpass.py b/ui-macos/askpass.py index 55e98ee..9690c0d 100755..100644 --- a/ui-macos/askpass.py +++ b/ui-macos/askpass.py @@ -1,31 +1,28 @@ -#!/usr/bin/env python import sys, os, re, subprocess -prompt = ' '.join(sys.argv[1:2]).replace('"', "'") +def askpass(prompt): + prompt = prompt.replace('"', "'") -if 'yes/no' in prompt: - print "yes" - sys.exit(0) + if 'yes/no' in prompt: + return "yes" -script=""" - tell application "Finder" - activate - display dialog "%s" \ - with title "Sshuttle SSH Connection" \ - default answer "" \ - with icon caution \ - with hidden answer - end tell -""" % prompt - -p = subprocess.Popen(['osascript', '-e', script], stdout=subprocess.PIPE) -out = p.stdout.read() -rv = p.wait() -if rv: - # if they press the cancel button, it returns nonzero - sys.exit(1) -g = re.match("text returned:(.*), button returned:.*", out) -if not g: - sys.exit(2) -print g.group(1) + script=""" + tell application "Finder" + activate + display dialog "%s" \ + with title "Sshuttle SSH Connection" \ + default answer "" \ + with icon caution \ + with hidden answer + end tell + """ % prompt + p = subprocess.Popen(['osascript', '-e', script], stdout=subprocess.PIPE) + out = p.stdout.read() + rv = p.wait() + if rv: + return None + g = re.match("text returned:(.*), button returned:.*", out) + if not g: + return None + return g.group(1) diff --git a/ui-macos/main.py b/ui-macos/main.py index 3a9780d..baa290d 100644 --- a/ui-macos/main.py +++ b/ui-macos/main.py @@ -1,6 +1,6 @@ import sys, os, pty from AppKit import * -import my, models +import my, models, askpass def sshuttle_args(host, auto_nets, auto_hosts, nets, debug): argv = [my.bundle_path('sshuttle/sshuttle', ''), '-r', host] @@ -147,7 +147,7 @@ class SshuttleController(NSObject): self.logField.didChangeText() def promptfunc(prompt): print 'prompt! %r' % prompt - return 'scss' + return askpass.askpass(prompt) nets_mode = server.autoNets() if nets_mode == models.NET_MANUAL: manual_nets = ["%s/%d" % (i.subnet(), i.width()) diff --git a/ui-macos/prime-sudo.sh b/ui-macos/prime-sudo.sh deleted file mode 100755 index 3b6806b..0000000 --- a/ui-macos/prime-sudo.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -clear -printf "[local sudo] " -sudo true |