Detect eaccess (or euidaccess) before using it.

Reported by Andrew Lindh via the -dev list.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@191367 65c4cc65-6c06-0410-ace0-fbb531ad65f3
certified/1.8.6
Tilghman Lesher 17 years ago
parent 38720ccd3b
commit 91dde03ba8

6
configure vendored

@ -1,5 +1,5 @@
#! /bin/sh #! /bin/sh
# From configure.ac Revision: 190150 . # From configure.ac Revision: 190093 .
# Guess values for system-dependent variables and create Makefiles. # Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.61 for asterisk 1.6. # Generated by GNU Autoconf 2.61 for asterisk 1.6.
# #
@ -15954,7 +15954,9 @@ done
for ac_func in asprintf atexit closefrom dup2 endpwent ftruncate getcwd gethostbyname gethostname getloadavg gettimeofday ioperm inet_ntoa isascii localtime_r memchr memmove memset mkdir munmap putenv re_comp regcomp select setenv socket strcasecmp strcasestr strchr strcspn strdup strerror strlcat strlcpy strncasecmp strndup strnlen strrchr strsep strspn strstr strtol strtoq unsetenv utime vasprintf getpeereid sysctl swapctl
for ac_func in asprintf atexit closefrom dup2 eaccess endpwent euidaccess ftruncate getcwd gethostbyname gethostname getloadavg gettimeofday ioperm inet_ntoa isascii localtime_r memchr memmove memset mkdir munmap putenv re_comp regcomp select setenv socket strcasecmp strcasestr strchr strcspn strdup strerror strlcat strlcpy strncasecmp strndup strnlen strrchr strsep strspn strstr strtol strtoq unsetenv utime vasprintf getpeereid sysctl swapctl
do do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
{ echo "$as_me:$LINENO: checking for $ac_func" >&5 { echo "$as_me:$LINENO: checking for $ac_func" >&5

@ -351,7 +351,7 @@ AC_FUNC_STRNLEN
AC_FUNC_STRTOD AC_FUNC_STRTOD
AC_FUNC_UTIME_NULL AC_FUNC_UTIME_NULL
AC_FUNC_VPRINTF AC_FUNC_VPRINTF
AC_CHECK_FUNCS([asprintf atexit closefrom dup2 endpwent ftruncate getcwd gethostbyname gethostname getloadavg gettimeofday ioperm inet_ntoa isascii localtime_r memchr memmove memset mkdir munmap putenv re_comp regcomp select setenv socket strcasecmp strcasestr strchr strcspn strdup strerror strlcat strlcpy strncasecmp strndup strnlen strrchr strsep strspn strstr strtol strtoq unsetenv utime vasprintf getpeereid sysctl swapctl]) AC_CHECK_FUNCS([asprintf atexit closefrom dup2 eaccess endpwent euidaccess ftruncate getcwd gethostbyname gethostname getloadavg gettimeofday ioperm inet_ntoa isascii localtime_r memchr memmove memset mkdir munmap putenv re_comp regcomp select setenv socket strcasecmp strcasestr strchr strcspn strdup strerror strlcat strlcpy strncasecmp strndup strnlen strrchr strsep strspn strstr strtol strtoq unsetenv utime vasprintf getpeereid sysctl swapctl])
AC_CHECK_FUNCS([glob]) AC_CHECK_FUNCS([glob])

@ -220,9 +220,15 @@
/* Define to 1 if you have the `dup2' function. */ /* Define to 1 if you have the `dup2' function. */
#undef HAVE_DUP2 #undef HAVE_DUP2
/* Define to 1 if you have the `eaccess' function. */
#undef HAVE_EACCESS
/* Define to 1 if you have the `endpwent' function. */ /* Define to 1 if you have the `endpwent' function. */
#undef HAVE_ENDPWENT #undef HAVE_ENDPWENT
/* Define to 1 if you have the `euidaccess' function. */
#undef HAVE_EUIDACCESS
/* Define this to indicate the ${EXP_DESCRIP} library */ /* Define this to indicate the ${EXP_DESCRIP} library */
#undef HAVE_EXP #undef HAVE_EXP

@ -3433,26 +3433,33 @@ int main(int argc, char *argv[])
if (geteuid() && ast_opt_dump_core) { if (geteuid() && ast_opt_dump_core) {
if (prctl(PR_SET_DUMPABLE, 1, 0, 0, 0) < 0) { if (prctl(PR_SET_DUMPABLE, 1, 0, 0, 0) < 0) {
ast_log(LOG_WARNING, "Unable to set the process for core dumps after changing to a non-root user. %s\n", strerror(errno)); ast_log(LOG_WARNING, "Unable to set the process for core dumps after changing to a non-root user. %s\n", strerror(errno));
} }
} }
#endif
{ {
#if defined(HAVE_EACCESS) || defined(HAVE_EUIDACCESS)
#if defined(HAVE_EUIDACCESS) && !defined(HAVE_EACCESS)
#define eaccess euidaccess
#endif
char dir[PATH_MAX]; char dir[PATH_MAX];
if (!getcwd(dir, sizeof(dir)) || eaccess(dir, R_OK | X_OK | F_OK)) { if (!getcwd(dir, sizeof(dir)) || eaccess(dir, R_OK | X_OK | F_OK)) {
ast_log(LOG_ERROR, "Unable to access the running directory (%s). Changing to '/' for compatibility.\n", strerror(errno)); ast_log(LOG_ERROR, "Unable to access the running directory (%s). Changing to '/' for compatibility.\n", strerror(errno));
/* If we cannot access the CWD, then we couldn't dump core anyway, /* If we cannot access the CWD, then we couldn't dump core anyway,
* so chdir("/") won't break anything. */ * so chdir("/") won't break anything. */
if (chdir("/")) { if (chdir("/")) {
ast_log(LOG_ERROR, "chdir() failed?!! %s\n", strerror(errno)); /* chdir(/) should never fail, so this ends up being a no-op */
ast_log(LOG_ERROR, "chdir(\"/\") failed?!! %s\n", strerror(errno));
} }
} else if (!ast_opt_no_fork && !ast_opt_dump_core) { } else
#endif /* defined(HAVE_EACCESS) || defined(HAVE_EUIDACCESS) */
if (!ast_opt_no_fork && !ast_opt_dump_core) {
/* Backgrounding, but no cores, so chdir won't break anything. */ /* Backgrounding, but no cores, so chdir won't break anything. */
if (chdir("/")) { if (chdir("/")) {
ast_log(LOG_ERROR, "Unable to chdir(\"/\") ?!! %s\n", strerror(errno)); ast_log(LOG_ERROR, "Unable to chdir(\"/\") ?!! %s\n", strerror(errno));
} }
} }
} }
#endif
ast_term_init(); ast_term_init();
printf("%s", term_end()); printf("%s", term_end());

Loading…
Cancel
Save