mailing list of musl libc
 help / color / mirror / code / Atom feed
* lchmod on Linux
@ 2015-08-26 19:12 Tomasz Sterna
  2015-08-26 19:49 ` Rich Felker
  0 siblings, 1 reply; 5+ messages in thread
From: Tomasz Sterna @ 2015-08-26 19:12 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 613 bytes --]

I think there is an issue with musl providing lchmod() implementation
on Linux.

It simply proxies to fchmodat(), but as you cannot change mod for
symlink on Linux it fails.

This gives trouble to libarchive's bsdtar implementation that detects
that platform provides lchmod, tries to use it while extracting
archives containing symlinks and fails... ;-(

For now I am just patching libarchive config.h to not use lchmod, but I
would rather see musl do the right thing. :-)


-- 
 /o__ Our missions are peaceful -- not for conquest. When we do battle, it
(_<^' is only because we have no choice.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: lchmod on Linux
  2015-08-26 19:12 lchmod on Linux Tomasz Sterna
@ 2015-08-26 19:49 ` Rich Felker
  2015-08-26 21:09   ` Tomasz Sterna
  0 siblings, 1 reply; 5+ messages in thread
From: Rich Felker @ 2015-08-26 19:49 UTC (permalink / raw)
  To: musl

On Wed, Aug 26, 2015 at 09:12:30PM +0200, Tomasz Sterna wrote:
> I think there is an issue with musl providing lchmod() implementation
> on Linux.
> 
> It simply proxies to fchmodat(), but as you cannot change mod for
> symlink on Linux it fails.
> 
> This gives trouble to libarchive's bsdtar implementation that detects
> that platform provides lchmod, tries to use it while extracting
> archives containing symlinks and fails... ;-(
> 
> For now I am just patching libarchive config.h to not use lchmod, but I
> would rather see musl do the right thing. :-)

This issue (the useless lchmod) was raised once before, a long time
ago. But there's not really anything that can be done about it since
there are existing binaries referencing it.

But conceptually, the same issue would exist if libarchive were using
the fchmodat function rather than lchmod. So it seems to me that the
problem is not the existence of an operation that always-fails, but
rather libarchive's misinterpretation of the result. EOPNOTSUP is a
documented result for fchmodat, and generally programs should not
treat it as an error but should just ignore it. The same should
probably be done for lchmod.

Rich


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: lchmod on Linux
  2015-08-26 19:49 ` Rich Felker
@ 2015-08-26 21:09   ` Tomasz Sterna
  2015-08-26 22:02     ` Laurent Bercot
  0 siblings, 1 reply; 5+ messages in thread
From: Tomasz Sterna @ 2015-08-26 21:09 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 1064 bytes --]

Dnia 2015-08-26, śro o godzinie 15:49 -0400, Rich Felker pisze:
> This issue (the useless lchmod) was raised once before, a long time
> ago. But there's not really anything that can be done about it since
> there are existing binaries referencing it.

One thing could be always returning 0, as this is really a no-op on
Linux.


> But conceptually, the same issue would exist if libarchive were using
> the fchmodat function rather than lchmod.

Well... fchmodat is a different function and you might expect it
failing.
But since a platform _is_ providing lchmod one should not expect it to
return not-supported when used on a symlink.
It would give me a serious WTF reading a code that uses a platform
supported function and checking for not-supported error. ;-)


> EOPNOTSUP is a documented result for fchmodat, [...]

Is it a documented result for lchmod? (Google is no help here.)
(If yes, I will die a little and just move on ;-)


-- 
 /o__ Q: Why did the astrophysicist order three hamburgers?
(_<^' A: Because he was hungry.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: lchmod on Linux
  2015-08-26 21:09   ` Tomasz Sterna
@ 2015-08-26 22:02     ` Laurent Bercot
  2015-08-27  1:39       ` Rich Felker
  0 siblings, 1 reply; 5+ messages in thread
From: Laurent Bercot @ 2015-08-26 22:02 UTC (permalink / raw)
  To: musl

On 26/08/2015 23:09, Tomasz Sterna wrote:
> One thing could be always returning 0, as this is really a no-op on
> Linux.

  I tend to agree with that.
  https://www.freebsd.org/cgi/man.cgi?query=lchmod&sektion=2  does not
describe EOPNOTSUPP as a possible error code. Is there a reason not
to make lchmod return 0 when the underlying fchmodat returns
-1 EOPNOTSUPP?


>> EOPNOTSUP is a documented result for fchmodat, [...]
> Is it a documented result for lchmod? (Google is no help here.)

  Not according to the FreeBSD doc.
  The thing is, lchmod() is not POSIX, it's only BSD (I could find
doc for FreeBSD and MacOS X); the best behaviour is not to use it
at all. What libarchive should really do is to replace lchmod() with
fchmodat() and explicitly test for EOPNOTSUPP.

-- 
  Laurent



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: lchmod on Linux
  2015-08-26 22:02     ` Laurent Bercot
@ 2015-08-27  1:39       ` Rich Felker
  0 siblings, 0 replies; 5+ messages in thread
From: Rich Felker @ 2015-08-27  1:39 UTC (permalink / raw)
  To: musl

On Thu, Aug 27, 2015 at 12:02:41AM +0200, Laurent Bercot wrote:
> On 26/08/2015 23:09, Tomasz Sterna wrote:
> >One thing could be always returning 0, as this is really a no-op on
> >Linux.
> 
>  I tend to agree with that.
>  https://www.freebsd.org/cgi/man.cgi?query=lchmod&sektion=2  does not
> describe EOPNOTSUPP as a possible error code. Is there a reason not
> to make lchmod return 0 when the underlying fchmodat returns
> -1 EOPNOTSUPP?

Conceptually I think it's wrong to return 0 when the operation wasn't
performed. There's also an argument to be made that lchmod should be
equivalent to the corresponding fchmodat call; if it were ever
standardized, it almost certainly would be. If there were a strong
compatibility benefit to be had by making it return 0 despite these
things, that would certainly be worth weighing in on, but I don't
think there is any such issue. There are very few users of lchown, and
IIRC the other ones we've found handle it fine already.

> >>EOPNOTSUP is a documented result for fchmodat, [...]
> >Is it a documented result for lchmod? (Google is no help here.)
> 
>  Not according to the FreeBSD doc.
>  The thing is, lchmod() is not POSIX, it's only BSD (I could find
> doc for FreeBSD and MacOS X); the best behaviour is not to use it
> at all. What libarchive should really do is to replace lchmod() with
> fchmodat() and explicitly test for EOPNOTSUPP.

I agree entirely with this. lchown should not be used at all if
fchmodat is supported, since the latter has standardized behavior you
can rely upon. Can we just propose a patch to libarchive to use
fchmodat when it exists and properly check for EOPNOTSUPP?

Rich


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-08-27  1:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-26 19:12 lchmod on Linux Tomasz Sterna
2015-08-26 19:49 ` Rich Felker
2015-08-26 21:09   ` Tomasz Sterna
2015-08-26 22:02     ` Laurent Bercot
2015-08-27  1:39       ` Rich Felker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).