Skip to content

Commit

Permalink
#1240: use sshpass on all posix platforms (except centos..) so we can…
Browse files Browse the repository at this point in the history
… supply the password from the launcher dialog

git-svn-id: https://xpra.org/svn/Xpra/trunk@13201 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Aug 4, 2016
1 parent ff5fd86 commit 8e47497
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 9 deletions.
2 changes: 2 additions & 0 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ Recommends:
,websockify
# we cannot do versionned recommends but we need keyboard-configuration (>= 1.82)
,keyboard-configuration
#for using SSH passwords from the GUI launcher:
,sshpass
Suggests: openssh-server
# optional - only really useful with GPU opencl implementations:
,python-pyopencl
Expand Down
3 changes: 0 additions & 3 deletions osx/Helpers/SSH_ASKPASS

This file was deleted.

3 changes: 3 additions & 0 deletions osx/Xpra.bundle
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@
<binary dest="${bundle}/Contents/Helpers/gst-inspect-1.0">
${prefix}/bin/gst-inspect-1.0
</binary>
<binary dest="${bundle}/Contents/Helpers/sshpass">
${prefix}/bin/sshpass
</binary>

<data dest="${bundle}/Contents/Resources/">
${project}/dist/Xpra.app/Contents/Resources/
Expand Down
10 changes: 10 additions & 0 deletions osx/jhbuild/xpra.modules
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@
</branch>
</autotools>


<autotools id="sshpass" autogen-sh="configure">
<branch repo="sourceforge.net" module="/projects/sshpass/files/sshpass/1.05/sshpass-1.05.tar.gz">
version="1.05"
hash="sha256:c6324fcee608b99a58f9870157dfa754837f8c48be3df0f5e2f3accf145dee60"
repo="ftp.gnu.org"/>
</autotools>


<autotools id="cpio" autogen-sh="configure">
<branch module="/gnu/cpio/cpio-2.12.tar.bz2"
version="2.12"
Expand Down Expand Up @@ -826,6 +835,7 @@
<dependencies>
<dep package="yasm"/>
<dep package="nasm"/>
<dep package="sshpass"/>
<dep package="liborc"/>
<dep package="libogg"/>
<dep package="libtheora"/>
Expand Down
2 changes: 1 addition & 1 deletion osx/make-app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ rm "${MACOS_DIR}/Xpra_Launcher-bin"
#ensure that every wrapper has a "python" executable to match:
#(see PythonExecWrapper for why we need this "exec -a" workaround)
python_executable="$RSCDIR/bin/python"
for x in `ls "$HELPERS_DIR" | egrep -v "Python|SSH_ASKPASS|gst-plugin-scanner"`; do
for x in `ls "$HELPERS_DIR" | egrep -v "Python|gst-plugin-scanner"`; do
#replace underscore with space in actual binary filename:
target="$RSCDIR/bin/`echo $x | sed 's+_+ +g'`"
if [ ! -e "$target" ]; then
Expand Down
5 changes: 5 additions & 0 deletions rpmbuild/xpra.spec
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@ Requires: xvidcore
Requires: ffmpeg-xpra
Requires: %{numpy}
Requires: xpra-common = %{version}-%{build_no}%{dist}
%if 0%{?el6}%{?el7}
#sshpass is not available!
%else
Requires: sshpass
%endif
%if 0%{?suse_version}
#only use recommends because these are not in the standard repos:
Recommends: python-gstreamer
Expand Down
14 changes: 11 additions & 3 deletions src/xpra/client/gtk_base/client_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,9 +400,17 @@ def mode_changed(self, *args):
self.username_label.hide()
if self.config.port>0:
self.port_entry.set_text("%s" % self.config.port)
if not ssh or sys.platform.startswith("win") or sys.platform.startswith("darwin"):
#password cannot be used with ssh
#(except on win32 with plink, and on osx via the SSH_ASKPASS hack)
can_use_password = not ssh
if ssh:
if sys.platform.startswith("win"):
#plink can use password
pass
else:
#can use password if sshpass is installed:
from xpra.platform.paths import get_sshpass_command
sshpass = get_sshpass_command()
can_use_password = bool(sshpass)
if can_use_password:
self.password_label.show()
self.password_entry.show()
else:
Expand Down
9 changes: 9 additions & 0 deletions src/xpra/platform/darwin/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,15 @@ def do_get_download_dir():
return d


def do_get_ssh_askpass_script():
from xpra.platform.paths import get_app_dir
base = get_app_dir()
p = os.path.join(base, "Resources", "bin", "sshpass")
if os.path.exists(p):
return p
return None


def do_get_sound_command():
#try to use the subapp:
from xpra.platform.paths import get_app_dir
Expand Down
16 changes: 16 additions & 0 deletions src/xpra/platform/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,20 @@ def do_get_remote_run_xpra_scripts():
return ["~/.xpra/run-xpra", "$XDG_RUNTIME_DIR/xpra/run-xpra", "xpra"]


def get_sshpass_command():
return env_or_delegate("XPRA_SSHPASS", do_get_sshpass_command)
def do_get_sshpass_command():
import os.path
def is_exe(fpath):
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
for path in os.environ["PATH"].split(os.pathsep):
path = path.strip('"')
exe_file = os.path.join(path, "sshpass")
if is_exe(exe_file):
return exe_file
return None


#overriden in platform code:
def get_app_dir():
return env_or_delegate("XPRA_APP_DIR", do_get_app_dir)
Expand Down Expand Up @@ -199,6 +213,7 @@ def do_get_sound_command():
"do_get_app_dir",
"do_get_icon_dir")
platform_import(globals(), "paths", False,
"do_get_ssh_askpass_script",
"do_get_sound_command",
"do_get_install_prefix",
"do_get_default_conf_dirs",
Expand All @@ -224,6 +239,7 @@ def get_info():
"icons" : get_icon_dir(),
"home" : os.path.expanduser("~"),
"sound_command" : get_sound_command(),
"sshpass_command" : get_sshpass_command(),
}


Expand Down
15 changes: 13 additions & 2 deletions src/xpra/scripts/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1436,8 +1436,6 @@ def connect_to(display_desc, opts=None, debug_cb=None, ssh_fail_cb=ssh_connect_f
cmd += [INITENV_COMMAND+";"+remote_cmd]
else:
cmd += [remote_cmd]
if env:
kwargs["env"] = env
if debug_cb:
debug_cb("starting %s tunnel" % str(cmd[0]))
#debug_cb("starting ssh: %s with kwargs=%s" % (str(cmd), kwargs))
Expand All @@ -1446,6 +1444,19 @@ def connect_to(display_desc, opts=None, debug_cb=None, ssh_fail_cb=ssh_connect_f
for x in cmd:
if type(x)!=str:
raise InitException("argument is not a string: %s (%s), found in command: %s" % (x, type(x), cmd))
password = display_desc.get("password")
if password:
from xpra.platform.paths import get_sshpass_command
sshpass = get_sshpass_command()
if sshpass:
#sshpass -e ssh ...
cmd.insert(0, sshpass)
cmd.insert(1, "-e")
if env is None:
env = os.environ.copy()
env["SSHPASS"] = password
if env:
kwargs["env"] = env
child = Popen(cmd, stdin=PIPE, stdout=PIPE, **kwargs)
except OSError as e:
raise InitException("Error running ssh program '%s': %s" % (cmd, e))
Expand Down

0 comments on commit 8e47497

Please sign in to comment.