Skip to contentSkip to conversation

master - lvmdump: If dir exists check dir perms too.

PATCH Alasdair Kergon 1 participant 1 message Apr 6, 2016

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f19ec0e36d64bcde6cb4cbd00376fe2377e81b19
Commit:        f19ec0e36d64bcde6cb4cbd00376fe2377e81b19
Parent:        55001ae9ec2c00a070f8dfa8541f4f17a6e2a284
Author:        Alasdair G Kergon <[email protected]>
AuthorDate:    Wed Apr 6 22:56:45 2016 +0100
Committer:     Alasdair G Kergon <[email protected]>
CommitterDate: Wed Apr 6 22:56:45 2016 +0100

lvmdump: If dir exists check dir perms too.

---
 scripts/lvmdump.sh |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
scripts/lvmdump.sh +2 -1
index 19b36d3..a813537 100755
@@ -100,7 +100,8 @@ else
 fi
 
 if test -d $dir ; then
-	(shopt -s nullglob dotglob; cd $dir && files=(*) && ((${#files[@]}))) && die 5 "Fatal: directory $dir already exists and is not empty"
+	(shopt -s nullglob dotglob; test -r $dir -a -w $dir -a -x $dir && cd $dir && files=(*) && ((! ${#files[@]}))) || \
+		die 5 "Fatal: directory $dir already exists and is not empty or inaccessible"
 else
 	test -e $dir && die 3 "Fatal: $dir already exists"
 	$MKDIR -p $dir || die 4 "Fatal: could not create $dir"