Author vstinner
Recipients Anthony Sottile, pitrou, vstinner
Date 2017-11-07.00:35:43
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1510014943.46.0.213398074469.issue31940@psf.upfronthosting.co.za>
In-reply-to
Content
If lchmod() fails with [Errno 95] Not supported, IMHO chmod(path, mode, follow_symlinks=False) should behaves as lchmod() doesn't exist and falls back to the next case, as if HAVE_LCHMOD wasn't defined, but implement such falls back at runtime.

So the "broken" lchmod() issue should be fixed a multiple places:

* os.lchmod()
* os.chmod()
* shutil.copymode()
* pathlib.Path.lchmod()

Oh wow, this issue impacts much more functions than what I expected.

Maybe the compromise of a configure check avoids to overengineer this issue :-)

Antoine: What do you think? Should we check if lchmod() works in configure (as already implemented in the PR 4267), or implement a runtime check as I proposed.


pathlib has an interesting long comment:

    # Some platforms don't support lchmod().  Often the function exists
    # anyway, as a stub that always returns ENOSUP or perhaps EOPNOTSUPP.
    # (No, I don't know why that's a good design.)  ./configure will detect
    # this and reject it--so HAVE_LCHMOD still won't be defined on such
    # platforms.  This is Very Helpful.
    #
    # However, sometimes platforms without a working lchmod() *do* have
    # fchmodat().  (Examples: Linux kernel 3.2 with glibc 2.15,
    # OpenIndiana 3.x.)  And fchmodat() has a flag that theoretically makes
    # it behave like lchmod().  So in theory it would be a suitable
    # replacement for lchmod().  But when lchmod() doesn't work, fchmodat()'s
    # flag doesn't work *either*.  Sadly ./configure isn't sophisticated
    # enough to detect this condition--it only determines whether or not
    # fchmodat() minimally works.
    #
    # Therefore we simply ignore fchmodat() when deciding whether or not
    # os.chmod supports follow_symlinks.  Just checking lchmod() is
    # sufficient.  After all--if you have a working fchmodat(), your
    # lchmod() almost certainly works too.
    #
    # _add("HAVE_FCHMODAT",   "chmod")
    _add("HAVE_FCHOWNAT",   "chown")
History
Date User Action Args
2017-11-07 00:35:43vstinnersetrecipients: + vstinner, pitrou, Anthony Sottile
2017-11-07 00:35:43vstinnersetmessageid: <1510014943.46.0.213398074469.issue31940@psf.upfronthosting.co.za>
2017-11-07 00:35:43vstinnerlinkissue31940 messages
2017-11-07 00:35:43vstinnercreate