Re: chown(2) vs lchown(2) and application breakage

Richard Gooch (Richard.Gooch@atnf.CSIRO.AU)
Tue, 26 May 1998 10:26:29 +1000


Anders Hammarquist writes:
> A few patch levels ago we were blessed with a lchown() syscall and chown()
> started following symlinks (until that time chown() had really been an
> lchown()). On the x86 and m68k (at least) lchown() eventually received the
> same syscall number (16) as the old chown() and the new chown() got a new
> syscall number. On the alpha, chown() is still 16 and lchown() is "new" (I
> suspect this has to do with wanting to remain compatible with Digital
> Unix).
>
> For the past few days we've been having a discussion of what's right and
> how to fix it on Debian's alpha port list (start reading at
> http://www.debian.org/Lists-Archives/debian-alpha-9805/msg00060.html if
> you are interested).
>
> >From what I can see, the semantics change only affects programs that
> expect chown() to act as lchown() (very few, but unfortunately the Debian
> package tool dpkg is one of them). The syscall number change that has been
> used on i386 and m68k only fix it for a libc that does not know about the
> new lchown(), binaries that break with unchanged syscall numbers as on the
> alpha will break on i386 and m68k when libc is recompiled with the new
> syscall numbers.
>
> This needs fixing (though exactly how may not be immediately obvious). To
> me, any application that expects lchown() behaviour should call lchown().
> Unfortunately this alone is not enough, since lchown() will fail with
> ENOSYS on some architectures for kernels < 2.1.8x, so libc (or the
> applications) need to call chown() iff lchown() fail with ENOSYS (I not
> sure where would be cleanest, but I leaning towards libc).
>
> On a related note, chown() will fail with ENOSYS with a libc compiled for >
> 2.1.8x on a kernel < 2.1.8x for those architectures that changed syscall
> numbers unless it is handled in libc. Perhaps I should advocate that the
> numbers be changed back? :-)

I agree with you: syscall #16 should be chown(). However, my complaint
about this was ignored in the name of "compatibility". In this
context, "compatibility" meant "compatibility with old versions of
Linux", not "compatibility with POSIX". I encourage you to push for
this to be fixed: syscall #16 should follow symlinks. Binaries that
break were relying on Linux's non-POSIX behaviour, so I don't have
much sympathy.

Anyway, for i386 I've written a patch for libc 5.4.44 which I sent to
H.J. last night. This patch creates the lchown() syscall interface and
implements a chown() function which uses syscall #182 if available,
otherwise falls back to syscall #16. So if we can't get the kernel
fixed, this patch is the next best thing.

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