[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: tor log file function



On Thu, Dec 14, 2006 at 10:49:03PM -0600, Arrakis wrote:
> Greetings,
> 
> I am having a problem with the "log" command for tor. When I execute
> the line "tor.exe log notice file log.txt" under win32, tor acts as
> though it doesn't recognize the option "file" as written in the tor
> manual.

Remember that spaces are handled by your command line interpreter
before they reach C.  So while you meant to have a command line
equivalent to a torrc file of:

   log notice file log.txt

Instead, Tor is breaking this command line into:

   log notice
   file log.txt

On Unix, you'd solve this by saying:

   tor log "notice file log.txt"

so that the quotes would force the "notice file log.txt" part to be
treated as one value.  I don't know whether this will work on Windows
or not, but the odds seem okay.  Every OS needs a way to tell where
arguments end on the command line, right?  ;)

> 
> c:\tor\tor.exe log notice file tor.log
> Dec 14 22:45:27.443 [notice] Tor v0.1.1.25. This is experimental software. Do not rely on it for strong anonymity.
> Dec 14 22:45:27.506 [warn] Failed to parse/validate config: Unknown option 'file'.  Failing.
> Dec 14 22:45:27.506 [err] tor_init(): Reading config failed--see warnings above.
>  For usage, try -h.
> 
> 

> 
> Any ideas why that is? I have also noticed that the PidFile command
> doesn't work either, in that it will run but doesn't create the file.

Check out write_pidfile in util.c:

 void
 write_pidfile(char *filename)
 {
 #ifndef MS_WINDOWS
   FILE *pidfile;

   if ((pidfile = fopen(filename, "w")) == NULL) {
     log_warn(LD_FS, "Unable to open \"%s\" for writing: %s", filename,
              strerror(errno));
   } else {
     fprintf(pidfile, "%d\n", (int)getpid());
     fclose(pidfile);
   }
 #endif
 }

Hmmm.  Looks like we couldn't find the equivalent of getpid() on
Windows, but looking at it now, I can't imagine why.  MSDN says that
there's one living in process.h.  I've checked in a fix as r9116,
which should get into the next alpha, assuming it doesn't turn out to
be way more complicated than it looks.  Thanks for the reminder!

peace,
-- 
Nick Mathewson

Attachment: pgpZZW1FBcPo3.pgp
Description: PGP signature