* [PATCH] chmodat, chownat: new modules
@ 2020-02-22 20:10 Paul Eggert
2020-02-22 22:47 ` Bruno Haible
0 siblings, 1 reply; 4+ messages in thread
From: Paul Eggert @ 2020-02-22 20:10 UTC (permalink / raw)
To: bug-gnulib; +Cc: Paul Eggert
These are split from fchmodat, fchownat. GNU Emacs needs the
POSIX-specified fchmodat, but not the gnulib-specified chmodat and
lchmodat. Split the latter two into a new module chmodat.
Similarly for fchownat. This the same basic idea for why statat
was split from fstatat on 2013-01-23.
* lib/chmodat.c, lib/openat.h (CHMODAT_INLINE):
Rename from FCHMODAT_INLINE. All uses changed.
* lib/chownat.c, lib/openat.h (CHOWNAT_INLINE):
Rename from FCHOWNAT_INLINE. All uses changed.
* lib/openat.h:
(chownat, lchownat): Define if GNULIB_CHOWNAT, not GNULIB_FCHOWNAT.
(chmodat, lchmodat): Define if GNULIB_CHMODAT, not GNULIB_FCHMODAT.
* modules/chmodat, modules/chownat, tests/test-chownat.c: New files.
* modules/fchmodat (Files:): Remove lib/fchmodat.c.
(configure.ac): Remove fchmodat module indicator.
(Makefile.am): Omit chmodat.c.
(Maintainer): Add self.
* modules/fchownat: Similarly, but for chown.
* tests/test-fchownat.c (BASE): Don't define if already defined.
(do_chown, do_lchown) [!TEST_CHOWNAT]: Test fchownat instead.
---
ChangeLog | 24 ++++++++++++++++++++++++
lib/chmodat.c | 2 +-
lib/chownat.c | 2 +-
lib/openat.h | 20 ++++++++++----------
modules/chmodat | 23 +++++++++++++++++++++++
modules/chownat | 23 +++++++++++++++++++++++
modules/fchmodat | 5 +----
modules/fchownat | 5 +----
tests/test-chownat.c | 27 +++++++++++++++++++++++++++
tests/test-fchownat.c | 12 +++++++++++-
10 files changed, 122 insertions(+), 21 deletions(-)
create mode 100644 modules/chmodat
create mode 100644 modules/chownat
create mode 100644 tests/test-chownat.c
diff --git a/ChangeLog b/ChangeLog
index e47bc36e9..5422529cc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,27 @@
+2020-02-22 Paul Eggert <eggert@cs.ucla.edu>
+
+ chmodat, chownat: new modules
+ These are split from fchmodat, fchownat. GNU Emacs needs the
+ POSIX-specified fchmodat, but not the gnulib-specified chmodat and
+ lchmodat. Split the latter two into a new module chmodat.
+ Similarly for fchownat. This the same basic idea for why statat
+ was split from fstatat on 2013-01-23.
+ * lib/chmodat.c, lib/openat.h (CHMODAT_INLINE):
+ Rename from FCHMODAT_INLINE. All uses changed.
+ * lib/chownat.c, lib/openat.h (CHOWNAT_INLINE):
+ Rename from FCHOWNAT_INLINE. All uses changed.
+ * lib/openat.h:
+ (chownat, lchownat): Define if GNULIB_CHOWNAT, not GNULIB_FCHOWNAT.
+ (chmodat, lchmodat): Define if GNULIB_CHMODAT, not GNULIB_FCHMODAT.
+ * modules/chmodat, modules/chownat, tests/test-chownat.c: New files.
+ * modules/fchmodat (Files:): Remove lib/fchmodat.c.
+ (configure.ac): Remove fchmodat module indicator.
+ (Makefile.am): Omit chmodat.c.
+ (Maintainer): Add self.
+ * modules/fchownat: Similarly, but for chown.
+ * tests/test-fchownat.c (BASE): Don't define if already defined.
+ (do_chown, do_lchown) [!TEST_CHOWNAT]: Test fchownat instead.
+
2020-02-22 Bruno Haible <bruno@clisp.org>
users.txt: Add groff.
diff --git a/lib/chmodat.c b/lib/chmodat.c
index 3c6968992..b496a809e 100644
--- a/lib/chmodat.c
+++ b/lib/chmodat.c
@@ -1,3 +1,3 @@
#include <config.h>
-#define FCHMODAT_INLINE _GL_EXTERN_INLINE
+#define CHMODAT_INLINE _GL_EXTERN_INLINE
#include "openat.h"
diff --git a/lib/chownat.c b/lib/chownat.c
index 3937f9c4f..698e96802 100644
--- a/lib/chownat.c
+++ b/lib/chownat.c
@@ -1,3 +1,3 @@
#include <config.h>
-#define FCHOWNAT_INLINE _GL_EXTERN_INLINE
+#define CHOWNAT_INLINE _GL_EXTERN_INLINE
#include "openat.h"
diff --git a/lib/openat.h b/lib/openat.h
index 7589150f3..824ce560e 100644
--- a/lib/openat.h
+++ b/lib/openat.h
@@ -52,19 +52,19 @@ _Noreturn void openat_save_fail (int);
slightly more readable than it would be with
fchownat (..., 0) or fchownat (..., AT_SYMLINK_NOFOLLOW). */
-#if GNULIB_FCHOWNAT
+#if GNULIB_CHOWNAT
-# ifndef FCHOWNAT_INLINE
-# define FCHOWNAT_INLINE _GL_INLINE
+# ifndef CHOWNAT_INLINE
+# define CHOWNAT_INLINE _GL_INLINE
# endif
-FCHOWNAT_INLINE int
+CHOWNAT_INLINE int
chownat (int fd, char const *file, uid_t owner, gid_t group)
{
return fchownat (fd, file, owner, group, 0);
}
-FCHOWNAT_INLINE int
+CHOWNAT_INLINE int
lchownat (int fd, char const *file, uid_t owner, gid_t group)
{
return fchownat (fd, file, owner, group, AT_SYMLINK_NOFOLLOW);
@@ -72,19 +72,19 @@ lchownat (int fd, char const *file, uid_t owner, gid_t group)
#endif
-#if GNULIB_FCHMODAT
+#if GNULIB_CHMODAT
-# ifndef FCHMODAT_INLINE
-# define FCHMODAT_INLINE _GL_INLINE
+# ifndef CHMODAT_INLINE
+# define CHMODAT_INLINE _GL_INLINE
# endif
-FCHMODAT_INLINE int
+CHMODAT_INLINE int
chmodat (int fd, char const *file, mode_t mode)
{
return fchmodat (fd, file, mode, 0);
}
-FCHMODAT_INLINE int
+CHMODAT_INLINE int
lchmodat (int fd, char const *file, mode_t mode)
{
return fchmodat (fd, file, mode, AT_SYMLINK_NOFOLLOW);
diff --git a/modules/chmodat b/modules/chmodat
new file mode 100644
index 000000000..b4dc230a0
--- /dev/null
+++ b/modules/chmodat
@@ -0,0 +1,23 @@
+Description:
+chmodat and lchmodat functions: Change access permissions of a file at a directory.
+
+Files:
+lib/chmodat.c
+
+Depends-on:
+fchmodat
+
+configure.ac:
+gl_MODULE_INDICATOR([chmodat]) dnl for lib/openat.h
+
+Makefile.am:
+lib_SOURCES += chmodat.c
+
+Include:
+"openat.h"
+
+License:
+GPL
+
+Maintainer:
+Jim Meyering, Eric Blake, Paul Eggert
diff --git a/modules/chownat b/modules/chownat
new file mode 100644
index 000000000..31b6bc0cc
--- /dev/null
+++ b/modules/chownat
@@ -0,0 +1,23 @@
+Description:
+chownat and lchownat functions: Change owner of a file at a directory.
+
+Files:
+lib/chownat.c
+
+Depends-on:
+fchownat
+
+configure.ac:
+gl_MODULE_INDICATOR([chownat]) dnl for lib/openat.h
+
+Makefile.am:
+lib_SOURCES += chownat.c
+
+Include:
+"openat.h"
+
+License:
+GPL
+
+Maintainer:
+Jim Meyering, Eric Blake, Paul Eggert
diff --git a/modules/fchmodat b/modules/fchmodat
index f0dac9dfe..aef184d9b 100644
--- a/modules/fchmodat
+++ b/modules/fchmodat
@@ -3,7 +3,6 @@ fchmodat() function: Change access permissions of a file at a directory.
Files:
lib/fchmodat.c
-lib/chmodat.c
lib/at-func.c
m4/fchmodat.m4
@@ -30,11 +29,9 @@ if test $HAVE_FCHMODAT = 0 || test $REPLACE_FCHMODAT = 1; then
AC_LIBOBJ([fchmodat])
gl_PREREQ_FCHMODAT
fi
-gl_MODULE_INDICATOR([fchmodat]) dnl for lib/openat.h
gl_SYS_STAT_MODULE_INDICATOR([fchmodat])
Makefile.am:
-lib_SOURCES += chmodat.c
Include:
<sys/stat.h>
@@ -43,4 +40,4 @@ License:
GPL
Maintainer:
-Jim Meyering, Eric Blake
+Jim Meyering, Eric Blake, Paul Eggert
diff --git a/modules/fchownat b/modules/fchownat
index 08fb75b12..d29d77eac 100644
--- a/modules/fchownat
+++ b/modules/fchownat
@@ -3,7 +3,6 @@ fchownat() function: Change the owner of a file at a directory.
Files:
lib/fchownat.c
-lib/chownat.c
lib/at-func.c
m4/fchownat.m4
@@ -27,11 +26,9 @@ gl_FUNC_FCHOWNAT
if test $HAVE_FCHOWNAT = 0 || test $REPLACE_FCHOWNAT = 1; then
AC_LIBOBJ([fchownat])
fi
-gl_MODULE_INDICATOR([fchownat]) dnl for lib/openat.h
gl_UNISTD_MODULE_INDICATOR([fchownat])
Makefile.am:
-lib_SOURCES += chownat.c
Include:
<unistd.h>
@@ -40,4 +37,4 @@ License:
GPL
Maintainer:
-Jim Meyering, Eric Blake
+Jim Meyering, Eric Blake, Paul Eggert
diff --git a/tests/test-chownat.c b/tests/test-chownat.c
new file mode 100644
index 000000000..c58377fca
--- /dev/null
+++ b/tests/test-chownat.c
@@ -0,0 +1,27 @@
+/* Tests of chownat and lchownat
+ Copyright 2020 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+#include "openat.h"
+
+#include "signature.h"
+SIGNATURE_CHECK (chownat, int, (int, char const *, uid_t, gid_t));
+SIGNATURE_CHECK (lchownat, int, (int, char const *, uid_t, gid_t));
+
+#define BASE "test-chownat.t"
+#define TEST_CHOWNAT
+#include "test-fchownat.c"
diff --git a/tests/test-fchownat.c b/tests/test-fchownat.c
index 993f335f5..960e2e905 100644
--- a/tests/test-fchownat.c
+++ b/tests/test-fchownat.c
@@ -36,7 +36,9 @@ SIGNATURE_CHECK (fchownat, int, (int, char const *, uid_t, gid_t, int));
#include "ignore-value.h"
#include "macros.h"
-#define BASE "test-fchownat.t"
+#ifndef BASE
+# define BASE "test-fchownat.t"
+#endif
#include "test-chown.h"
#include "test-lchown.h"
@@ -47,14 +49,22 @@ static int dfd = AT_FDCWD;
static int
do_chown (char const *name, uid_t user, gid_t group)
{
+#ifdef TEST_CHOWNAT
return chownat (dfd, name, user, group);
+#else
+ return fchownat (dfd, name, user, group, 0);
+#endif
}
/* Wrapper around fchownat to test lchown behavior. */
static int
do_lchown (char const *name, uid_t user, gid_t group)
{
+#ifdef TEST_CHOWNAT
return lchownat (dfd, name, user, group);
+#else
+ return fchownat (dfd, name, user, group, AT_SYMLINK_NOFOLLOW);
+#endif
}
int
--
2.24.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] chmodat, chownat: new modules
2020-02-22 20:10 [PATCH] chmodat, chownat: new modules Paul Eggert
@ 2020-02-22 22:47 ` Bruno Haible
2020-02-25 14:23 ` Pádraig Brady
0 siblings, 1 reply; 4+ messages in thread
From: Bruno Haible @ 2020-02-22 22:47 UTC (permalink / raw)
To: bug-gnulib; +Cc: Paul Eggert
Paul Eggert wrote:
> These are split from fchmodat, fchownat. GNU Emacs needs the
> POSIX-specified fchmodat, but not the gnulib-specified chmodat and
> lchmodat. Split the latter two into a new module chmodat.
As this is a backward-incompatible change for the gnulib users, we
should advertise it in the NEWS file. Done like this:
2020-02-22 Bruno Haible <bruno@clisp.org>
Update NEWS.
* NEWS: Mention the last change.
diff --git a/NEWS b/NEWS
index bc81dfc..4b9a983 100644
--- a/NEWS
+++ b/NEWS
@@ -58,6 +58,16 @@ User visible incompatible changes
Date Modules Changes
+2020-02-22 fchownat This module no longer defines the functions
+ 'chownat' and 'lchownat'. Program that need these
+ functions should add the module 'chownat' to the
+ list of imported modules.
+
+2020-02-22 fchmodat This module no longer defines the functions
+ 'chmodat' and 'lchmodat'. Program that need these
+ functions should add the module 'chmodat' to the
+ list of imported modules.
+
2020-02-07 fchmodat When applied to non-symlinks, these now act like
lchmod chmod (the BSD behavior, which POSIX requires for
fchmodat + AT_SYMLINK_NOFOLLOW), instead of failing
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] chmodat, chownat: new modules
2020-02-22 22:47 ` Bruno Haible
@ 2020-02-25 14:23 ` Pádraig Brady
2020-02-25 16:11 ` Bruno Haible
0 siblings, 1 reply; 4+ messages in thread
From: Pádraig Brady @ 2020-02-25 14:23 UTC (permalink / raw)
To: Bruno Haible, bug-gnulib; +Cc: Paul Eggert
On 22/02/2020 22:47, Bruno Haible wrote:
> Paul Eggert wrote:
>> These are split from fchmodat, fchownat. GNU Emacs needs the
>> POSIX-specified fchmodat, but not the gnulib-specified chmodat and
>> lchmodat. Split the latter two into a new module chmodat.
>
> As this is a backward-incompatible change for the gnulib users, we
> should advertise it in the NEWS file. Done like this:
>
>
> 2020-02-22 Bruno Haible <bruno@clisp.org>
>
> Update NEWS.
> * NEWS: Mention the last change.
>
> diff --git a/NEWS b/NEWS
> index bc81dfc..4b9a983 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -58,6 +58,16 @@ User visible incompatible changes
>
> Date Modules Changes
>
> +2020-02-22 fchownat This module no longer defines the functions
> + 'chownat' and 'lchownat'. Program that need these
> + functions should add the module 'chownat' to the
> + list of imported modules.
> +
> +2020-02-22 fchmodat This module no longer defines the functions
> + 'chmodat' and 'lchmodat'. Program that need these
> + functions should add the module 'chmodat' to the
> + list of imported modules.
> +
> 2020-02-07 fchmodat When applied to non-symlinks, these now act like
> lchmod chmod (the BSD behavior, which POSIX requires for
> fchmodat + AT_SYMLINK_NOFOLLOW), instead of failing
+1 please apply
thanks
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] chmodat, chownat: new modules
2020-02-25 14:23 ` Pádraig Brady
@ 2020-02-25 16:11 ` Bruno Haible
0 siblings, 0 replies; 4+ messages in thread
From: Bruno Haible @ 2020-02-25 16:11 UTC (permalink / raw)
To: Pádraig Brady; +Cc: Paul Eggert, bug-gnulib
> > diff --git a/NEWS b/NEWS
> > index bc81dfc..4b9a983 100644
> > --- a/NEWS
> > +++ b/NEWS
> > @@ -58,6 +58,16 @@ User visible incompatible changes
> >
> > Date Modules Changes
> >
> > +2020-02-22 fchownat This module no longer defines the functions
> > + 'chownat' and 'lchownat'. Program that need these
> > + functions should add the module 'chownat' to the
> > + list of imported modules.
> > +
> > +2020-02-22 fchmodat This module no longer defines the functions
> > + 'chmodat' and 'lchmodat'. Program that need these
> > + functions should add the module 'chmodat' to the
> > + list of imported modules.
> > +
> > 2020-02-07 fchmodat When applied to non-symlinks, these now act like
> > lchmod chmod (the BSD behavior, which POSIX requires for
> > fchmodat + AT_SYMLINK_NOFOLLOW), instead of failing
>
> +1 please apply
Already pushed on 2020-02-22.
Bruno
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-02-25 16:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-22 20:10 [PATCH] chmodat, chownat: new modules Paul Eggert
2020-02-22 22:47 ` Bruno Haible
2020-02-25 14:23 ` Pádraig Brady
2020-02-25 16:11 ` Bruno Haible
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 read-only IMAP folder(s) and NNTP newsgroup(s).