[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] {maint} tests: tempdirs with restrictive permissions are cleaned
From: |
Stefano Lattarini |
Subject: |
[PATCH] {maint} tests: tempdirs with restrictive permissions are cleaned correctly |
Date: |
Wed, 16 Feb 2011 21:26:17 +0100 |
User-agent: |
KMail/1.13.3 (Linux/2.6.30-2-686; KDE/4.4.4; i686; ; ) |
Hello automakers.
Before this change, the removal of a temporary test directory
containing subdirectories with restrictive permissions (such as
'r--r--r--') could fail.
Here is a minimal example of the issue just described.
$ cd ~/src/automake/tests
$ cat > foo.test <<'END'
. ./defs
mkdir foo
: > foo/bar
chmod 222 foo
END
First time the test is run, only the final clenaup fails. No big
deal apparently.
$ sh foo.test
~/src/automake/tests:...:/bin:/sbin
=== Running test foo.test
++ pwd
/home/stefano/src/automake/tests/foo.dir
+ mkdir foo
+ :
+ chmod 222 foo
+ exit_status=0
+ set +e
+ cd /home/stefano/src/automake/tests
+ case $exit_status,$keep_testdirs in
+ find foo.dir -type d '!' -perm -200 -exec chmod u+w '{}' ';'
find: `foo.dir/foo': Permission denied
+ rm -rf foo.dir
rm: cannot remove `foo.dir/foo': Permission denied
+ test 0 '!=' 0
+ echo 'foo: exit 0'
foo: exit 0
+ exit 0
But the second time it's run, the setup fails, and the test errors
out! This is unacceptable.
$ sh foo.test
~/src/automake/tests:...:/bin:/sbin
find: `foo.dir/foo': Permission denied
rm: cannot remove `foo.dir/foo': Permission denied
mkdir: cannot create directory `foo.dir': File exists
=== Running test foo.test
++ pwd
/home/stefano/src/automake/tests/foo.dir
+ mkdir foo
mkdir: cannot create directory `foo': File exists
+ :
foo.test: line 3: foo/bar: Permission denied
+ exit_status=1
+ set +e
+ cd /home/stefano/src/automake/tests
+ case $exit_status,$keep_testdirs in
+ test 0 '!=' 0
+ echo 'foo: exit 1'
foo: exit 1
+ exit 1
The attached patch should fix this. OK for maint?
Regards,
Stefano
-*-*-*-
* tests/defs: Ensure that all the subdirectories of a temporary
test directory have the 'read', 'write' and 'execute' bits set,
before trying to remove it with `rm -rf'.
* tests/Makefile.am (clean-local-check): Likewise.
---
ChangeLog | 11 +++++++++++
tests/Makefile.am | 2 +-
tests/defs.in | 4 ++--
3 files changed, 14 insertions(+), 3 deletions(-)
From 0988777745de242bb201658a0dfa8df369a1263e Mon Sep 17 00:00:00 2001
From: Stefano Lattarini <address@hidden>
Date: Wed, 16 Feb 2011 20:43:22 +0100
Subject: [PATCH] tests: tempdirs with restrictive permissions are cleaned
correctly
Before this change, the removal of a temporary test directory
containing subdirectories with restrictive permissions (such as
'r--r--r--') could fail.
* tests/defs: Ensure that all the subdirectories of a temporary
test directory have the 'read', 'write' and 'execute' bits set,
before trying to remove it with `rm -rf'.
* tests/Makefile.am (clean-local-check): Likewise.
---
ChangeLog | 11 +++++++++++
tests/Makefile.am | 2 +-
tests/defs.in | 4 ++--
3 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 4563585..3d233a3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,15 @@
2011-02-16 Stefano Lattarini <address@hidden>
+
+ tests: tempdirs with restrictive permissions are cleaned correctly
+ Before this change, the removal of a temporary test directory
+ containing subdirectories with restrictive permissions (such as
+ 'r--r--r--') could fail.
+ * tests/defs: Ensure that all the subdirectories of a temporary
+ test directory have the 'read', 'write' and 'execute' bits set,
+ before trying to remove it with `rm -rf'.
+ * tests/Makefile.am (clean-local-check): Likewise.
+
+2011-02-16 Stefano Lattarini <address@hidden>
Ralf Wildenhues <address@hidden>
test defs: add subroutine for input unindenting
diff --git a/tests/Makefile.am b/tests/Makefile.am
index ed415f2..047bc7b 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -839,6 +839,6 @@ clean-local-check:
if test "$$#,$$1" = "1,*.dir"; then \
: there is no test directory to clean; \
else \
- find "$$@" -type d '!' -perm -200 -exec chmod u+w {} ';'; \
+ find "$$@" -type d ! -perm -700 -exec chmod u+rwx {} ';'; \
rm -rf "$$@"; \
fi;
diff --git a/tests/defs.in b/tests/defs.in
index ffe21e1..fd0cc9c 100644
--- a/tests/defs.in
+++ b/tests/defs.in
@@ -263,7 +263,7 @@ Exit ()
curdir=`pwd`
testSubDir=$me.dir
test ! -d $testSubDir || {
- find $testSubDir -type d ! -perm -200 -exec chmod u+w {} ";"
+ find $testSubDir -type d ! -perm -700 -exec chmod u+rwx {} ";"
rm -rf $testSubDir
}
mkdir $testSubDir
@@ -275,7 +275,7 @@ if test "$sh_errexit_works" = yes; then
cd "$curdir"
case $exit_status,$keep_testdirs in
0,)
- find $testSubDir -type d ! -perm -200 -exec chmod u+w {} ";"
+ find $testSubDir -type d ! -perm -700 -exec chmod u+rwx {} ";"
rm -rf $testSubDir
;;
esac
--
1.7.2.3
- [PATCH] {maint} tests: tempdirs with restrictive permissions are cleaned correctly,
Stefano Lattarini <=