mirror of
https://github.com/sshuttle/sshuttle.git
synced 2025-04-23 02:38:30 +02:00
ui-macos: Actually prompt for passwords instead of assuming a default.
This commit is contained in:
parent
342ce12840
commit
da7a490cd7
33
ui-macos/askpass.py
Executable file → Normal file
33
ui-macos/askpass.py
Executable file → Normal file
@ -1,13 +1,12 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
import sys, os, re, subprocess
|
import sys, os, re, subprocess
|
||||||
|
|
||||||
prompt = ' '.join(sys.argv[1:2]).replace('"', "'")
|
def askpass(prompt):
|
||||||
|
prompt = prompt.replace('"', "'")
|
||||||
|
|
||||||
if 'yes/no' in prompt:
|
if 'yes/no' in prompt:
|
||||||
print "yes"
|
return "yes"
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
script="""
|
script="""
|
||||||
tell application "Finder"
|
tell application "Finder"
|
||||||
activate
|
activate
|
||||||
display dialog "%s" \
|
display dialog "%s" \
|
||||||
@ -16,16 +15,14 @@ script="""
|
|||||||
with icon caution \
|
with icon caution \
|
||||||
with hidden answer
|
with hidden answer
|
||||||
end tell
|
end tell
|
||||||
""" % prompt
|
""" % 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)
|
|
||||||
|
|
||||||
|
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)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import sys, os, pty
|
import sys, os, pty
|
||||||
from AppKit import *
|
from AppKit import *
|
||||||
import my, models
|
import my, models, askpass
|
||||||
|
|
||||||
def sshuttle_args(host, auto_nets, auto_hosts, nets, debug):
|
def sshuttle_args(host, auto_nets, auto_hosts, nets, debug):
|
||||||
argv = [my.bundle_path('sshuttle/sshuttle', ''), '-r', host]
|
argv = [my.bundle_path('sshuttle/sshuttle', ''), '-r', host]
|
||||||
@ -147,7 +147,7 @@ class SshuttleController(NSObject):
|
|||||||
self.logField.didChangeText()
|
self.logField.didChangeText()
|
||||||
def promptfunc(prompt):
|
def promptfunc(prompt):
|
||||||
print 'prompt! %r' % prompt
|
print 'prompt! %r' % prompt
|
||||||
return 'scss'
|
return askpass.askpass(prompt)
|
||||||
nets_mode = server.autoNets()
|
nets_mode = server.autoNets()
|
||||||
if nets_mode == models.NET_MANUAL:
|
if nets_mode == models.NET_MANUAL:
|
||||||
manual_nets = ["%s/%d" % (i.subnet(), i.width())
|
manual_nets = ["%s/%d" % (i.subnet(), i.width())
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
clear
|
|
||||||
printf "[local sudo] "
|
|
||||||
sudo true
|
|
Loading…
Reference in New Issue
Block a user