Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 5 Aug 2005 03:29:11 GMT
From:      Igor <igor@ispsystem.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   bin/84569: rm -W sometime does not work
Message-ID:  <200508050329.j753TB3N042115@www.freebsd.org>
Resent-Message-ID: <200508050330.j753UKuc083401@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         84569
>Category:       bin
>Synopsis:       rm -W sometime does not work
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Aug 05 03:30:20 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator:     Igor
>Release:        FreeBSD-5.4
>Organization:
ISPsystem
>Environment:
root@dev-5# uname -a                                                                                                    
FreeBSD dev-5.ispsystem.net 5.4-STABLE FreeBSD 5.4-STABLE #20: Fri Aug  5 04:35:25 CEST 2005     root@dev-5.ispsystem.ne
t:/root/src/sys/i386/compile/ISPSYSTEM  i386                                                                            
>Description:
rm -W does not work sometime

test# ls -lW
w---------   0 root  wheel         0 Jan  1  1970 amd.map 
      
test# rm -W amd.map                   
rm: amd.map: No such file or directory


>How-To-Repeat:
no way, but please see rm.c code and may find variable 'struct stat st' is not inialized if Wflag is set, then the utility checks uninitialized sb.st_flags to make some actions which cause error.
>Fix:
there is 2 ways:
1. to initialize sb stucture by zero
--- rm.c.orig   Fri Aug  5 05:06:29 2005                             
+++ rm.c        Fri Aug  5 05:25:03 2005                             
@@ -318,6 +318,7 @@                                                  
                /* Assume if can't stat the file, can't unlink it. */
                if (lstat(f, &sb)) {                                 
                        if (Wflag) {                                 
+                               bzero(&sb, sizeof(sb));              
                                sb.st_mode = S_IFWHT|S_IWUSR|S_IRUSR;
                        } else {                                     
                                if (!fflag || errno != ENOENT) {    

 
2. to add checks of WHT flag before doing chflags
--- rm.c.orig   Fri Aug  5 05:06:29 2005                                           
+++ rm.c        Fri Aug  5 05:19:18 2005                                           
@@ -340,7 +340,7 @@                                                                
                if (!fflag && !S_ISWHT(sb.st_mode) && !check(f, f, &sb))           
                        continue;                                                  
                rval = 0;                                                          
-               if (!uid &&                                                        
+               if (!S_ISWHT(sb.st_mode) && !uid &&                                
                    (sb.st_flags & (UF_APPEND|UF_IMMUTABLE)) &&                    
                    !(sb.st_flags & (SF_APPEND|SF_IMMUTABLE)))                     
                        rval = chflags(f, sb.st_flags & ~(UF_APPEND|UF_IMMUTABLE));
>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200508050329.j753TB3N042115>