From owner-freebsd-bugs Sat Jul 20 0:10:12 2002 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 DC5B637B400 for ; Sat, 20 Jul 2002 00:10:06 -0700 (PDT) Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 477AE43E65 for ; Sat, 20 Jul 2002 00:10:06 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.4/8.12.4) with ESMTP id g6K7A5JU044426 for ; Sat, 20 Jul 2002 00:10:06 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.4/8.12.4/Submit) id g6K7A5pL044425; Sat, 20 Jul 2002 00:10:05 -0700 (PDT) Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DA0E837B400 for ; Sat, 20 Jul 2002 00:06:00 -0700 (PDT) Received: from www.freebsd.org (www.FreeBSD.org [216.136.204.117]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9EBE843E64 for ; Sat, 20 Jul 2002 00:06:00 -0700 (PDT) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.12.4/8.12.4) with ESMTP id g6K760OT016596 for ; Sat, 20 Jul 2002 00:06:00 -0700 (PDT) (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.12.4/8.12.4/Submit) id g6K760mE016595; Sat, 20 Jul 2002 00:06:00 -0700 (PDT) Message-Id: <200207200706.g6K760mE016595@www.freebsd.org> Date: Sat, 20 Jul 2002 00:06:00 -0700 (PDT) From: Landon Fuller To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-1.0 Subject: bin/40801: touch(1) attempts to open a directory O_RDWR 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: 40801 >Category: bin >Synopsis: touch(1) attempts to open a directory O_RDWR >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: Sat Jul 20 00:10:05 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Landon Fuller >Release: FreeBSD 4.5-RELEASE i386 >Organization: Apple Computer, Inc >Environment: FreeBSD machine.apple.com 4.5-RELEASE FreeBSD 4.5-RELEASE #0: Mon Jan 28 14:31:56 GMT 2002 murray@builder.freebsdmall.com:/usr/src/sys/compile/GENERIC i386 >Description: touch attempts to open directories O_RDWR in a last ditch effort to update the the directories' modification time. This results in the following: > touch /etc touch: /etc: Is a directory Should be: touch /etc touch: /etc: Permission denied >How-To-Repeat: 'touch' a directory to which you not have write permission >Fix: http://public.boredom.org/~swift/code/touch.diff Index: touch.c =================================================================== RCS file: /home/ncvs/src/usr.bin/touch/touch.c,v retrieving revision 1.16 diff -u -d -w -b -r1.16 touch.c --- touch.c 2002/03/22 01:42:36 1.16 +++ touch.c 2002/07/20 06:58:22 @@ -186,8 +186,11 @@ continue; /* Try reading/writing. */ - if (rw(*argv, &sb, fflag)) + if (!S_ISLNK(sb.st_mode) && !S_ISDIR(sb.st_mode) && + rw(*argv, &sb, fflag)) rval = 1; + else + warn("%s", *argv); } exit(rval); } @@ -312,8 +315,8 @@ int fd, needed_chmod, rval; u_char byte; - /* Try regular files and directories. */ - if (!S_ISREG(sbp->st_mode) && !S_ISDIR(sbp->st_mode)) { + /* Try regular files. */ + if (!S_ISREG(sbp->st_mode)) { warnx("%s: %s", fname, strerror(EFTYPE)); return (1); } >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message