[svn-commits] mmichelson: branch 1.4 r139769 - /branches/1.4/main/config.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Aug 25 10:52:59 CDT 2008


Author: mmichelson
Date: Mon Aug 25 10:52:59 2008
New Revision: 139769

URL: http://svn.digium.com/view/asterisk?view=rev&rev=139769
Log:
Fix the logic in config_text_file_save so that if an
UpdateConfig manager action is issued and the
file specified in DstFileName does not yet exist,
an error is not returned.

(closes issue #13341)
Reported by: vadim
Patches:
      13341.patch uploaded by putnopvut (license 60)
	  (with small modification from seanbright)


Modified:
    branches/1.4/main/config.c

Modified: branches/1.4/main/config.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/main/config.c?view=diff&rev=139769&r1=139768&r2=139769
==============================================================================
--- branches/1.4/main/config.c (original)
+++ branches/1.4/main/config.c Mon Aug 25 10:52:59 2008
@@ -1013,6 +1013,7 @@
 	struct ast_comment *cmt;
 	struct stat s;
 	int blanklines = 0;
+	int stat_result = 0;
 
 	if (configfile[0] == '/') {
 		snprintf(fntmp, sizeof(fntmp), "%s.XXXXXX", configfile);
@@ -1124,10 +1125,11 @@
 			close(fd);
 		return -1;
 	}
-	stat(fn, &s);
-	fchmod(fd, s.st_mode);
+	if (!(stat_result = stat(fn, &s))) {
+		fchmod(fd, s.st_mode);
+	}
 	fclose(f);
-	if (unlink(fn) || link(fntmp, fn)) {
+	if ((!stat_result && unlink(fn)) || link(fntmp, fn)) {
 		if (option_debug)
 			ast_log(LOG_DEBUG, "Unable to open for writing: %s (%s)\n", fn, strerror(errno));
 		if (option_verbose > 1)




More information about the svn-commits mailing list