From owner-freebsd-bugs@FreeBSD.ORG Mon Feb 23 07:30:04 2009 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EF7C6106564A for ; Mon, 23 Feb 2009 07:30:04 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 97B028FC0A for ; Mon, 23 Feb 2009 07:30:04 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id n1N7U45f078516 for ; Mon, 23 Feb 2009 07:30:04 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id n1N7U41t078507; Mon, 23 Feb 2009 07:30:04 GMT (envelope-from gnats) Resent-Date: Mon, 23 Feb 2009 07:30:04 GMT Resent-Message-Id: <200902230730.n1N7U41t078507@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, Deomid Ryabkov Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DC9931065678 for ; Mon, 23 Feb 2009 07:25:27 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id 9465A8FC16 for ; Mon, 23 Feb 2009 07:25:27 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id n1N7PQUB023380 for ; Mon, 23 Feb 2009 07:25:26 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id n1N7PQN7023379; Mon, 23 Feb 2009 07:25:26 GMT (envelope-from nobody) Message-Id: <200902230725.n1N7PQN7023379@www.freebsd.org> Date: Mon, 23 Feb 2009 07:25:26 GMT From: Deomid Ryabkov To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: misc/131999: chflags: unable to unset flags on symlinks when link target exists 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: Mon, 23 Feb 2009 07:30:05 -0000 >Number: 131999 >Category: misc >Synopsis: chflags: unable to unset flags on symlinks when link target exists >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: Mon Feb 23 07:30:03 UTC 2009 >Closed-Date: >Last-Modified: >Originator: Deomid Ryabkov >Release: 7.1-PRERELEASE #0: Mon Sep 8 14:15:33 MSD 2008 >Organization: >Environment: FreeBSD xxx 7.1-PRERELEASE FreeBSD 7.1-PRERELEASE #0: Mon Sep 8 14:15:33 MSD 2008 rojer@xxx:/usr/obj/usr/src/sys/GENERIC amd64 >Description: # ls -lo logs lrwxr-xr-x 1 root www-rojer schg 17 Sep 16 2006 logs -> /logs/rojer # ls -ldo /logs/rojer drwxr-x--- 2 root www-rojer - 512 Feb 23 09:59 /logs/rojer # chflags -h noschg logs # ls -lo logs lrwxr-xr-x 1 root www-rojer schg 17 Sep 16 2006 logs -> /logs/rojer.pp.ru i. e. nothing happened truss of chflags reveals the problem: usage of stat() where lstat() should have been used. # truss chflags -h noschg logs [...] stat("logs",{ mode=drwxr-x--- ,inode=22303757,size=512,blksize=4096 }) = 0 (0x0) process exit, rval = 0 this way, lchflags(2) is never actually called because chflags(3) doesn't think it is necessary. >How-To-Repeat: create a symlink pointing to an existing flagless entry (this is important), use chfalgs -h to set flags on the symlink - this one succeeds. then try chflags -h to remove the flag you just set - this one fails, because stat(2) returns information on the entry symlink points at that does not have the flag. >Fix: i had a glance at bin/chflags/chflags.c and it seems to be using fts_* functions to traverse the tree. somehow those need to be told to use lstat to return information, when appropriate. >Release-Note: >Audit-Trail: >Unformatted: