[svn-commits] tilghman: branch 1.6.0 r191284 - in /branches/1.6.0: ./ main/asterisk.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Apr 30 01:48:04 CDT 2009


Author: tilghman
Date: Thu Apr 30 01:48:00 2009
New Revision: 191284

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=191284
Log:
Merged revisions 191283 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

........
  r191283 | tilghman | 2009-04-30 01:47:13 -0500 (Thu, 30 Apr 2009) | 11 lines
  
  Change working directory to / under certain conditions.
  If backgrounding and no core will be produced, then changing the directory
  won't break anything; likewise, if the CWD isn't accessible by the current
  user, then a core wasn't possible anyway.
  (closes issue #14831)
   Reported by: chris-mac
   Patches: 
         20090428__bug14831.diff.txt uploaded by tilghman (license 14)
         20090430__bug14831.diff.txt uploaded by tilghman (license 14)
   Tested by: chris-mac
........

Modified:
    branches/1.6.0/   (props changed)
    branches/1.6.0/main/asterisk.c

Propchange: branches/1.6.0/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.

Modified: branches/1.6.0/main/asterisk.c
URL: http://svn.digium.com/svn-view/asterisk/branches/1.6.0/main/asterisk.c?view=diff&rev=191284&r1=191283&r2=191284
==============================================================================
--- branches/1.6.0/main/asterisk.c (original)
+++ branches/1.6.0/main/asterisk.c Thu Apr 30 01:48:00 2009
@@ -3253,6 +3253,23 @@
 			ast_log(LOG_WARNING, "Unable to set the process for core dumps after changing to a non-root user. %s\n", strerror(errno));
 		}	
 	}
+
+	{
+		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));
+			}
+		} else 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();




More information about the svn-commits mailing list