samba

Rsync shell

May 4th, 2011
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.52 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. cd $HOME
  4.  
  5. # block any non-rsync commands
  6. echo "$SSH_ORIGINAL_COMMAND" | grep -q '^rsync --server' || exit 1
  7.  
  8. # force all paths to reside within home directory, and filter '..' relative path shifts.
  9. RSYNC_COMMAND=$(echo $SSH_ORIGINAL_COMMAND | sed -r 's@ \. /(.*)$@ . ./\1@; s@\.+@.@g;')
  10.  
  11. # add other options for efficiency
  12. RSYNC_COMMAND=$(echo $RSYNC_COMMAND | sed 's/--server/--server --safe-links --no-g --no-o --fuzzy --inplace -z/')
  13.  
  14. # echo "remote command: $RSYNC_COMMAND" >&2
  15. exec $RSYNC_COMMAND
Advertisement
Add Comment
Please, Sign In to add comment