bin/88365 : [patch] rm(1): "/bin/rm -P" cannot remove files not writeable by user while "/bin/rm" can

vaidab vaidab at phenix.rootshell.be
Sun Nov 6 01:20:22 PST 2005


The following reply was made to PR bin/88365; it has been noted by GNATS.

From: vaidab <vaidab at phenix.rootshell.be>
To: bug-followup at FreeBSD.org
Cc: vaida.bogdan at gmail.com
Subject: Re: bin/88365 : [patch] rm(1): "/bin/rm -P" cannot remove files not
 writeable by user while "/bin/rm" can
Date: Sun, 6 Nov 2005 10:14:07 +0100 (CET)

 I'm submitting the patch again. mx1.freebsd.org rejects me as I don't have 
 a hostname and my send-pr are sent via email
 
 > Fix:
 
 --- /usr/src/bin/rm/rm.c.orig	Thu Nov  3 21:19:47 2005
 +++ /usr/src/bin/rm/rm.c	Thu Nov  3 21:20:42 2005
 @@ -393,6 +393,8 @@
   	}
   	if (!S_ISREG(sbp->st_mode))
   		return (1);
 +	if (lchmod(file, S_IWUSR) == -1)
 +		goto err;
   	if ((fd = open(file, O_WRONLY, 0)) == -1)
   		goto err;
   	if (fstatfs(fd, &fsb) == -1)
 @@ -450,7 +452,7 @@
   		 * we will not be able to overwrite file contents and will
   		 * barf later.
   		 */
 -		if (!stdin_ok || S_ISLNK(sp->st_mode) || Pflag ||
 +		if (!stdin_ok || S_ISLNK(sp->st_mode) ||
   		    (!access(name, W_OK) &&
   		    !(sp->st_flags & (SF_APPEND|SF_IMMUTABLE)) &&
   		    (!(sp->st_flags & (UF_APPEND|UF_IMMUTABLE)) || !uid)))


More information about the freebsd-bugs mailing list