[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Autotest: make test dir writable before removing
From: |
Ralf Wildenhues |
Subject: |
Re: Autotest: make test dir writable before removing |
Date: |
Tue, 4 Oct 2005 12:08:02 +0200 |
User-agent: |
Mutt/1.5.11 |
Hi Paul,
* Paul Eggert wrote on Mon, Oct 03, 2005 at 09:41:04PM CEST:
> Ralf Wildenhues <address@hidden> writes:
>
> > Erm, the setup of the test directories (testsuite.dir/NNN) is pretty
> > irrelevant _before_ the test run: it is supposed to be erased.
>
> I was worried about the case where it wasn't erased, and where the
> test contained a symlink to /usr/bin or something like that.
Argh, `chmod -R' follows symlinks-to-files on some systems.
(Does it also descend symlinks-to-directories on some, by the way?)
> Admittedly I'm waving my hands a bit here; I don't know exactly what
> I'm worried about.
Nono, that's fine -- it should not change anything outside the test dir.
> Here are some other problems with that patch.
>
> First, there are two other instances of the problem in general.m4:
>
> rm -f -r "$at_suite_dir" "$at_suite_log"
>
> $at_debug_p || rm -f -r $at_group_dir
>
> Second, chmod u+w doesn't suffice for recursive removals. You would
> need at least chmod u+rwx. The 'r' is needed so that rm can read the
> directory to find out what its subfiles are. The 'x' is needed so
> that rm can search the directory to remove its subfiles.
Thanks. Updated patch below. Please take a look from a portability POV
(I'm not really sure whether the use of `find' is really safe like this).
Cheers, and thanks to Stepan, too,
Ralf
* lib/autotest/general.m4 (AT_INIT): Take care to ensure
writability before all removals of test dirs; do not descend
symlinks, change only directories.
Index: lib/autotest/general.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autotest/general.m4,v
retrieving revision 1.192
diff -u -r1.192 general.m4
--- lib/autotest/general.m4 3 Oct 2005 10:44:01 -0000 1.192
+++ lib/autotest/general.m4 4 Oct 2005 08:54:03 -0000
@@ -276,6 +276,8 @@
;;
--clean | -c )
+ test -d "$at_suite_dir" &&
+ find "$at_suite_dir" -type l -prune -o -type d -exec chmod u+rwx \{\}
\;
rm -f -r "$at_suite_dir" "$at_suite_log"
exit 0
;;
@@ -669,7 +671,8 @@
# Create a fresh directory for the next test group, and enter.
at_group_dir=$at_suite_dir/$at_group_normalized
at_group_log=$at_group_dir/$as_me.log
- test -d $at_group_dir && chmod -R u+w $at_group_dir
+ test -d $at_group_dir &&
+ find $at_group_dir -type l -prune -o -type d -exec chmod u+rwx \{\} \;
rm -f -r $at_group_dir
mkdir $at_group_dir ||
AS_ERROR([cannot create $at_group_dir])
@@ -763,7 +766,11 @@
echo "$at_log_msg" >&AS_MESSAGE_LOG_FD
# Cleanup the group directory, unless the user wants the files.
- $at_debug_p || rm -f -r $at_group_dir
+ if $at_debug_p; then :; else
+ test -d $at_group_dir &&
+ find $at_group_dir -type l -prune -o -type d -exec chmod u+rwx
\{\} \;
+ rm -f -r $at_group_dir
+ fi
;;
*)
# Upon failure, include the log into the testsuite's global
- Autotest: make test dir writable before removing, Ralf Wildenhues, 2005/10/01
- Re: Autotest: make test dir writable before removing, Ralf Wildenhues, 2005/10/01
- Re: Autotest: make test dir writable before removing, Paul Eggert, 2005/10/02
- Re: Autotest: make test dir writable before removing,
Ralf Wildenhues <=
- Re: Autotest: make test dir writable before removing, Paul Eggert, 2005/10/04
- Re: Autotest: make test dir writable before removing, Stepan Kasal, 2005/10/05
- Re: Autotest: make test dir writable before removing, Ralf Wildenhues, 2005/10/05
Re: Autotest: make test dir writable before removing, Stepan Kasal, 2005/10/03