X-Git-Url: https://git.stderr.nl/gitweb?p=matthijs%2Fupstream%2Fbackupninja.git;a=blobdiff_plain;f=backupninja;h=c8764ab651d3ea3402d1a4192ee47d5070ab28fc;hp=921cb96754d3e76673b51ab080d2281bd359b9c4;hb=a7bf628e6129254d0abb47e00fbb0df2d588cf34;hpb=8fbbbbe8d759eeaad8427c22fc76f4f4e4127181 diff --git a/backupninja b/backupninja index 921cb96..c8764ab 100755 --- a/backupninja +++ b/backupninja @@ -133,6 +133,77 @@ function getconf() { eval $1='$ret' } +# +# enforces very strict permissions on configuration file $file. +# + +function check_perms() { + local file=$1 + local perms=`ls -ld $file` + perms=${perms:4:6} + if [ "$perms" != "------" ]; then + fatal "Configuration files must not be group or world readable! Dying on file $file" + fi + if [ `ls -ld $file | awk '{print $3}'` != "root" ]; then + fatal "Configuration files must be owned by root! Dying on file $file" + fi +} + +# simple lowercase function +function tolower() { + echo "$1" | tr [:upper:] [:lower:] +} + +# simple to integer function +function toint() { + echo "$1" | tr [:alpha:] -d +} + +# +# function isnow(): returns 1 if the time/day passed as $1 matches +# the current time/day. +# +# format is at