2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-22 09:57:41 +00:00

Add fchownat() systems without it.

This commit is contained in:
Todd C. Miller 2022-09-21 19:08:12 -06:00
parent 86c108b50b
commit 376d18b5da
7 changed files with 49 additions and 2 deletions

View File

@ -220,6 +220,7 @@ lib/util/event_select.c
lib/util/explicit_bzero.c lib/util/explicit_bzero.c
lib/util/fatal.c lib/util/fatal.c
lib/util/fchmodat.c lib/util/fchmodat.c
lib/util/fchownat.c
lib/util/fnmatch.c lib/util/fnmatch.c
lib/util/freezero.c lib/util/freezero.c
lib/util/fstatat.c lib/util/fstatat.c

View File

@ -298,6 +298,9 @@
/* Define to 1 if you have the `fchmodat' function. */ /* Define to 1 if you have the `fchmodat' function. */
#undef HAVE_FCHMODAT #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. */ /* Define to 1 if your system has the F_CLOSEM fcntl. */
#undef HAVE_FCNTL_CLOSEM #undef HAVE_FCNTL_CLOSEM

26
configure vendored
View File

@ -22747,6 +22747,32 @@ esac
fi fi
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 fi
done done

View File

@ -2873,6 +2873,10 @@ AC_CHECK_FUNCS(nanosleep, [], [
SUDO_APPEND_COMPAT_EXP(sudo_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_CHECK_FUNCS([mkdirat], [], [
AC_LIBOBJ(mkdirat) AC_LIBOBJ(mkdirat)
SUDO_APPEND_COMPAT_EXP(sudo_mkdirat) SUDO_APPEND_COMPAT_EXP(sudo_mkdirat)

View File

@ -484,6 +484,11 @@ sudo_dso_public size_t sudo_strnlen(const char *str, size_t maxlen);
# undef strnlen # undef strnlen
# define strnlen(_a, _b) sudo_strnlen((_a), (_b)) # define strnlen(_a, _b) sudo_strnlen((_a), (_b))
#endif /* HAVE_STRNLEN */ #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 #ifndef HAVE_MEMRCHR
sudo_dso_public void *sudo_memrchr(const void *s, int c, size_t n); sudo_dso_public void *sudo_memrchr(const void *s, int c, size_t n);
# undef memrchr # undef memrchr

View File

@ -703,6 +703,14 @@ fchmodat.i: $(srcdir)/fchmodat.c $(incdir)/sudo_compat.h \
$(CC) -E -o $@ $(CPPFLAGS) $< $(CC) -E -o $@ $(CPPFLAGS) $<
fchmodat.plog: fchmodat.i 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 $@ 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 \ fnm_test.lo: $(srcdir)/regress/fnmatch/fnm_test.c $(incdir)/compat/fnmatch.h \
$(incdir)/compat/stdbool.h $(incdir)/sudo_compat.h \ $(incdir)/compat/stdbool.h $(incdir)/sudo_compat.h \
$(incdir)/sudo_util.h $(top_builddir)/config.h $(incdir)/sudo_util.h $(top_builddir)/config.h

View File

@ -2,7 +2,7 @@
# #
# SPDX-License-Identifier: ISC # 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 # Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above # 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 # 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:\@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:\@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 # Parse OBJS lines
my %objs; my %objs;