Merge branch 'master' of ssh://haible@git.sv.gnu.org/srv/git/gnulib
[gnulib.git] / lib / write-any-file.c
index d016177..8492ac8 100644 (file)
@@ -2,10 +2,10 @@
 
    Copyright (C) 2007 Free Software Foundation, Inc.
 
-   This program is free software; you can redistribute it and/or modify
+   This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2, or (at your option)
-   any later version.
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -13,8 +13,7 @@
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software Foundation,
-   Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.  */
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 /* Written by Paul Eggert.  */
 
@@ -34,10 +33,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 +47,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;
 }