From owner-freebsd-bugs Sun Jun 2 2:42:46 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 98D8F37B41E for ; Sun, 2 Jun 2002 02:40:15 -0700 (PDT) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g529eED56978; Sun, 2 Jun 2002 02:40:14 -0700 (PDT) (envelope-from gnats) Received: from nwww.freebsd.org (www.FreeBSD.org [216.136.204.117]) by hub.freebsd.org (Postfix) with ESMTP id 0A5FB37B404 for ; Sat, 1 Jun 2002 21:31:33 -0700 (PDT) Received: from www.freebsd.org (localhost [127.0.0.1]) by nwww.freebsd.org (8.12.2/8.12.2) with ESMTP id g524VWhG061180 for ; Sat, 1 Jun 2002 21:31:32 -0700 (PDT) (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.12.2/8.12.2/Submit) id g524VWgS061179; Sat, 1 Jun 2002 21:31:32 -0700 (PDT) Message-Id: <200206020431.g524VWgS061179@www.freebsd.org> Date: Sat, 1 Jun 2002 21:31:32 -0700 (PDT) From: Pat Young To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-1.0 Subject: bin/38818: if [ -w filename ] incorrectly returns results when run as root and testing non-writeable files. Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 38818 >Category: bin >Synopsis: if [ -w filename ] incorrectly returns results when run as root and testing non-writeable files. >Confidential: no >Severity: serious >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sun Jun 02 02:40:14 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Pat Young >Release: 4.6-RC >Organization: NetLedger, Inc. >Environment: FreeBSD beast.netledger.com 4.6-RC FreeBSD 4.6-RC #8: Thu May 16 23:34:27 PDT 2002 xdice@beast.netledger.com:/usr/obj/usr/src/sys/BEAST i386 >Description: While writing a small shell script to test to see if a file was writable, I found that when running the script as root, and incorrect result was returned. As a normal user, the script works. As root, however, even testing a file that is chmod 400 results in an incorrect test. I've tested with with bash from ports, and /bin/sh - same behavior. Linux fails in the same fashion, but Solaris works just fine (returns the expected result, which would be nothing.), regardless of shell. >How-To-Repeat: # if [ -w netsaintize ] > then > ls -l netsaintize > fi -r-------- 1 root wheel 0 Jun 1 21:02 netsaintize # >Fix: >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message