+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.
#include <config.h>
-#define FCHMODAT_INLINE _GL_EXTERN_INLINE
+#define CHMODAT_INLINE _GL_EXTERN_INLINE
#include "openat.h"
#include <config.h>
-#define FCHOWNAT_INLINE _GL_EXTERN_INLINE
+#define CHOWNAT_INLINE _GL_EXTERN_INLINE
#include "openat.h"
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);
#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);
--- /dev/null
+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
--- /dev/null
+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
Files:
lib/fchmodat.c
-lib/chmodat.c
lib/at-func.c
m4/fchmodat.m4
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>
GPL
Maintainer:
-Jim Meyering, Eric Blake
+Jim Meyering, Eric Blake, Paul Eggert
Files:
lib/fchownat.c
-lib/chownat.c
lib/at-func.c
m4/fchownat.m4
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>
GPL
Maintainer:
-Jim Meyering, Eric Blake
+Jim Meyering, Eric Blake, Paul Eggert
--- /dev/null
+/* 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"
#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"
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