* lib/write-any-file.c (can_write_any_file): Fix else-else bug
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 30 Mar 2007 07:08:51 +0000 (07:08 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 30 Mar 2007 07:08:51 +0000 (07:08 +0000)
reported by Bruno Haible.

ChangeLog
lib/write-any-file.c

index 48372b6..eb1838a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2007-03-30  Paul Eggert  <eggert@cs.ucla.edu>
+
+       * lib/write-any-file.c (can_write_any_file): Fix else-else bug
+       reported by Bruno Haible.
+
 2007-03-29  Bruno Haible  <bruno@clisp.org>
 
        * m4/iconv.m4 (AM_ICONV_LINK): Require AC_CANONICAL_HOST. Test against
index d016177..19ab99e 100644 (file)
@@ -34,10 +34,11 @@ bool
 can_write_any_file (void)
 {
   static bool initialized;
-  static bool can;
+  static bool can_write;
 
   if (! initialized)
     {
+      bool can = false;
 #if defined PRIV_EFFECTIVE && defined PRIV_FILE_DAC_WRITE
       priv_set_t *pset = priv_allocset ();
       if (pset)
@@ -47,13 +48,13 @@ can_write_any_file (void)
             && priv_ismember (pset, PRIV_FILE_DAC_WRITE));
          priv_freeset (pset);
        }
-      else
 #else
       /* In traditional Unix, only root can unlink directories.  */
       can = (geteuid () == 0);
 #endif
+      can_write = can;
       initialized = true;
     }
 
-  return can;
+  return can_write;
 }