diff options
| author | Jim Meyering <meyering@redhat.com> | 2010-03-06 13:16:19 +0100 |
|---|---|---|
| committer | Jim Meyering <meyering@redhat.com> | 2010-03-10 11:05:18 +0100 |
| commit | 998fe29301083246f16738a5f42ccb9d15fd85ea (patch) | |
| tree | 0daf0fc0c6bc6f291888d0a9617d16f6a8d1bc1a /src/remove.c | |
| parent | doc: Add an example for cutting fields separated by runs of blanks (diff) | |
| download | coreutils-998fe29301083246f16738a5f42ccb9d15fd85ea.tar.gz coreutils-998fe29301083246f16738a5f42ccb9d15fd85ea.zip | |
remove: without -f, avoid unnecessary-expense/issues with euidaccess
* src/remove.c (write_protected_non_symlink): If faccessat fails,
return 1 or -1 directly, rather than falling back on euidaccess*.
Diffstat (limited to 'src/remove.c')
| -rw-r--r-- | src/remove.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/remove.c b/src/remove.c index b6cfc8e99..d0b2dae2f 100644 --- a/src/remove.c +++ b/src/remove.c @@ -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); |
