From owner-freebsd-bugs@FreeBSD.ORG Fri Aug 5 03:30:21 2005 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D98D716A41F for ; Fri, 5 Aug 2005 03:30:21 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id C3CF943D49 for ; Fri, 5 Aug 2005 03:30:20 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.3/8.13.3) with ESMTP id j753UKHA083402 for ; Fri, 5 Aug 2005 03:30:20 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.3/8.13.1/Submit) id j753UKuc083401; Fri, 5 Aug 2005 03:30:20 GMT (envelope-from gnats) Resent-Date: Fri, 5 Aug 2005 03:30:20 GMT Resent-Message-Id: <200508050330.j753UKuc083401@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Igor Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0640616A41F for ; Fri, 5 Aug 2005 03:29:12 +0000 (GMT) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [216.136.204.117]) by mx1.FreeBSD.org (Postfix) with ESMTP id 70F4D43D46 for ; Fri, 5 Aug 2005 03:29:11 +0000 (GMT) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.13.1/8.13.1) with ESMTP id j753TBRN042118 for ; Fri, 5 Aug 2005 03:29:11 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.13.1/8.13.1/Submit) id j753TB3N042115; Fri, 5 Aug 2005 03:29:11 GMT (envelope-from nobody) Message-Id: <200508050329.j753TB3N042115@www.freebsd.org> Date: Fri, 5 Aug 2005 03:29:11 GMT From: Igor To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-2.3 Cc: Subject: bin/84569: rm -W sometime does not work X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Aug 2005 03:30:22 -0000 >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: