From 9a33001df00af2d8624c6c9878b72f9ad56e0a61 Mon Sep 17 00:00:00 2001 From: Tatsuya Kinoshita Date: Thu, 12 Jan 2023 20:41:23 +0900 Subject: [PATCH] Use faccessat for rc_dir and tmp_dir --- config.h.dist | 1 + config.h.in | 1 + configure | 2 +- configure.ac | 2 +- rc.c | 5 +++++ 5 files changed, 9 insertions(+), 2 deletions(-) diff --git a/config.h.dist b/config.h.dist index fdb591a..fb73e77 100644 --- a/config.h.dist +++ b/config.h.dist @@ -212,6 +212,7 @@ typedef long clen_t; #undef HAVE_GETPASSPHRASE #define HAVE_CHDIR #define HAVE_MKDTEMP +#define HAVE_FACCESSAT #define SETJMP(env) sigsetjmp(env,1) diff --git a/config.h.in b/config.h.in index 8a3829d..e312faf 100644 --- a/config.h.in +++ b/config.h.in @@ -145,6 +145,7 @@ typedef long clen_t; #undef HAVE_GETPASSPHRASE #undef HAVE_CHDIR #undef HAVE_MKDTEMP +#undef HAVE_FACCESSAT #undef HAVE_SETPGRP #undef HAVE_SETLOCALE #undef HAVE_LANGINFO_CODESET diff --git a/configure b/configure index c2d62f7..4017260 100755 --- a/configure +++ b/configure @@ -9550,7 +9550,7 @@ _ACEOF -for ac_func in strcasecmp strcasestr strchr memcpy strerror bcopy setpgrp chdir mkdtemp getcwd getwd readlink setenv putenv strtoll stroq atoll atoq symlink readlink lstat srand48 srandom getpassphrase waitpid setlocale +for ac_func in strcasecmp strcasestr strchr memcpy strerror bcopy setpgrp chdir mkdtemp faccessat getcwd getwd readlink setenv putenv strtoll stroq atoll atoq symlink readlink lstat srand48 srandom getpassphrase waitpid setlocale do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" diff --git a/configure.ac b/configure.ac index 0e31d18..8fe6cc0 100644 --- a/configure.ac +++ b/configure.ac @@ -151,7 +151,7 @@ dnl AC_FUNC_MEMCMP dnl AC_FUNC_MMAP dnl AC_FUNC_SETVBUF_REVERSED dnl AC_FUNC_VPRINTF -AC_CHECK_FUNCS(strcasecmp strcasestr strchr memcpy strerror bcopy setpgrp chdir mkdtemp getcwd getwd readlink setenv putenv strtoll stroq atoll atoq symlink readlink lstat srand48 srandom getpassphrase waitpid setlocale) +AC_CHECK_FUNCS(strcasecmp strcasestr strchr memcpy strerror bcopy setpgrp chdir mkdtemp faccessat getcwd getwd readlink setenv putenv strtoll stroq atoll atoq symlink readlink lstat srand48 srandom getpassphrase waitpid setlocale) AC_FUNC_STRFTIME AC_FUNC_WAIT3 AC_FUNC_SETPGRP diff --git a/rc.c b/rc.c index cf000a0..49c4aa5 100644 --- a/rc.c +++ b/rc.c @@ -1282,6 +1282,11 @@ do_recursive_mkdir(const char *dir) *ch = tmp; } while (*ch++ != '\0'); +#ifdef HAVE_FACCESSAT + if (faccessat(AT_FDCWD, dir, W_OK|X_OK, AT_EACCESS) < 0) { + return -1; + } +#endif return 0; }