dont force root privileges

This commit is contained in:
Vincent Riquer 2012-02-15 09:17:06 +01:00
parent a76bc6bc98
commit 1ed3a5ee9a
2 changed files with 32 additions and 14 deletions

6
debian/changelog vendored
View File

@ -1,3 +1,9 @@
remote-backup (1.5.3) stable; urgency=low
* Use rsync --fake-super when running as user
-- Vincent Riquer <v.riquer@b2f-concept.com> Wed, 15 Feb 2012 09:15:16 +0100
remote-backup (1.5.2) stable; urgency=low remote-backup (1.5.2) stable; urgency=low
* close log before printing failed backups info * close log before printing failed backups info

View File

@ -185,10 +185,12 @@ runBackup() {
if [[ $2 == PROTOCOLMISMATCH ]] if [[ $2 == PROTOCOLMISMATCH ]]
then then
# Protocol mismatch occurred, maybe caused by multiple --link-dest
# occurrences with rsync server protocol < 29
proto29=1 proto29=1
MAX_ROTATE=1 MAX_ROTATE=1
fi fi
for (( backup_num=0 ; backup_num <= MAX_ROTATE ; backup_num++ )) for (( backup_num=1 ; backup_num <= MAX_ROTATE ; backup_num++ ))
do do
if [ -d "$SNAPSHOT_RW/$NAME/daily.$backup_num" ] if [ -d "$SNAPSHOT_RW/$NAME/daily.$backup_num" ]
then then
@ -209,6 +211,14 @@ runBackup() {
RSYNC_OPTS="$RSYNC_OPTS --timeout=1800" RSYNC_OPTS="$RSYNC_OPTS --timeout=1800"
fi fi
# Not root? use --fake-super
if (( UID > 0 ))
then
echo "(info) running as user, using --fake-super."
RSYNC_OPTS="$RSYNC_OPTS --fake-super"
fi
for (( try=1 ; try <= RETRY ; try++ )) for (( try=1 ; try <= RETRY ; try++ ))
do do
$RSYNC \ $RSYNC \
@ -226,6 +236,14 @@ runBackup() {
break break
;; ;;
*) *)
if (( try == RETRY ))
then
cat <<-EOF
Trial $try / $RETRY failed, Giving up!
EOF
else
cat <<-EOF cat <<-EOF
Trial $try / $RETRY failed. Trial $try / $RETRY failed.
@ -233,6 +251,7 @@ runBackup() {
EOF EOF
sleep $RETRY_DELAY sleep $RETRY_DELAY
fi
;; ;;
esac esac
done done
@ -266,13 +285,6 @@ runBackup() {
unset proto29 unset proto29
} }
# make sure we're running as root
if [ ! $UID -eq 0 ]
then
echo "Sorry, must be root. Exiting..."
exit
fi
openLog openLog
if [ -n "$EMERG" ] if [ -n "$EMERG" ]