Date: Tue, 24 Feb 2009 17:19:17 +1100 (EST) From: Bruce Evans <brde@optusnet.com.au> To: Deomid Ryabkov <myself@rojer.pp.ru> Cc: freebsd-bugs@freebsd.org, freebsd-gnats-submit@freebsd.org Subject: Re: misc/131999: chflags: unable to unset flags on symlinks when link target exists Message-ID: <20090224170808.K10627@delplex.bde.org> In-Reply-To: <200902230725.n1N7PQN7023379@www.freebsd.org> References: <200902230725.n1N7PQN7023379@www.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 23 Feb 2009, Deomid Ryabkov wrote: >> Synopsis: chflags: unable to unset flags on symlinks when link target exists Also, setting only works accidentally in some cases. > 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. And for chflags -h schg logs, lchflags() is only called because the wrong flags returned by stat() happen to have their schg bit clear. If the schg bit were set in the symlink target, then this chflags would do nothing too. >> 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. Setting FTS_PHYSICAL seems to fix it: % Index: chflags.c % =================================================================== % RCS file: /home/ncvs/src/bin/chflags/chflags.c,v % retrieving revision 1.24 % diff -u -2 -r1.24 chflags.c % --- chflags.c 9 Mar 2008 12:10:24 -0000 1.24 % +++ chflags.c 24 Feb 2009 06:13:00 -0000 % @@ -115,5 +115,7 @@ % fts_options |= FTS_LOGICAL; % } % - } else % + } else if (hflag) % + fts_options = FTS_PHYSICAL; % + else % fts_options = FTS_LOGICAL; % Bruce
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090224170808.K10627>