Created
December 27, 2017 22:46
-
-
Save rduplain/11aa60c3e8f0628606342472713287eb to your computer and use it in GitHub Desktop.
Ensure rrsync subdirectory is a mountpoint.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Simple pre-rsync check to ensure rrsync subdirectory is a mountpoint. | |
# That is, only allow rsyncing to a mounted drive, and fail otherwise. | |
# | |
# Drop-in replacement for rrsync in .ssh/authorized_keys. | |
rrsync="$HOME"/bin/rrsync | |
# Assume -ro always comes before the subdirectory, if provided. | |
if [ $# -eq 0 ]; then | |
exec $rrsync | |
elif [ $# -eq 1 ]; then | |
path=$1 | |
elif [ $# -eq 2 ]; then | |
path=$2 | |
else | |
exec $rrsync | |
fi | |
if ! mountpoint -q $path; then | |
echo "Path is not a mountpoint: $path" >&2 | |
exit 2 | |
fi | |
exec $rrsync "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment