autoconf-patches
[Top][All Lists]
Advanced

[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: Wed, 5 Oct 2005 11:23:27 +0200
User-agent: Mutt/1.5.11

Hi Paul,

* Paul Eggert wrote on Tue, Oct 04, 2005 at 09:17:54PM CEST:
> Ralf Wildenhues <address@hidden> writes:
> 
> > +   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"
> 
> Why do you need the "-type l -prune" here?  Can't that be omitted?
> "find" doesn't follow symlinks.  (Ancient versions of "find" don't
> understand either -type l or -prune.)

OK then.  I was just trying to be overly cautious here, and I misread
this paragraph in the SUSv3 find(1) page, overlooking the `on the
command line' part:

|                                     Historical practice for the -follow
| primary, however, is not consistent. Some implementations always follow
| symbolic links on the command line whether -follow is specified or not.
| Others follow symbolic links on the command line only if -follow is
| specified. Both behaviors are provided by the -H and -L options, but
| scripts using the current -follow primary would be broken if the -follow
| option is specified to work either way.

> Similarly for the other uses of "find" and "rm".

Yep.

> Also, as a minor efficiency thing, if $at_suite_dir is not a directory
> then you don't need to invoke rm at all; this really only applies to
> the other uses, since the only thing they do is remove $at_group_dir.

I've not quite understood this paragraph, but I believe the updated
patch below does what you intended.

Cheers,
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.193
diff -u -r1.193 general.m4
--- lib/autotest/general.m4     4 Oct 2005 09:14:12 -0000       1.193
+++ lib/autotest/general.m4     5 Oct 2005 09:13:09 -0000
@@ -276,7 +276,8 @@
        ;;
 
     --clean | -c )
-       test -d "$at_suite_dir" && chmod -R u+rwx "$at_suite_dir"
+       test -d "$at_suite_dir" &&
+         find "$at_suite_dir" -type d -exec chmod u+rwx \{\} \;
        rm -f -r "$at_suite_dir" "$at_suite_log"
        exit 0
        ;;
@@ -670,8 +671,10 @@
       # 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+rwx $at_group_dir
-      rm -f -r $at_group_dir
+      if test -d $at_group_dir; then
+       find $at_group_dir -type d -exec chmod u+rwx \{\} \;
+       rm -f -r $at_group_dir
+      fi
       mkdir $at_group_dir ||
        AS_ERROR([cannot create $at_group_dir])
       cd $at_group_dir
@@ -764,10 +767,12 @@
          echo "$at_log_msg" >&AS_MESSAGE_LOG_FD
 
          # Cleanup the group directory, unless the user wants the files.
-         $at_debug_p || {
-           test -d $at_group_dir && chmod -R u+rwx $at_group_dir
-           rm -f -r $at_group_dir
-         }
+         if $at_debug_p; then :; else
+           if test -d $at_group_dir; then
+             find $at_group_dir -type d -exec chmod u+rwx \{\} \;
+             rm -f -r $at_group_dir
+           fi
+         fi
          ;;
        *)
          # Upon failure, include the log into the testsuite's global




reply via email to

[Prev in Thread] Current Thread [Next in Thread]