summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2011-10-09 10:52:52 +0200
committerJim Meyering <meyering@redhat.com>2011-10-09 19:04:35 +0200
commitd12ca9764bb85948fe408576ae45f40030dc21b0 (patch)
tree43df655ab049b5e01eaf9d1449e9b0dfa8c15d01 /src
parentc977d5de8d0cb83d9193dea860ed7f395df89858 (diff)
downloadcoreutils-d12ca9764bb85948fe408576ae45f40030dc21b0.tar.xz
rm: do not resort to stat'ing very long names even on deficient systems
This change affects only systems that have neither *at function support nor the /proc/self/fd support required to emulate those *at functions. * src/remove.c (write_protected_non_symlink): Call faccessat unconditionally. Thus we no longer need euidaccess_stat, which was the sole function used here to operate on a full relative file name. Remove full_name parameter and update caller. * lib/euidaccess-stat.h: Remove file. * lib/euidaccess-stat.c: Likewise. * m4/euidaccess-stat.m4: Likewise. * po/POTFILES.in: Remove lib/euidaccess-stat.c. * m4/prereq.m4 (gl_PREREQ): Don't require gl_EUIDACCESS_STAT. Prompted by a report from Bruno Haible that the rm/deep-2 test was failing on HP-UX 11.31. See http://thread.gmane.org/gmane.comp.gnu.coreutils.general/1748
Diffstat (limited to 'src')
-rw-r--r--src/remove.c35
1 files changed, 4 insertions, 31 deletions
diff --git a/src/remove.c b/src/remove.c
index 381423238..c65054306 100644
--- a/src/remove.c
+++ b/src/remove.c
@@ -23,7 +23,6 @@
#include "system.h"
#include "error.h"
-#include "euidaccess-stat.h"
#include "file-type.h"
#include "ignore-value.h"
#include "quote.h"
@@ -106,13 +105,10 @@ cache_stat_ok (struct stat *st)
/* Return 1 if FILE is an unwritable non-symlink,
0 if it is writable or some other type of file,
-1 and set errno if there is some problem in determining the answer.
- Use FULL_NAME only if necessary.
- Set *BUF to the file status.
- This is to avoid calling euidaccess when FILE is a symlink. */
+ Set *BUF to the file status. */
static int
write_protected_non_symlink (int fd_cwd,
char const *file,
- char const *full_name,
struct stat *buf)
{
if (can_write_any_file ())
@@ -170,32 +166,10 @@ write_protected_non_symlink (int fd_cwd,
mess up with long file names). */
{
- /* This implements #1: on decent systems, either faccessat is
- native or /proc/self/fd allows us to skip a chdir. */
- 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);
-
- if (MIN (PATH_MAX, 8192) <= file_name_len)
- return ! euidaccess_stat (buf, W_OK);
- if (euidaccess (full_name, W_OK) == 0)
+ if (faccessat (fd_cwd, file, W_OK, AT_EACCESS) == 0)
return 0;
- if (errno == EACCES)
- {
- errno = 0;
- return 1;
- }
- /* Perhaps some other process has removed the file, or perhaps this
- is a buggy NFS client. */
- return -1;
+ return errno == EACCES ? 1 : -1;
}
}
@@ -244,8 +218,7 @@ prompt (FTS const *fts, FTSENT const *ent, bool is_dir,
&& ((x->interactive == RMI_ALWAYS) || x->stdin_tty)
&& dirent_type != DT_LNK)
{
- write_protected = write_protected_non_symlink (fd_cwd, filename,
- full_name, sbuf);
+ write_protected = write_protected_non_symlink (fd_cwd, filename, sbuf);
wp_errno = errno;
}