aboutsummaryrefslogtreecommitdiffstats
path: root/main/asterisk.c
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2009-04-30 17:43:37 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2009-04-30 17:43:37 +0000
commitd628bd5b99dcd93f4cd2e442e875a6e479365f3c (patch)
treeb51b6cd73d18389a9d8f2a590922181fa920ac29 /main/asterisk.c
parentb7c30af379257dec4b61669f4ff85afc487a2fb3 (diff)
Merged revisions 191367 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk ........ r191367 | tilghman | 2009-04-30 12:40:58 -0500 (Thu, 30 Apr 2009) | 3 lines Detect eaccess (or euidaccess) before using it. Reported by Andrew Lindh via the -dev list. ........ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.0@191368 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/asterisk.c')
-rw-r--r--main/asterisk.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/main/asterisk.c b/main/asterisk.c
index 1cc6f791e..275216fe2 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -3251,26 +3251,33 @@ int main(int argc, char *argv[])
if (geteuid() && ast_opt_dump_core) {
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));
- }
+ }
}
+#endif
{
+#if defined(HAVE_EACCESS) || defined(HAVE_EUIDACCESS)
+#if defined(HAVE_EUIDACCESS) && !defined(HAVE_EACCESS)
+#define eaccess euidaccess
+#endif
char dir[PATH_MAX];
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));
/* If we cannot access the CWD, then we couldn't dump core anyway,
* so chdir("/") won't break anything. */
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. */
if (chdir("/")) {
ast_log(LOG_ERROR, "Unable to chdir(\"/\") ?!! %s\n", strerror(errno));
}
}
}
-#endif
ast_term_init();
printf("%s", term_end());