Re: XFS reports lchmod failure, but changes file system contents

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Feb 12, 2020 at 09:01:22PM +0100, Florian Weimer wrote:
> * Al Viro:
> 
> > On Wed, Feb 12, 2020 at 08:15:08PM +0100, Florian Weimer wrote:
> >
> >> | Further, I've found some inconsistent behavior with ext4: chmod on the
> >> | magic symlink fails with EOPNOTSUPP as in Florian's test, but fchmod
> >> | on the O_PATH fd succeeds and changes the symlink mode. This is with
> >> | 5.4. Cany anyone else confirm this? Is it a problem?
> >> 
> >> It looks broken to me because fchmod (as an inode-changing operation)
> >> is not supposed to work on O_PATH descriptors.
> >
> > Why?  O_PATH does have an associated inode just fine; where does
> > that "not supposed to" come from?
> 
> It fails on most file systems right now.  I thought that was expected.
> Other system calls (fsetxattr IIRC) do not work on O_PATH descriptors,
> either.  I assumed that an O_PATH descriptor was not intending to
> confer that capability.  Even openat fails.
> 
> Although fchmod does succeed on read-only descriptors, which is a bit
> strange.

That's intentional and as-specified (and matches all historical
practice):

  "The fchmod() function shall be equivalent to chmod() except that
  the file whose permissions are changed is specified by the file
  descriptor fildes."

And chmod is specified as:

  "The application shall ensure that the effective user ID of the
  process matches the owner of the file or the process has appropriate
  privileges in order to do this."

No alternate behavior regarding permissions is specified; ability to
operate on the file does not depend on the open file mode.

Rich



[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux