Skip to content

Commit c8b679a

Browse files
committed
Force temp dirname must end with 'temp' or 'tmp'
1 parent f09bed0 commit c8b679a

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

backup

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ if [ -z "${BackupTmpDir+x}" ]; then
3939
fi
4040
bkupdir=$BackupTmpDir
4141

42+
if [[ ! "$BackupTmpDir" =~ te?mp$ ]]; then
43+
echo "Backup temp dirname must end with 'temp' or 'tmp'!"
44+
exit 1
45+
fi
46+
4247
if [ -d $bkupdir ]; then
4348
# Remove temporary archives
4449
rm -rf $bkupdir/*

test/bats

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,9 @@ teardown() {
5353
[ "$status" -eq 1 ]
5454
[ "${lines[0]}" = "Backup temp dir not defined!" ]
5555
}
56+
57+
@test "invoking backup with config where backup temp dirname is invalid" {
58+
run backup $confdir/invalid-tmpdir.conf
59+
[ "$status" -eq 1 ]
60+
[ "${lines[0]}" = "Backup temp dirname must end with 'temp' or 'tmp'!" ]
61+
}

test/fixtures/invalid-tmpdir.conf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
BackupCmdDir=$PWD/test/fixtures/bkcmd.test.d
2+
BackupTmpDir=/usr/local
3+
Buckets=storage
4+
DestDir=destination
5+
MaxAge=5
6+
MaxLogAge=20

0 commit comments

Comments
 (0)