Matt McCutchen's Web Site
/
rsync
/
rsync.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Man page: Move the description of --info=progress2 to a better place.
[rsync/rsync.git]
/
support
/
lsh
diff --git
a/support/lsh
b/support/lsh
index
20ebc3d
..
b63444e
100755
(executable)
--- a/
support/lsh
+++ b/
support/lsh
@@
-6,18
+6,30
@@
# we get a -l USER option, we try to use "sudo -u USER" to run the
# command.
# we get a -l USER option, we try to use "sudo -u USER" to run the
# command.
-prefix=''
-
-cd # Default path is home dir, just like ssh.
+user=''
+do_cd=y # Default path is user's home dir, just like ssh.
while : ; do
case "$1" in
while : ; do
case "$1" in
- -l) shift ; prefix="sudo -u $1"; shift ;;
- -l*) prefix=`echo $1 | sed 's/-l/sudo -u /'`; shift ;;
+ -l) user="$2"; shift; shift ;;
+ -l*) user=`echo "$1" | sed 's/^-l//'`; shift ;;
+ --no-cd) do_cd=n; shift ;;
-*) shift ;;
localhost) shift; break ;;
-*) shift ;;
localhost) shift; break ;;
- *) exit 1 ;;
+ *) e
cho "lsh: unable to connect to host $1" 1>&2; e
xit 1 ;;
esac
done
esac
done
-eval $prefix "${@}"
+if [ "$user" ]; then
+ prefix=''
+ if [ $do_cd = y ]; then
+ home=`perl -e "print((getpwnam('$user'))[7])"`
+ prefix="cd '$home' &&"
+ fi
+ sudo -H -u "$user" sh -c "$prefix $*"
+else
+ if [ $do_cd = y ]; then
+ cd || exit 1
+ fi
+ eval "${@}"
+fi