Simplify code

This commit is contained in:
Janek Bevendorff 2015-10-14 20:35:55 +02:00
parent a87b975a72
commit 785c0245f0
1 changed files with 9 additions and 11 deletions

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
## ##
# Copyright (C) 2013-2014 Janek Bevendorff # Copyright (C) 2013-2015 Janek Bevendorff
# Website: http://www.refining-linux.org/ # Website: http://www.refining-linux.org/
# #
# Run a restricted command in an SSH session. # Run a restricted command in an SSH session.
@ -27,19 +27,17 @@
## ##
home_dir=$1 home_dir=$1
export HOME="${home_dir}/files"
cd $HOME
if $(echo "${SSH_ORIGINAL_COMMAND}" | grep -q "^\(internal-sftp\|.*/sftp-server\)"); then if $(echo "${SSH_ORIGINAL_COMMAND}" | grep -q "^\(internal-sftp\|.*/sftp-server\)"); then
export HOME="${home_dir}/files" [ -x /usr/lib/ssh/sftp-server ] && exec /usr/lib/ssh/sftp-server -R
cd $HOME [ -x /usr/libexec/sftp-server ] && exec /usr/libexec/sftp-server -R
[ -x /usr/lib/ssh/sftp-server ] && exec /usr/lib/ssh/sftp-server -R [ -x /opt/libexec/sftp-server ] && exec /opt/libexec/sftp-server -R
[ -x /usr/libexec/sftp-server ] && exec /usr/libexec/sftp-server -R
[ -x /opt/libexec/sftp-server ] && exec /opt/libexec/sftp-server -R
else else
RSYNC=/usr/bin/rsync RSYNC_OPTS="--server --daemon --config='$home_dir/rsync.conf' ."
RSYNC_OPTS="--server --daemon --config='$home_dir/rsync.conf' ." [ -x /usr/bin/rsync ] && exec /usr/bin/rsync $(eval echo $RSYNC_OPTS)
[ -x $RSYNC ] && exec $RSYNC $(eval echo $RSYNC_OPTS) [ -x /opt/bin/rsync ] && exec /opt/bin/rsync $(eval echo $RSYNC_OPTS)
RSYNC=/opt/bin/rsync
[ -x $RSYNC ] && exec $RSYNC $(eval echo $RSYNC_OPTS)
fi fi
echo "Session failed." >&2 echo "Session failed." >&2