mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-11-19 03:33:43 +03:00
rm: fix a tiny, nearly inconsequential bug.
Don't perform a "."-relative lstat, when the file in question may well not be in ".". Although this is a bug, a few attempts to exercise it on a linux-2.6.22 system failed. You probably need a pre-openat system to trigger the failure. The consequence of this bug would be a lower-quality diagnostic upon failed dir removal. * src/remove.c (is_dir_lstat): Add a parameter, fd_cwd. Use it instead of hard-coding AT_FDCWD. (remove_entry): Call is_dir_lstat with fd_cwd. Signed-off-by: Jim Meyering <jim@meyering.net>
This commit is contained in:
1 parent
ebeb56f9df
commit
920b4416c1
2 files changed
+16
-3
No files matched your search
@@ -1,3 +1,15 @@
|
||||
2007-09-22 Jim Meyering <jim@meyering.net>
|
||||
|
||||
rm: fix a tiny, nearly inconsequential bug.
|
||||
Don't perform a "."-relative lstat, when the file in question
|
||||
may well not be in ".". Although this is a bug, a few attempts
|
||||
to exercise it on a linux-2.6.22 system failed. You probably need
|
||||
a pre-openat system to trigger the failure. The consequence of this
|
||||
bug would be a lower-quality diagnostic upon failed dir removal.
|
||||
* src/remove.c (is_dir_lstat): Add a parameter, fd_cwd.
|
||||
Use it instead of hard-coding AT_FDCWD.
|
||||
(remove_entry): Call is_dir_lstat with fd_cwd.
|
||||
|
||||
2007-09-22 Karl Berry <karl@freefriends.org>
|
||||
|
||||
* TODO: It'd be nice to add renice.
|
||||
|
||||
+4
-3
@@ -927,11 +927,11 @@ prompt (int fd_cwd, Dirstack_state const *ds, char const *filename,
|
||||
*ST is FILENAME's tstatus.
|
||||
Do not modify errno. */
|
||||
static inline bool
|
||||
is_dir_lstat (char const *filename, struct stat *st)
|
||||
is_dir_lstat (int fd_cwd, char const *filename, struct stat *st)
|
||||
{
|
||||
int saved_errno = errno;
|
||||
bool is_dir =
|
||||
(cache_fstatat (AT_FDCWD, filename, st, AT_SYMLINK_NOFOLLOW) == 0
|
||||
(cache_fstatat (fd_cwd, filename, st, AT_SYMLINK_NOFOLLOW) == 0
|
||||
&& S_ISDIR (st->st_mode));
|
||||
errno = saved_errno;
|
||||
return is_dir;
|
||||
@@ -1061,7 +1061,8 @@ remove_entry (int fd_cwd, Dirstack_state const *ds, char const *filename,
|
||||
/* Upon a failed attempt to unlink a directory, most non-Linux systems
|
||||
set errno to the POSIX-required value EPERM. In that case, change
|
||||
errno to EISDIR so that we emit a better diagnostic. */
|
||||
if (! x->recursive && errno == EPERM && is_dir_lstat (filename, st))
|
||||
if (! x->recursive && errno == EPERM && is_dir_lstat (fd_cwd,
|
||||
filename, st))
|
||||
errno = EISDIR;
|
||||
|
||||
if (! x->recursive
|
||||
|
||||
Reference in new issue
Block a user