[tor-commits] [tor/master] Make sure everything using an interned string is preceded by a log

nickm at torproject.org nickm at torproject.org
Thu Apr 17 03:48:07 UTC 2014


commit 156eefca454e10440d1070f7500e1708589fc64b
Author: Nick Mathewson <nickm at torproject.org>
Date:   Wed Apr 16 13:17:09 2014 -0400

    Make sure everything using an interned string is preceded by a log
    
    (It's nice to know what we were about to rename before we died from
    renaming it.)
---
 src/common/compat.c |    2 ++
 src/common/crypto.c |    1 +
 src/common/util.c   |    2 ++
 src/or/config.c     |    1 +
 src/or/dns.c        |    2 ++
 5 files changed, 8 insertions(+)

diff --git a/src/common/compat.c b/src/common/compat.c
index 5c18535..c5945fb 100644
--- a/src/common/compat.c
+++ b/src/common/compat.c
@@ -144,6 +144,7 @@ tor_open_cloexec(const char *path, int flags, unsigned mode)
     return -1;
 #endif
 
+  log_debug(LD_FS, "Opening %s with flags %x", path, flags);
   fd = open(path, flags, mode);
 #ifdef FD_CLOEXEC
   if (fd >= 0) {
@@ -179,6 +180,7 @@ tor_fopen_cloexec(const char *path, const char *mode)
 int
 tor_rename(const char *path_old, const char *path_new)
 {
+  log_debug(LD_FS, "Renaming %s to %s", path_old, path_new);
   return rename(sandbox_intern_string(path_old),
                 sandbox_intern_string(path_new));
 }
diff --git a/src/common/crypto.c b/src/common/crypto.c
index 8a4ffb6..a247a87 100644
--- a/src/common/crypto.c
+++ b/src/common/crypto.c
@@ -2471,6 +2471,7 @@ crypto_strongest_rand(uint8_t *out, size_t out_len)
   return 0;
 #else
   for (i = 0; filenames[i]; ++i) {
+    log_debug(LD_FS, "Opening %s for entropy", filenames[i]);
     fd = open(sandbox_intern_string(filenames[i]), O_RDONLY, 0);
     if (fd<0) continue;
     log_info(LD_CRYPTO, "Reading entropy from \"%s\"", filenames[i]);
diff --git a/src/common/util.c b/src/common/util.c
index a50f256..86bb8ba 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -1830,6 +1830,7 @@ file_status(const char *fname)
   int r;
   f = tor_strdup(fname);
   clean_name_for_stat(f);
+  log_debug(LD_FS, "stat()ing %s", f);
   r = stat(sandbox_intern_string(f), &st);
   tor_free(f);
   if (r) {
@@ -1880,6 +1881,7 @@ check_private_dir(const char *dirname, cpd_check_t check,
   tor_assert(dirname);
   f = tor_strdup(dirname);
   clean_name_for_stat(f);
+  log_debug(LD_FS, "stat()ing %s", f);
   r = stat(sandbox_intern_string(f), &st);
   tor_free(f);
   if (r) {
diff --git a/src/or/config.c b/src/or/config.c
index 89aedcc..c2eebf7 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -6462,6 +6462,7 @@ remove_file_if_very_old(const char *fname, time_t now)
 #define VERY_OLD_FILE_AGE (28*24*60*60)
   struct stat st;
 
+  log_debug(LD_FS, "stat()ing %s", fname);
   if (stat(sandbox_intern_string(fname), &st)==0 &&
       st.st_mtime < now-VERY_OLD_FILE_AGE) {
     char buf[ISO_TIME_LEN+1];
diff --git a/src/or/dns.c b/src/or/dns.c
index 21c82e8..3627193 100644
--- a/src/or/dns.c
+++ b/src/or/dns.c
@@ -1480,6 +1480,7 @@ configure_nameservers(int force)
 
   evdns_set_log_fn(evdns_log_cb);
   if (conf_fname) {
+    log_debug(LD_FS, "stat()ing %s", conf_fname);
     if (stat(sandbox_intern_string(conf_fname), &st)) {
       log_warn(LD_EXIT, "Unable to stat resolver configuration in '%s': %s",
                conf_fname, strerror(errno));
@@ -1497,6 +1498,7 @@ configure_nameservers(int force)
 #if defined(DNS_OPTION_HOSTSFILE) && defined(USE_LIBSECCOMP)
     if (flags & DNS_OPTION_HOSTSFILE) {
       flags ^= DNS_OPTION_HOSTSFILE;
+      log_debug(LD_FS, "Loading /etc/hosts");
       evdns_base_load_hosts(the_evdns_base,
           sandbox_intern_string("/etc/hosts"));
     }





More information about the tor-commits mailing list