]> Savannah Git Hosting - gnulib.git/commitdiff
savewd: remove SAVEWD_CHDIR_READABLE
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 23 Sep 2015 03:04:13 +0000 (20:04 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 23 Sep 2015 03:05:01 +0000 (20:05 -0700)
It was problematic in the light of file systems that ignore umask.
Problem reported by Sebastian Ungar in: http://bugs.gnu.org/21534
* NEWS: Document this.
* lib/mkancesdirs.c (mkancesdirs): MAKE_DIR now returns 0 if
successful, -1 (setting errno) on failure, rather than something
more complicated than that.
* lib/mkdir-p.c (make_dir_parents):
Do not use SAVEWD_CHDIR_READABLE.
* lib/savewd.c (savewd_chdir):
Remove support for SAVEWD_CHDIR_READABLE.
* lib/savewd.h (SAVEWD_CHDIR_READABLE): Remove.

ChangeLog
NEWS
lib/mkancesdirs.c
lib/mkdir-p.c
lib/savewd.c
lib/savewd.h

index 62458b2a01835437c907e44cfabf4cd14b9c4da1..1bcc6f180d47e55dc90f3e64b171aeefe5b3747c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
 2015-09-22  Paul Eggert  <eggert@cs.ucla.edu>
 
+       savewd: remove SAVEWD_CHDIR_READABLE
+       It was problematic in the light of file systems that ignore umask.
+       Problem reported by Sebastian Ungar in: http://bugs.gnu.org/21534
+       * NEWS: Document this.
+       * lib/mkancesdirs.c (mkancesdirs): MAKE_DIR now returns 0 if
+       successful, -1 (setting errno) on failure, rather than something
+       more complicated than that.
+       * lib/mkdir-p.c (make_dir_parents):
+       Do not use SAVEWD_CHDIR_READABLE.
+       * lib/savewd.c (savewd_chdir):
+       Remove support for SAVEWD_CHDIR_READABLE.
+       * lib/savewd.h (SAVEWD_CHDIR_READABLE): Remove.
+
        c-ctype: port better to EBCDIC
        Problems reported by Daniel Richard G. in
        http://lists.gnu.org/archive/html/bug-gnulib/2015-09/msg00020.html
diff --git a/NEWS b/NEWS
index b294edd9844cda4791755d9ed646d35dab0b2ea7..b54a99286d430ed501403163a6b9a2f69c93c1cf 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -42,6 +42,8 @@ User visible incompatible changes
 
 Date        Modules         Changes
 
+2015-09-22  savewd          SAVEWD_CHDIR_READABLE constant removed.
+
 2015-07-24  fprintftime     Exported functions' time zone arguments are now of
             strftime        type timezone_t (with NULL denoting UTC) instead of
                             type int (with nonzero denoting UTC).  These
index 91ed694aacd30d108bd8fd4a431da7f9c667bd36..2747d4a649a9d0940d2e5365fdf081c960eb34ec 100644 (file)
 
    Create any ancestor directories that don't already exist, by
    invoking MAKE_DIR (FILE, COMPONENT, MAKE_DIR_ARG).  This function
-   should return 0 if successful and the resulting directory is
-   readable, 1 if successful but the resulting directory might not be
-   readable, -1 (setting errno) otherwise.  If COMPONENT is relative,
-   it is relative to the temporary working directory, which may differ
-   from *WD.
+   should return 0 if successful, -1 (setting errno) otherwise.  If
+   COMPONENT is relative, it is relative to the temporary working
+   directory, which may differ from *WD.
 
    Ordinarily MAKE_DIR is executed with the working directory changed
    to reflect the already-made prefix, and mkancesdirs returns with
@@ -112,20 +110,10 @@ mkancesdirs (char *file, struct savewd *wd,
             if (sep - component == 2
                 && component[0] == '.' && component[1] == '.')
               made_dir = false;
+            else if (make_dir (file, component, make_dir_arg) < 0)
+              make_dir_errno = errno;
             else
-              switch (make_dir (file, component, make_dir_arg))
-                {
-                case -1:
-                  make_dir_errno = errno;
-                  break;
-
-                case 0:
-                  savewd_chdir_options |= SAVEWD_CHDIR_READABLE;
-                  /* Fall through.  */
-                case 1:
-                  made_dir = true;
-                  break;
-                }
+              made_dir = true;
 
             if (made_dir)
               savewd_chdir_options |= SAVEWD_CHDIR_NOFOLLOW;
index e55b1ddf145a5536055bee5cca9d188553c9f334..e5182723b538f0b2322d09a8a1693f3e7b382957 100644 (file)
@@ -136,9 +136,7 @@ make_dir_parents (char *dir,
               announce (dir, options);
               preserve_existing = (keep_owner & keep_special_mode_bits
                                    & umask_must_be_ok);
-              savewd_chdir_options |=
-                (SAVEWD_CHDIR_NOFOLLOW
-                 | (mode & S_IRUSR ? SAVEWD_CHDIR_READABLE : 0));
+              savewd_chdir_options |= SAVEWD_CHDIR_NOFOLLOW;
             }
           else
             {
index 16f56a8eb5ff0c8e778e235d73269a6a8250e5dc..f835074bf444351fa2b80c82488a0e030706d55d 100644 (file)
@@ -116,7 +116,7 @@ savewd_chdir (struct savewd *wd, char const *dir, int options,
           open_result[1] = errno;
         }
 
-      if (fd < 0 && (errno != EACCES || (options & SAVEWD_CHDIR_READABLE)))
+      if (fd < 0 && errno != EACCES)
         result = -1;
     }
 
index bb442b33b36be03ff940e1ff43b475b14ce0674b..69b371859e53cc31bd4038a1c7d95c12d0021421 100644 (file)
@@ -82,20 +82,15 @@ savewd_init (struct savewd *wd)
 }
 
 
-/* Options for savewd_chdir.  */
+/* Options for savewd_chdir.  Can be ORed together.  */
 enum
   {
     /* Do not follow symbolic links, if supported.  */
     SAVEWD_CHDIR_NOFOLLOW = 1,
 
-    /* The directory should be readable, so fail if it happens to be
-       discovered that the directory is not readable.  (Unreadable
-       directories are not necessarily diagnosed, though.)  */
-    SAVEWD_CHDIR_READABLE = 2,
-
     /* Do not chdir if the directory is readable; simply succeed
        without invoking chdir if the directory was opened.  */
-    SAVEWD_CHDIR_SKIP_READABLE = 4
+    SAVEWD_CHDIR_SKIP_READABLE = 2
   };
 
 /* Change the directory, and if successful, record into *WD the fact