coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fwd: Bug#1015273: coreutils: rm -d doesn't try to remove unreadable


From: Pádraig Brady
Subject: Re: Fwd: Bug#1015273: coreutils: rm -d doesn't try to remove unreadable directories, lies in error message, with *fails to prompt* with -i
Date: Tue, 21 Feb 2023 12:45:04 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Thunderbird/109.0

On 21/02/2023 02:59, Jim Meyering wrote:
---------- Forwarded message ---------
From: Jim Meyering <jim@meyering.net>
Date: Mon, Feb 20, 2023 at 6:27 PM
Subject: Re: Bug#1015273: coreutils: rm -d doesn't try to remove
unreadable directories, lies in error message, with *fails to prompt*
with -i
To: наб <nabijaczleweli@nabijaczleweli.xyz>, <1015273@bugs.debian.org>
Cc: Debian Bug Tracking System <submit@bugs.debian.org>

On Mon, Jul 18, 2022 at 12:21 PM наб <nabijaczleweli@nabijaczleweli.xyz> wrote:
Package: coreutils
Version: 8.32-4.1
Severity: normal

Dear Maintainer,

Fun one for ya: the baseline:
-- >8 --
$ mkdir -p /tmp/psko
$ rm -vid /tmp/psko
rm: remove directory '/tmp/psko'? y
removed directory '/tmp/psko'
-- >8 --

Bug a:
-- >8 --
$ mkdir -p /tmp/psko
$ chmod -r /tmp/psko
$ rm -vid /tmp/psko; echo $?
rm: cannot remove '/tmp/psko': Directory not empty
1
-- >8 --

Absolutely 0 prompt, despite -i!
That's very fun (and a POSIX violation)!

Bug b:
-- >8 --
$ strace rm -vid /tmp/psko 2>&1 | grep -v locale
execve("/bin/rm", ["rm", "-vid", "/tmp/psko"], 0xff8fbc48 /* 24 vars */) = 0
/* ... */
arch_prctl(ARCH_SET_FS, 0xf7f9e240)     = 0
mprotect(0xf7f8b000, 8192, PROT_READ)   = 0
mprotect(0x40f000, 4096, PROT_READ)     = 0
mprotect(0xf7fcd000, 8192, PROT_READ)   = 0
munmap(0xf7f96000, 26859)               = 0
brk(NULL)                               = 0xaa6000
brk(0xac7000)                           = 0xac7000
brk(0xac8000)                           = 0xac8000
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=3041504, ...}, AT_EMPTY_PATH) 
= 0
mmap(NULL, 2097152, PROT_READ, MAP_PRIVATE, 3, 0) = 0xf7a00000
mmap(NULL, 2596864, PROT_READ, MAP_PRIVATE, 3, 0x6d000) = 0xf7786000
close(3)                                = 0
ioctl(0, TCGETS, {B38400 opost isig icanon echo ...}) = 0
newfstatat(AT_FDCWD, "/tmp/psko", {st_mode=S_IFDIR|0311, st_size=40, ...}, 
AT_SYMLINK_NOFOLLOW) = 0
openat(AT_FDCWD, "/tmp/psko", 
O_RDONLY|O_NOCTTY|O_NONBLOCK|O_NOFOLLOW|O_DIRECTORY) = -1 EACCES (Permission denied)
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=2996, ...}, AT_EMPTY_PATH) = 0
read(3, "# Locale name alias data base.\n#"..., 4096) = 2996
read(3, "", 4096)                       = 0
close(3)                                = 0
write(2, "rm: ", 4rm: )                     = 4
write(2, "cannot remove '/tmp/psko'", 25cannot remove '/tmp/psko') = 25
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=1433, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 1433, PROT_READ, MAP_PRIVATE, 3, 0) = 0xf7f9c000
close(3)                                = 0
write(2, ": Directory not empty", 21: Directory not empty)   = 21
write(2, "\n", 1
)                       = 1
lseek(0, 0, SEEK_CUR)                   = -1 ESPIPE (Illegal seek)
close(0)                                = 0
close(1)                                = 0
close(2)                                = 0
exit_group(1)                           = ?
+++ exited with 1 +++
-- >8 --

Can you spot a rmdir(2) equivalent? I can't! So why does it lie and say
that it tried to remove it?

Also, the directory /isn't nonempty/! Bug c:
-- >8 --
$ rmdir -v /tmp/psko/; echo $?
rmdir: removing directory, '/tmp/psko/'
0
-- >8 --
And it's not there! Because, shockingly, there's nothing stopping you
from removing it! So why on /earth/ is rm failing to prompt, failing to
try to remove it, then lying that it had and failed with an obviously
false errno?

The same applies to just plain rm -d /tmp/psko (no -i)
(except for bug a).

Thank you for the bug report.
I've attached a patch that fixes those bugs.

lgtm
modulo the commit summary line should start with rm: not rm ...
Do you have git hooks disabled?

thanks!
Pádraig



reply via email to

[Prev in Thread] Current Thread [Next in Thread]