summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2004-08-09 23:34:49 +0000
committerPaul Eggert <eggert@cs.ucla.edu>2004-08-09 23:34:49 +0000
commit1def589bea0974dc92183b99efc18545c8f88c33 (patch)
treeb938a7029a580931372629ec97e367dd2ce23dd0
parente077b28593c58a1d1215d234740e5688de8f48d5 (diff)
downloadcoreutils-1def589bea0974dc92183b99efc18545c8f88c33.tar.xz
(wipename): Work even if the directory is writeable
and not readable. Prefer write access, since this should work better with fdatasync.
-rw-r--r--src/shred.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/shred.c b/src/shred.c
index 4d3b18d5e..d9da0bb7b 100644
--- a/src/shred.c
+++ b/src/shred.c
@@ -1434,10 +1434,13 @@ wipename (char *oldname, char const *qoldname, struct Options const *flags)
size_t len = base_len (base);
char *dir = dir_name (newname);
char *qdir = xstrdup (quotearg_colon (dir));
- int dir_fd = open (dir, O_RDONLY | O_NOCTTY);
bool first = true;
bool ok = true;
+ int dir_fd = open (dir, O_WRONLY | O_NOCTTY);
+ if (dir_fd < 0)
+ dir_fd = open (dir, O_RDONLY | O_NOCTTY);
+
if (flags->verbose)
error (0, 0, _("%s: removing"), qoldname);