"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/app/config/config.c" between
tor-0.4.6.3-rc.tar.gz and tor-0.4.6.4-rc.tar.gz

About: Tor is an anonymous Internet communication system - a network of virtual tunnels that allows people and groups to improve their privacy and security on the Internet. Release candidate.

config.c  (tor-0.4.6.3-rc):config.c  (tor-0.4.6.4-rc)
skipping to change at line 6859 skipping to change at line 6859
return 0; return 0;
} }
/** This string must remain the same forevermore. It is how we /** This string must remain the same forevermore. It is how we
* recognize that the torrc file doesn't need to be backed up. */ * recognize that the torrc file doesn't need to be backed up. */
#define GENERATED_FILE_PREFIX "# This file was generated by Tor; " \ #define GENERATED_FILE_PREFIX "# This file was generated by Tor; " \
"if you edit it, comments will not be preserved" "if you edit it, comments will not be preserved"
/** This string can change; it tries to give the reader an idea /** This string can change; it tries to give the reader an idea
* that editing this file by hand is not a good plan. */ * that editing this file by hand is not a good plan. */
#define GENERATED_FILE_COMMENT "# The old torrc file was renamed " \ #define GENERATED_FILE_COMMENT "# The old torrc file was renamed " \
"to torrc.orig.1 or similar, and Tor will ignore it" "to torrc.orig.1, and Tor will ignore it"
/** Save a configuration file for the configuration in <b>options</b> /** Save a configuration file for the configuration in <b>options</b>
* into the file <b>fname</b>. If the file already exists, and * into the file <b>fname</b>. If the file already exists, and
* doesn't begin with GENERATED_FILE_PREFIX, rename it. Otherwise * doesn't begin with GENERATED_FILE_PREFIX, rename it. Otherwise
* replace it. Return 0 on success, -1 on failure. */ * replace it. Return 0 on success, -1 on failure. */
static int static int
write_configuration_file(const char *fname, const or_options_t *options) write_configuration_file(const char *fname, const or_options_t *options)
{ {
char *old_val=NULL, *new_val=NULL, *new_conf=NULL; char *old_val=NULL, *new_val=NULL, *new_conf=NULL;
int rename_old = 0, r; int rename_old = 0, r;
skipping to change at line 6903 skipping to change at line 6903
if (!(new_conf = options_dump(options, OPTIONS_DUMP_MINIMAL))) { if (!(new_conf = options_dump(options, OPTIONS_DUMP_MINIMAL))) {
log_warn(LD_BUG, "Couldn't get configuration string"); log_warn(LD_BUG, "Couldn't get configuration string");
goto err; goto err;
} }
tor_asprintf(&new_val, "%s\n%s\n\n%s", tor_asprintf(&new_val, "%s\n%s\n\n%s",
GENERATED_FILE_PREFIX, GENERATED_FILE_COMMENT, new_conf); GENERATED_FILE_PREFIX, GENERATED_FILE_COMMENT, new_conf);
if (rename_old) { if (rename_old) {
int i = 1;
char *fn_tmp = NULL; char *fn_tmp = NULL;
while (1) { tor_asprintf(&fn_tmp, CONFIG_BACKUP_PATTERN, fname);
tor_asprintf(&fn_tmp, "%s.orig.%d", fname, i); file_status_t fn_tmp_status = file_status(fn_tmp);
if (file_status(fn_tmp) == FN_NOENT) if (fn_tmp_status == FN_DIR || fn_tmp_status == FN_ERROR) {
break; log_warn(LD_CONFIG,
"Config backup file \"%s\" is not a file? Failing.", fn_tmp);
tor_free(fn_tmp); tor_free(fn_tmp);
++i; goto err;
} }
log_notice(LD_CONFIG, "Renaming old configuration file to \"%s\"", fn_tmp); log_notice(LD_CONFIG, "Renaming old configuration file to \"%s\"", fn_tmp);
if (tor_rename(fname, fn_tmp) < 0) {//XXXX sandbox doesn't allow if (replace_file(fname, fn_tmp) < 0) {
log_warn(LD_FS, log_warn(LD_FS,
"Couldn't rename configuration file \"%s\" to \"%s\": %s", "Couldn't rename configuration file \"%s\" to \"%s\": %s",
fname, fn_tmp, strerror(errno)); fname, fn_tmp, strerror(errno));
tor_free(fn_tmp); tor_free(fn_tmp);
goto err; goto err;
} }
tor_free(fn_tmp); tor_free(fn_tmp);
} }
if (write_str_to_file(fname, new_val, 0) < 0) if (write_str_to_file(fname, new_val, 0) < 0)
 End of changes. 6 change blocks. 
8 lines changed or deleted 9 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)