summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MANIFEST1
-rw-r--r--config.h.in3
-rwxr-xr-xconfigure26
-rw-r--r--configure.ac4
-rw-r--r--include/sudo_compat.h5
-rw-r--r--lib/util/Makefile.in8
-rwxr-xr-xscripts/mkdep.pl4
7 files changed, 49 insertions, 2 deletions
diff --git a/MANIFEST b/MANIFEST
index 22e2348df..628cbf4de 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -220,6 +220,7 @@ lib/util/event_select.c
lib/util/explicit_bzero.c
lib/util/fatal.c
lib/util/fchmodat.c
+lib/util/fchownat.c
lib/util/fnmatch.c
lib/util/freezero.c
lib/util/fstatat.c
diff --git a/config.h.in b/config.h.in
index bd8f0d59d..32dbb9879 100644
--- a/config.h.in
+++ b/config.h.in
@@ -298,6 +298,9 @@
/* Define to 1 if you have the `fchmodat' function. */
#undef HAVE_FCHMODAT
+/* Define to 1 if you have the `fchownat' function. */
+#undef HAVE_FCHOWNAT
+
/* Define to 1 if your system has the F_CLOSEM fcntl. */
#undef HAVE_FCNTL_CLOSEM
diff --git a/configure b/configure
index 35f528ab4..f565225fb 100755
--- a/configure
+++ b/configure
@@ -22751,6 +22751,32 @@ fi
done
+ for ac_func in fchownat
+do :
+ ac_fn_c_check_func "$LINENO" "fchownat" "ac_cv_func_fchownat"
+if test "x$ac_cv_func_fchownat" = xyes
+then :
+ printf "%s\n" "#define HAVE_FCHOWNAT 1" >>confdefs.h
+
+else $as_nop
+
+ case " $LIBOBJS " in
+ *" fchownat.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS fchownat.$ac_objext"
+ ;;
+esac
+
+
+ for _sym in sudo_fchownat; do
+ COMPAT_EXP="${COMPAT_EXP}${_sym}
+"
+ done
+
+
+fi
+
+done
+
for ac_func in mkdirat
do :
ac_fn_c_check_func "$LINENO" "mkdirat" "ac_cv_func_mkdirat"
diff --git a/configure.ac b/configure.ac
index 427bfa794..54f2c5e5a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2873,6 +2873,10 @@ AC_CHECK_FUNCS(nanosleep, [], [
SUDO_APPEND_COMPAT_EXP(sudo_nanosleep)
])
])
+AC_CHECK_FUNCS([fchownat], [], [
+ AC_LIBOBJ(fchownat)
+ SUDO_APPEND_COMPAT_EXP(sudo_fchownat)
+])
AC_CHECK_FUNCS([mkdirat], [], [
AC_LIBOBJ(mkdirat)
SUDO_APPEND_COMPAT_EXP(sudo_mkdirat)
diff --git a/include/sudo_compat.h b/include/sudo_compat.h
index a9212189e..87602154e 100644
--- a/include/sudo_compat.h
+++ b/include/sudo_compat.h
@@ -484,6 +484,11 @@ sudo_dso_public size_t sudo_strnlen(const char *str, size_t maxlen);
# undef strnlen
# define strnlen(_a, _b) sudo_strnlen((_a), (_b))
#endif /* HAVE_STRNLEN */
+#ifndef HAVE_FCHOWNAT
+sudo_dso_public int sudo_fchownat(int dfd, const char *path, uid_t uid, gid_t gid, int flag);
+# undef fchownat
+# define fchownat(_a, _b, _c, _d, _e) sudo_fchownat((_a), (_b), (_c), (_d), (_e))
+#endif /* HAVE_FCHOWNAT */
#ifndef HAVE_MEMRCHR
sudo_dso_public void *sudo_memrchr(const void *s, int c, size_t n);
# undef memrchr
diff --git a/lib/util/Makefile.in b/lib/util/Makefile.in
index 22abb8888..f3d44fc0f 100644
--- a/lib/util/Makefile.in
+++ b/lib/util/Makefile.in
@@ -703,6 +703,14 @@ fchmodat.i: $(srcdir)/fchmodat.c $(incdir)/sudo_compat.h \
$(CC) -E -o $@ $(CPPFLAGS) $<
fchmodat.plog: fchmodat.i
rm -f $@; pvs-studio --cfg $(PVS_CFG) --sourcetree-root $(top_srcdir) --skip-cl-exe yes --source-file $(srcdir)/fchmodat.c --i-file $< --output-file $@
+fchownat.lo: $(srcdir)/fchownat.c $(incdir)/sudo_compat.h \
+ $(top_builddir)/config.h
+ $(LIBTOOL) $(LTFLAGS) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(ASAN_CFLAGS) $(PIE_CFLAGS) $(HARDENING_CFLAGS) $(srcdir)/fchownat.c
+fchownat.i: $(srcdir)/fchownat.c $(incdir)/sudo_compat.h \
+ $(top_builddir)/config.h
+ $(CC) -E -o $@ $(CPPFLAGS) $<
+fchownat.plog: fchownat.i
+ rm -f $@; pvs-studio --cfg $(PVS_CFG) --sourcetree-root $(top_srcdir) --skip-cl-exe yes --source-file $(srcdir)/fchownat.c --i-file $< --output-file $@
fnm_test.lo: $(srcdir)/regress/fnmatch/fnm_test.c $(incdir)/compat/fnmatch.h \
$(incdir)/compat/stdbool.h $(incdir)/sudo_compat.h \
$(incdir)/sudo_util.h $(top_builddir)/config.h
diff --git a/scripts/mkdep.pl b/scripts/mkdep.pl
index 4056119e7..a6e10bcc1 100755
--- a/scripts/mkdep.pl
+++ b/scripts/mkdep.pl
@@ -2,7 +2,7 @@
#
# SPDX-License-Identifier: ISC
#
-# Copyright (c) 2011-2021 Todd C. Miller <Todd.Miller@sudo.ws>
+# Copyright (c) 2011-2022 Todd C. Miller <Todd.Miller@sudo.ws>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
@@ -120,7 +120,7 @@ sub mkdep {
# XXX - fill in AUTH_OBJS from contents of the auth dir instead
$makefile =~ s:\@AUTH_OBJS\@:afs.lo aix_auth.lo bsdauth.lo dce.lo fwtk.lo getspwuid.lo kerb5.lo pam.lo passwd.lo rfc1938.lo secureware.lo securid5.lo sia.lo:;
$makefile =~ s:\@DIGEST\@:digest.lo digest_openssl.lo digest_gcrypt.lo:;
- $makefile =~ s:\@LTLIBOBJS\@:arc4random.lo arc4random_buf.lo arc4random_uniform.lo cfmakeraw.lo closefrom.lo dup3.lo explicit_bzero.lo fchmodat.lo freezero.lo fstatat.lo fnmatch.lo getaddrinfo.lo getcwd.lo getentropy.lo getgrouplist.lo getdelim.lo getopt_long.lo getusershell.lo glob.lo gmtime_r.lo inet_ntop_lo inet_pton.lo isblank.lo localtime_r.lo memrchr.lo mkdirat.lo mksiglist.lo mksigname.lo mktemp.lo nanosleep.lo openat.lo pipe2.lo pread.lo pwrite.lo pw_dup.lo reallocarray.lo sha2.lo sig2str.lo siglist.lo signame.lo snprintf.lo str2sig.lo strlcat.lo strlcpy.lo strndup.lo strnlen.lo strsignal.lo timegm.lo unlinkat.lo utimens.lo:;
+ $makefile =~ s:\@LTLIBOBJS\@:arc4random.lo arc4random_buf.lo arc4random_uniform.lo cfmakeraw.lo closefrom.lo dup3.lo explicit_bzero.lo fchmodat.lo fchownat.lo freezero.lo fstatat.lo fnmatch.lo getaddrinfo.lo getcwd.lo getentropy.lo getgrouplist.lo getdelim.lo getopt_long.lo getusershell.lo glob.lo gmtime_r.lo inet_ntop_lo inet_pton.lo isblank.lo localtime_r.lo memrchr.lo mkdirat.lo mksiglist.lo mksigname.lo mktemp.lo nanosleep.lo openat.lo pipe2.lo pread.lo pwrite.lo pw_dup.lo reallocarray.lo sha2.lo sig2str.lo siglist.lo signame.lo snprintf.lo str2sig.lo strlcat.lo strlcpy.lo strndup.lo strnlen.lo strsignal.lo timegm.lo unlinkat.lo utimens.lo:;
# Parse OBJS lines
my %objs;