]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
remove: without -f, avoid unnecessary-expense/issues with euidaccess
authorJim Meyering <meyering@redhat.com>
Sat, 6 Mar 2010 12:16:19 +0000 (13:16 +0100)
committerJim Meyering <meyering@redhat.com>
Wed, 10 Mar 2010 10:05:18 +0000 (11:05 +0100)
* src/remove.c (write_protected_non_symlink): If faccessat fails,
return 1 or -1 directly, rather than falling back on euidaccess*.

src/remove.c

index b6cfc8e99919cebdd898b39a89f761390b59a889..d0b2dae2f479f9e4e8f969d349c153b095a7e7d3 100644 (file)
@@ -171,9 +171,13 @@ write_protected_non_symlink (int fd_cwd,
   {
     /* This implements #1: on decent systems, either faccessat is
        native or /proc/self/fd allows us to skip a chdir.  */
-    if (!openat_needs_fchdir ()
-        && faccessat (fd_cwd, file, W_OK, AT_EACCESS) == 0)
-      return 0;
+    if (!openat_needs_fchdir ())
+      {
+        if (faccessat (fd_cwd, file, W_OK, AT_EACCESS) == 0)
+          return 0;
+
+        return errno == EACCES ? 1 : -1;
+      }
 
     /* This implements #5: */
     size_t file_name_len = strlen (full_name);