commit c546c3a5724c81cee9a11d816a38ccdf17472129
parent c1341583c96307cb0e6152c963ed23c4d56a4278
Author: Michael Forney <mforney@mforney.org>
Date: Fri, 22 May 2026 10:55:39 -0700
rm: Don't ask for confirmation to remove symlinks
faccessat traverses symlinks, and does not support AT_SYMLINK_NOFOLLOW
in POSIX.
Diffstat:
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libutil/rm.c b/libutil/rm.c
@@ -19,7 +19,7 @@ rm(int dirfd, const char *name, struct stat *st, void *data, struct recursor *r)
ignore = r->flags & IGNORE;
quiet = r->flags & SILENT;
ask = r->flags & CONFIRM;
- write = faccessat(dirfd, name, W_OK, 0) == 0;
+ write = S_ISLNK(st->st_mode) || faccessat(dirfd, name, W_OK, 0) == 0;
flags = 0;
if (S_ISDIR(st->st_mode) && r->maxdepth) {