summaryrefslogtreecommitdiff
path: root/libbb/remove_file.c
diff options
context:
space:
mode:
authorMatt Kraai2001-05-11 02:35:36 +0000
committerMatt Kraai2001-05-11 02:35:36 +0000
commitf3e79ba6e3b3bfa380241205829d0a78570c9af3 (patch)
tree7778ed6ee8c7cab1d2bcd2b878592e4547ee840c /libbb/remove_file.c
parent6e91f69a0d3105f78acbbf9f4e01d5b31fd0dfdf (diff)
downloadbusybox-f3e79ba6e3b3bfa380241205829d0a78570c9af3.zip
busybox-f3e79ba6e3b3bfa380241205829d0a78570c9af3.tar.gz
Fix symlink removal problem noted by Erik Andersen.
Diffstat (limited to 'libbb/remove_file.c')
-rw-r--r--libbb/remove_file.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/libbb/remove_file.c b/libbb/remove_file.c
index 52b3211..23be404 100644
--- a/libbb/remove_file.c
+++ b/libbb/remove_file.c
@@ -37,7 +37,7 @@ extern int remove_file(const char *path, int flags)
struct stat path_stat;
int path_exists = 1;
- if (stat(path, &path_stat) < 0) {
+ if (lstat(path, &path_stat) < 0) {
if (errno != ENOENT) {
perror_msg("unable to stat `%s'", path);
return -1;
@@ -110,6 +110,7 @@ extern int remove_file(const char *path, int flags)
return status;
} else {
if ((!(flags & FILEUTILS_FORCE) && access(path, W_OK) < 0 &&
+ !S_ISLNK(path_stat.st_mode) &&
isatty(0)) ||
(flags & FILEUTILS_INTERACTIVE)) {
fprintf(stderr, "%s: remove `%s'? ", applet_name, path);