[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] fchmodat, lchmod: port to buggy Linux filesystems
From: |
Bruno Haible |
Subject: |
Re: [PATCH] fchmodat, lchmod: port to buggy Linux filesystems |
Date: |
Sun, 16 Feb 2020 22:38:58 +0100 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-171-generic; KDE/5.18.0; x86_64; ; ) |
Paul Eggert wrote:
> > 2) Also the discussion what is the "right" behaviour is specific to Linux.
> > The code in the '#else' case
> >
> > if (S_ISLNK (st.st_mode))
> > {
> > close (fd);
> > errno = EOPNOTSUPP;
> > return -1;
> > }
> >
> > will surely upset users on BSD systems, where symlinks are intended to have
> > permission bits.
>
> Because of the Autoconf tests, that code should be executed only on
> platforms where lchmod fails (or does not exist), whould shouldn't occur
> on BSD systems.
Unfortunately, it doesn't: The line in the module description
lib_SOURCES += lchmod.c
causes lchmod.c to be compiled (to a .o file that defines 'lchmod', not
even 'rpl_lchmod'!) on macOS, FreeBSD, NetBSD, etc.
> Still, I take your point that the code is confusing.
> Perhaps lchmod.m4 and fchmodat.m4 should define a symbol
> HAVE_LCHMOD_BUG_WITH_NON_SYMLINKS and the C code could refer to that.
> The resulting machine code would be the same as now, but the
> cause-and-effect would be clearer.
Yes, I agree. Let me do this. Also I'm adding more comments. This patch
is tested on all platforms that have an lchown() function.
Before:
HAVE_LCHMOD REPLACE_LCHMOD nm lchmod.o nm fchmodat.o
glibc/Linux 0 0 rpl_fchmodat
fchmodat,openat,chmod,...
macOS 1 0 rpl_lstat,chmod
save_cwd,chmod,lchmod,...
HP-UX 1 0 rpl_lstat,chmod
save_cwd,chmod,lchmod,...
musl/Linux 1 0 fchmodat --
glibc/Hurd 1 0 fchmodat --
glibc/kFreeBSD 1 0 fchmodat --
FreeBSD 1 0 fchmodat --
NetBSD 1 0 fchmodat --
After:
HAVE_LCHMOD REPLACE_LCHMOD nm lchmod.o nm fchmodat.o
glibc/Linux 0 0 rpl_fchmodat
fchmodat,openat,chmod,...
macOS 1 0 --
save_cwd,chmod,lchmod,...
HP-UX 1 0 --
save_cwd,chmod,lchmod,...
musl/Linux 1 0 -- --
glibc/Hurd 1 0 -- --
glibc/kFreeBSD 1 0 -- --
FreeBSD 1 0 -- --
NetBSD 1 0 -- --
2020-02-16 Bruno Haible <address@hidden>
lchmod: Make more future-proof.
* m4/lchmod.m4 (gl_FUNC_LCHMOD): Define NEED_LCHMOD_NONSYMLINK_FIX.
(gl_PREREQ_LCHMOD): New macro.
* lib/lchmod.c (orig_lchmod): New function.
(lchmod): Test NEED_LCHMOD_NONSYMLINK_FIX. Access /proc only on Linux.
Return EOPNOTSUPP only on Linux and on platforms without lchmod
function.
* modules/lchmod (configure.ac): Invoke gl_PREREQ_LCHMOD.
lchmod: Fix buggy override on macOS, HP-UX (regression from 2020-02-08).
* modules/lchmod (Makefile.am): Don't add lchmod.c to lib_SOURCES.
0001-lchmod-Fix-buggy-override-on-macOS-HP-UX-regression-.patch
Description: Text Data
0002-lchmod-Make-more-future-proof.patch
Description: Text Data
- [PATCH] fchmodat, lchmod: port to buggy Linux filesystems, Paul Eggert, 2020/02/13
- Re: [PATCH] fchmodat, lchmod: port to buggy Linux filesystems, Bruno Haible, 2020/02/13
- Re: [PATCH] fchmodat, lchmod: port to buggy Linux filesystems, Bruno Haible, 2020/02/13
- Re: [PATCH] fchmodat, lchmod: port to buggy Linux filesystems, Paul Eggert, 2020/02/14
- Re: [PATCH] fchmodat, lchmod: port to buggy Linux filesystems,
Bruno Haible <=
- Re: [PATCH] fchmodat, lchmod: port to buggy Linux filesystems, Bruno Haible, 2020/02/16
- Re: [PATCH] fchmodat, lchmod: port to buggy Linux filesystems, Bruno Haible, 2020/02/22
- Re: [PATCH] fchmodat, lchmod: port to buggy Linux filesystems, Paul Eggert, 2020/02/23
- Re: [PATCH] fchmodat, lchmod: port to buggy Linux filesystems, Bruno Haible, 2020/02/23
- Re: [PATCH] fchmodat, lchmod: port to buggy Linux filesystems, Paul Eggert, 2020/02/23
- Re: overriding glibc stub functions, Bruno Haible, 2020/02/23
- Re: overriding glibc stub functions, Paul Eggert, 2020/02/24
- Re: [PATCH] fchmodat, lchmod: port to buggy Linux filesystems, Bruno Haible, 2020/02/22