changeset 746:5caa4035c1c8

essat's flag not to follow symlinks isn't in the system call, and if libc is supposed to implement this as a wrapper uClibc gets it wrong. So use the stat info about symlinks instead. (Doesn't check the parent directory, but if that's read only we can't delete the file anyway so prompting is moot.)
author Rob Landley <rob@landley.net>
date Mon, 10 Dec 2012 01:48:02 -0600
parents 0faab963ea92
children 68d6c1ce7bba
files toys/posix/rm.c
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/toys/posix/rm.c	Sun Dec 09 13:57:04 2012 -0600
+++ b/toys/posix/rm.c	Mon Dec 10 01:48:02 2012 -0600
@@ -35,8 +35,8 @@
   if (dir && !(flags & (FLAG_r|FLAG_R))) goto skip;
 
   // This is either the posix section 2(b) prompt or the section 3 prompt.
-  if (!(flags & FLAG_f) && faccessat(fd, try->name, W_OK, AT_SYMLINK_NOFOLLOW))
-    or++;
+  if (!(flags & FLAG_f)
+    && (!S_ISLNK(try->st.st_mode) && faccessat(fd, try->name, W_OK, 0))) or++;
   if (!(dir && try->data == -1) && ((or && isatty(0)) || (flags & FLAG_i))) {
     char *s = dirtree_path(try, 0);
     fprintf(stderr, "rm %s%s", or ? "ro " : "", dir ? "dir " : "");