changeset 8592:e91286e73129

* lib/write-any-file.c (can_write_any_file): Fix else-else bug reported by Bruno Haible.
author Paul Eggert <eggert@cs.ucla.edu>
date Fri, 30 Mar 2007 07:08:51 +0000
parents 5cba81876885
children d07bd599d67f
files ChangeLog lib/write-any-file.c
diffstat 2 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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
--- a/lib/write-any-file.c
+++ b/lib/write-any-file.c
@@ -34,10 +34,11 @@
 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 @@
 	     && 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;
 }