[or-cvs] clients shouldn"t create datadir until we have something to...

Roger Dingledine arma at seul.org
Thu Jul 22 00:13:44 UTC 2004


Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/or

Modified Files:
	config.c dirserv.c main.c 
Log Message:
clients shouldn't create datadir until we have something to put there


Index: config.c
===================================================================
RCS file: /home/or/cvsroot/src/or/config.c,v
retrieving revision 1.128
retrieving revision 1.129
diff -u -d -r1.128 -r1.129
--- config.c	20 Jul 2004 10:17:43 -0000	1.128
+++ config.c	22 Jul 2004 00:13:42 -0000	1.129
@@ -945,10 +945,13 @@
   const char *d;
   if (options->DataDirectory)
     d = options->DataDirectory;
-  else
+  else if (server_mode())
     d = "~/.tor";
+  else
+    d = NULL; /* XXX008 don't create datadir until we have something
+                 we'll be putting in it */
 
-  if (strncmp(d,"~/",2)==0) {
+  if (d && strncmp(d,"~/",2)==0) {
     char *fn = expand_filename(d);
     tor_free(options->DataDirectory);
     options->DataDirectory = fn;

Index: dirserv.c
===================================================================
RCS file: /home/or/cvsroot/src/or/dirserv.c,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -d -r1.64 -r1.65
--- dirserv.c	21 Jul 2004 22:54:27 -0000	1.64
+++ dirserv.c	22 Jul 2004 00:13:42 -0000	1.65
@@ -673,9 +673,11 @@
       exit(0);
     }
     free(new_directory);
-    sprintf(filename,"%s/cached-directory", get_data_directory(&options));
-    if(write_str_to_file(filename,the_directory) < 0) {
-      log_fn(LOG_WARN, "Couldn't write cached directory to disk. Ignoring.");
+    if(get_data_directory(&options)) {
+      sprintf(filename,"%s/cached-directory", get_data_directory(&options));
+      if(write_str_to_file(filename,the_directory) < 0) {
+        log_fn(LOG_WARN, "Couldn't write cached directory to disk. Ignoring.");
+      }
     }
   } else {
     log(LOG_INFO,"Directory still clean, reusing.");

Index: main.c
===================================================================
RCS file: /home/or/cvsroot/src/or/main.c,v
retrieving revision 1.303
retrieving revision 1.304
diff -u -d -r1.303 -r1.304
--- main.c	21 Jul 2004 23:43:47 -0000	1.303
+++ main.c	22 Jul 2004 00:13:42 -0000	1.304
@@ -667,7 +667,8 @@
   }
 
   /* Ensure data directory is private; create if possible. */
-  if (check_private_dir(get_data_directory(&options), 1) != 0) {
+  if (get_data_directory(&options) &&
+      check_private_dir(get_data_directory(&options), 1) != 0) {
     log_fn(LOG_ERR, "Couldn't access/create private data directory %s",
            get_data_directory(&options));
     return -1;



More information about the tor-commits mailing list