Tor  0.4.6.0-alpha-dev
main.c
Go to the documentation of this file.
1 /* Copyright (c) 2001 Matej Pfajfar.
2  * Copyright (c) 2001-2004, Roger Dingledine.
3  * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
4  * Copyright (c) 2007-2020, The Tor Project, Inc. */
5 /* See LICENSE for licensing information */
6 
7 /**
8  * \file main.c
9  * \brief Invocation module. Initializes subsystems and runs the main loop.
10  **/
11 
12 #include "core/or/or.h"
13 
14 #include "app/config/config.h"
15 #include "app/config/statefile.h"
16 #include "app/config/quiet_level.h"
17 #include "app/main/main.h"
18 #include "app/main/ntmain.h"
19 #include "app/main/risky_options.h"
20 #include "app/main/shutdown.h"
21 #include "app/main/subsysmgr.h"
24 #include "core/mainloop/mainloop.h"
27 #include "core/or/channel.h"
28 #include "core/or/channelpadding.h"
29 #include "core/or/circuitpadding.h"
30 #include "core/or/circuitlist.h"
31 #include "core/or/command.h"
32 #include "core/or/connection_or.h"
33 #include "core/or/relay.h"
34 #include "core/or/status.h"
35 #include "feature/api/tor_api.h"
41 #include "feature/dirauth/keypin.h"
46 #include "feature/hs/hs_dos.h"
50 #include "feature/relay/dns.h"
54 #include "feature/rend/rendcache.h"
57 #include "feature/stats/bwhist.h"
58 #include "feature/stats/rephist.h"
59 #include "lib/compress/compress.h"
60 #include "lib/buf/buffers.h"
64 #include "lib/net/resolve.h"
65 #include "lib/trace/trace.h"
66 
67 #include "lib/process/waitpid.h"
69 
70 #include "lib/meminfo/meminfo.h"
71 #include "lib/osinfo/uname.h"
72 #include "lib/osinfo/libc.h"
73 #include "lib/sandbox/sandbox.h"
74 #include "lib/fs/lockfile.h"
75 #include "lib/tls/tortls.h"
77 #include "lib/encoding/confline.h"
78 #include "lib/evloop/timers.h"
80 #include "lib/version/torversion.h"
81 
82 #include <event2/event.h>
83 
86 
88 #include "core/or/port_cfg_st.h"
89 
90 #ifdef HAVE_UNISTD_H
91 #include <unistd.h>
92 #endif
93 
94 #ifdef HAVE_SYSTEMD
95 # if defined(__COVERITY__) && !defined(__INCLUDE_LEVEL__)
96 /* Systemd's use of gcc's __INCLUDE_LEVEL__ extension macro appears to confuse
97  * Coverity. Here's a kludge to unconfuse it.
98  */
99 # define __INCLUDE_LEVEL__ 2
100 #endif /* defined(__COVERITY__) && !defined(__INCLUDE_LEVEL__) */
101 #include <systemd/sd-daemon.h>
102 #endif /* defined(HAVE_SYSTEMD) */
103 
104 #ifdef HAVE_RUST
105 // helper function defined in Rust to output a log message indicating if tor is
106 // running with Rust enabled. See src/rust/tor_util
107 void rust_log_welcome_string(void);
108 #endif
109 
110 /********* PROTOTYPES **********/
111 
112 static void dumpmemusage(int severity);
113 static void dumpstats(int severity); /* log stats */
114 static void process_signal(int sig);
115 
116 /** Called when we get a SIGHUP: reload configuration files and keys,
117  * retry all connections, and so on. */
118 static int
119 do_hup(void)
120 {
121  const or_options_t *options = get_options();
122 
123  log_notice(LD_GENERAL,"Received reload signal (hup). Reloading config and "
124  "resetting internal state.");
125  if (accounting_is_enabled(options))
127 
130  /* first, reload config variables, in case they've changed */
131  if (options->ReloadTorrcOnSIGHUP) {
132  /* no need to provide argc/v, they've been cached in init_from_config */
133  int init_rv = options_init_from_torrc(0, NULL);
134  if (init_rv < 0) {
135  log_err(LD_CONFIG,"Reading config failed--see warnings above. "
136  "For usage, try -h.");
137  return -1;
138  } else if (BUG(init_rv > 0)) {
139  // LCOV_EXCL_START
140  /* This should be impossible: the only "return 1" cases in
141  * options_init_from_torrc are ones caused by command-line arguments;
142  * but they can't change while Tor is running. */
143  return -1;
144  // LCOV_EXCL_STOP
145  }
146  options = get_options(); /* they have changed now */
147  /* Logs are only truncated the first time they are opened, but were
148  probably intended to be cleaned up on signal. */
149  if (options->TruncateLogFile)
150  truncate_logs();
151  } else {
152  char *msg = NULL;
153  log_notice(LD_GENERAL, "Not reloading config file: the controller told "
154  "us not to.");
155  /* Make stuff get rescanned, reloaded, etc. */
156  if (set_options((or_options_t*)options, &msg) < 0) {
157  if (!msg)
158  msg = tor_strdup("Unknown error");
159  log_warn(LD_GENERAL, "Unable to re-set previous options: %s", msg);
160  tor_free(msg);
161  }
162  }
163  if (authdir_mode(options)) {
164  /* reload the approved-routers file */
165  if (dirserv_load_fingerprint_file() < 0) {
166  /* warnings are logged from dirserv_load_fingerprint_file() directly */
167  log_info(LD_GENERAL, "Error reloading fingerprints. "
168  "Continuing with old list.");
169  }
170  }
171 
172  /* Rotate away from the old dirty circuits. This has to be done
173  * after we've read the new options, but before we start using
174  * circuits for directory fetches. */
176 
177  /* retry appropriate downloads */
180  if (!net_is_disabled())
181  update_networkstatus_downloads(time(NULL));
182 
183  /* We'll retry routerstatus downloads in about 10 seconds; no need to
184  * force a retry there. */
185 
186  if (server_mode(options)) {
187  /* Maybe we've been given a new ed25519 key or certificate?
188  */
189  time_t now = approx_time();
190  int new_signing_key = load_ed_keys(options, now);
191  if (new_signing_key < 0 ||
192  generate_ed_link_cert(options, now, new_signing_key > 0)) {
193  log_warn(LD_OR, "Problem reloading Ed25519 keys; still using old keys.");
194  }
195 
196  /* Update cpuworker and dnsworker processes, so they get up-to-date
197  * configuration options. */
199  dns_reset();
200  }
201  return 0;
202 }
203 
204 /** Libevent callback: invoked when we get a signal.
205  */
206 static void
207 signal_callback(evutil_socket_t fd, short events, void *arg)
208 {
209  const int *sigptr = arg;
210  const int sig = *sigptr;
211  (void)fd;
212  (void)events;
213 
214  update_current_time(time(NULL));
215  process_signal(sig);
216 }
217 
218 /** Do the work of acting on a signal received in <b>sig</b> */
219 static void
221 {
222  switch (sig)
223  {
224  case SIGTERM:
225  log_notice(LD_GENERAL,"Catching signal TERM, exiting cleanly.");
227  break;
228  case SIGINT:
229  if (!server_mode(get_options())) { /* do it now */
230  log_notice(LD_GENERAL,"Interrupt: exiting cleanly.");
232  return;
233  }
234 #ifdef HAVE_SYSTEMD
235  sd_notify(0, "STOPPING=1");
236 #endif
238  break;
239 #ifdef SIGPIPE
240  case SIGPIPE:
241  log_debug(LD_GENERAL,"Caught SIGPIPE. Ignoring.");
242  break;
243 #endif
244  case SIGUSR1:
245  /* prefer to log it at INFO, but make sure we always see it */
248  break;
249  case SIGUSR2:
251  log_debug(LD_GENERAL,"Caught USR2, going to loglevel debug. "
252  "Send HUP to change back.");
254  break;
255  case SIGHUP:
256 #ifdef HAVE_SYSTEMD
257  sd_notify(0, "RELOADING=1");
258 #endif
259  if (do_hup() < 0) {
260  log_warn(LD_CONFIG,"Restart failed (config error?). Exiting.");
262  return;
263  }
264 #ifdef HAVE_SYSTEMD
265  sd_notify(0, "READY=1");
266 #endif
268  break;
269 #ifdef SIGCHLD
270  case SIGCHLD:
272  break;
273 #endif
274  case SIGNEWNYM: {
275  do_signewnym(time(NULL));
276  break;
277  }
278  case SIGCLEARDNSCACHE:
281  break;
282  case SIGHEARTBEAT:
283  log_heartbeat(time(NULL));
285  break;
286  case SIGACTIVE:
287  /* "SIGACTIVE" counts as ersatz user activity. */
290  break;
291  case SIGDORMANT:
292  /* "SIGDORMANT" means to ignore past user activity */
293  log_notice(LD_GENERAL, "Going dormant because of controller request.");
298  break;
299  }
300 }
301 
302 #ifdef _WIN32
303 /** Activate SIGINT on receiving a control signal in console. */
304 static BOOL WINAPI
305 process_win32_console_ctrl(DWORD ctrl_type)
306 {
307  /* Ignore type of the ctrl signal */
308  (void) ctrl_type;
309 
310  activate_signal(SIGINT);
311  return TRUE;
312 }
313 #endif
314 
315 /**
316  * Write current memory usage information to the log.
317  */
318 static void
319 dumpmemusage(int severity)
320 {
322  tor_log(severity, LD_GENERAL, "In rephist: %"PRIu64" used by %d Tors.",
324  dump_routerlist_mem_usage(severity);
325  dump_cell_pool_usage(severity);
326  dump_dns_mem_usage(severity);
327  tor_log_mallinfo(severity);
328 }
329 
330 /** Write all statistics to the log, with log level <b>severity</b>. Called
331  * in response to a SIGUSR1. */
332 static void
333 dumpstats(int severity)
334 {
335  time_t now = time(NULL);
336  time_t elapsed;
337  size_t rbuf_cap, wbuf_cap, rbuf_len, wbuf_len;
338 
339  tor_log(severity, LD_GENERAL, "Dumping stats:");
340 
342  int i = conn_sl_idx;
343  tor_log(severity, LD_GENERAL,
344  "Conn %d (socket %d) is a %s, created %d secs ago",
345  i, (int)conn->s,
346  connection_describe(conn),
347  (int)(now - conn->timestamp_created));
348  if (!connection_is_listener(conn)) {
349  tor_log(severity,LD_GENERAL,
350  "Conn %d: %d bytes waiting on inbuf (len %d, last read %d secs ago)",
351  i,
352  (int)connection_get_inbuf_len(conn),
353  (int)buf_allocation(conn->inbuf),
354  (int)(now - conn->timestamp_last_read_allowed));
355  tor_log(severity,LD_GENERAL,
356  "Conn %d: %d bytes waiting on outbuf "
357  "(len %d, last written %d secs ago)",i,
358  (int)connection_get_outbuf_len(conn),
359  (int)buf_allocation(conn->outbuf),
360  (int)(now - conn->timestamp_last_write_allowed));
361  if (conn->type == CONN_TYPE_OR) {
362  or_connection_t *or_conn = TO_OR_CONN(conn);
363  if (or_conn->tls) {
364  if (tor_tls_get_buffer_sizes(or_conn->tls, &rbuf_cap, &rbuf_len,
365  &wbuf_cap, &wbuf_len) == 0) {
366  tor_log(severity, LD_GENERAL,
367  "Conn %d: %d/%d bytes used on OpenSSL read buffer; "
368  "%d/%d bytes used on write buffer.",
369  i, (int)rbuf_len, (int)rbuf_cap, (int)wbuf_len, (int)wbuf_cap);
370  }
371  }
372  }
373  }
374  circuit_dump_by_conn(conn, severity); /* dump info about all the circuits
375  * using this conn */
376  } SMARTLIST_FOREACH_END(conn);
377 
378  channel_dumpstats(severity);
379  channel_listener_dumpstats(severity);
380 
381  tor_log(severity, LD_NET,
382  "Cells processed: %"PRIu64" padding\n"
383  " %"PRIu64" create\n"
384  " %"PRIu64" created\n"
385  " %"PRIu64" relay\n"
386  " (%"PRIu64" relayed)\n"
387  " (%"PRIu64" delivered)\n"
388  " %"PRIu64" destroy",
397  tor_log(severity,LD_NET,"Average packaged cell fullness: %2.3f%%",
398  100*(((double)stats_n_data_bytes_packaged) /
401  tor_log(severity,LD_NET,"Average delivered cell fullness: %2.3f%%",
402  100*(((double)stats_n_data_bytes_received) /
404 
405  cpuworker_log_onionskin_overhead(severity, ONION_HANDSHAKE_TYPE_TAP, "TAP");
406  cpuworker_log_onionskin_overhead(severity, ONION_HANDSHAKE_TYPE_NTOR,"ntor");
407 
408  if (now - time_of_process_start >= 0)
409  elapsed = now - time_of_process_start;
410  else
411  elapsed = 0;
412 
413  if (elapsed) {
414  tor_log(severity, LD_NET,
415  "Average bandwidth: %"PRIu64"/%d = %d bytes/sec reading",
416  (get_bytes_read()),
417  (int)elapsed,
418  (int) (get_bytes_read()/elapsed));
419  tor_log(severity, LD_NET,
420  "Average bandwidth: %"PRIu64"/%d = %d bytes/sec writing",
421  (get_bytes_written()),
422  (int)elapsed,
423  (int) (get_bytes_written()/elapsed));
424  }
425 
426  tor_log(severity, LD_NET, "--------------- Dumping memory information:");
427  dumpmemusage(severity);
428 
429  rep_hist_dump_stats(now,severity);
430  rend_service_dump_stats(severity);
431  hs_service_dump_stats(severity);
432 }
433 
434 #ifdef _WIN32
435 #define UNIX_ONLY 0
436 #else
437 #define UNIX_ONLY 1
438 #endif
439 
440 static struct {
441  /** A numeric code for this signal. Must match the signal value if
442  * try_to_register is true. */
444  /** True if we should try to register this signal with libevent and catch
445  * corresponding posix signals. False otherwise. */
447  /** Pointer to hold the event object constructed for this signal. */
448  struct event *signal_event;
449 } signal_handlers[] = {
450 #ifdef SIGINT
451  { SIGINT, UNIX_ONLY, NULL }, /* do a controlled slow shutdown */
452 #endif
453 #ifdef SIGTERM
454  { SIGTERM, UNIX_ONLY, NULL }, /* to terminate now */
455 #endif
456 #ifdef SIGPIPE
457  { SIGPIPE, UNIX_ONLY, NULL }, /* otherwise SIGPIPE kills us */
458 #endif
459 #ifdef SIGUSR1
460  { SIGUSR1, UNIX_ONLY, NULL }, /* dump stats */
461 #endif
462 #ifdef SIGUSR2
463  { SIGUSR2, UNIX_ONLY, NULL }, /* go to loglevel debug */
464 #endif
465 #ifdef SIGHUP
466  { SIGHUP, UNIX_ONLY, NULL }, /* to reload config, retry conns, etc */
467 #endif
468 #ifdef SIGXFSZ
469  { SIGXFSZ, UNIX_ONLY, NULL }, /* handle file-too-big resource exhaustion */
470 #endif
471 #ifdef SIGCHLD
472  { SIGCHLD, UNIX_ONLY, NULL }, /* handle dns/cpu workers that exit */
473 #endif
474  /* These are controller-only */
475  { SIGNEWNYM, 0, NULL },
476  { SIGCLEARDNSCACHE, 0, NULL },
477  { SIGHEARTBEAT, 0, NULL },
478  { SIGACTIVE, 0, NULL },
479  { SIGDORMANT, 0, NULL },
480  { -1, -1, NULL }
481 };
482 
483 /** Set up the signal handler events for this process, and register them
484  * with libevent if appropriate. */
485 void
487 {
488  int i;
489  const int enabled = !get_options()->DisableSignalHandlers;
490 
491  for (i = 0; signal_handlers[i].signal_value >= 0; ++i) {
492  /* Signal handlers are only registered with libevent if they need to catch
493  * real POSIX signals. We construct these signal handler events in either
494  * case, though, so that controllers can activate them with the SIGNAL
495  * command.
496  */
497  if (enabled && signal_handlers[i].try_to_register) {
498  signal_handlers[i].signal_event =
499  tor_evsignal_new(tor_libevent_get_base(),
500  signal_handlers[i].signal_value,
502  &signal_handlers[i].signal_value);
503  if (event_add(signal_handlers[i].signal_event, NULL))
504  log_warn(LD_BUG, "Error from libevent when adding "
505  "event for signal %d",
506  signal_handlers[i].signal_value);
507  } else {
508  signal_handlers[i].signal_event =
509  tor_event_new(tor_libevent_get_base(), -1,
510  EV_SIGNAL, signal_callback,
511  &signal_handlers[i].signal_value);
512  }
513  }
514 
515 #ifdef _WIN32
516  /* Windows lacks traditional POSIX signals but WinAPI provides a function
517  * to handle control signals like Ctrl+C in the console, we can use this to
518  * simulate the SIGINT signal */
519  if (enabled) SetConsoleCtrlHandler(process_win32_console_ctrl, TRUE);
520 #endif
521 }
522 
523 /* Cause the signal handler for signal_num to be called in the event loop. */
524 void
525 activate_signal(int signal_num)
526 {
527  int i;
528  for (i = 0; signal_handlers[i].signal_value >= 0; ++i) {
529  if (signal_handlers[i].signal_value == signal_num) {
530  event_active(signal_handlers[i].signal_event, EV_SIGNAL, 1);
531  return;
532  }
533  }
534 }
535 
536 /** Main entry point for the Tor command-line client. Return 0 on "success",
537  * negative on "failure", and positive on "success and exit".
538  */
539 int
540 tor_init(int argc, char *argv[])
541 {
542  char progname[256];
544  bool running_tor = false;
545 
546  time_of_process_start = time(NULL);
548  /* Have the log set up with our application name. */
549  tor_snprintf(progname, sizeof(progname), "Tor %s", get_version());
550  log_set_application_name(progname);
551 
552  /* Initialize the history structures. */
553  rep_hist_init();
554  bwhist_init();
555  /* Initialize the service cache. */
556  rend_cache_init();
557  addressmap_init(); /* Init the client dns cache. Do it always, since it's
558  * cheap. */
559 
560  /* Initialize the HS subsystem. */
561  hs_init();
562 
563  {
564  /* We check for the "quiet"/"hush" settings first, since they decide
565  whether we log anything at all to stdout. */
566  parsed_cmdline_t *cmdline;
567  cmdline = config_parse_commandline(argc, argv, 1);
568  if (cmdline) {
569  quiet = cmdline->quiet_level;
570  running_tor = (cmdline->command == CMD_RUN_TOR);
571  }
572  parsed_cmdline_free(cmdline);
573  }
574 
575  /* give it somewhere to log to initially */
577  quiet_level = quiet;
578 
579  {
580  const char *version = get_version();
581 
582  log_notice(LD_GENERAL, "Tor %s running on %s with Libevent %s, "
583  "%s %s, Zlib %s, Liblzma %s, Libzstd %s and %s %s as libc.",
584  version,
585  get_uname(),
589  tor_compress_supports_method(ZLIB_METHOD) ?
590  tor_compress_version_str(ZLIB_METHOD) : "N/A",
591  tor_compress_supports_method(LZMA_METHOD) ?
592  tor_compress_version_str(LZMA_METHOD) : "N/A",
593  tor_compress_supports_method(ZSTD_METHOD) ?
594  tor_compress_version_str(ZSTD_METHOD) : "N/A",
596  tor_libc_get_name() : "Unknown",
598 
599  log_notice(LD_GENERAL, "Tor can't help you if you use it wrong! "
600  "Learn how to be safe at "
601  "https://www.torproject.org/download/download#warning");
602 
603  if (strstr(version, "alpha") || strstr(version, "beta"))
604  log_notice(LD_GENERAL, "This version is not a stable Tor release. "
605  "Expect more bugs than usual.");
606 
607  if (strlen(risky_option_list) && running_tor) {
608  log_warn(LD_GENERAL, "This build of Tor has been compiled with one "
609  "or more options that might make it less reliable or secure! "
610  "They are:%s", risky_option_list);
611  }
612 
614  }
615 
616 #ifdef HAVE_RUST
617  rust_log_welcome_string();
618 #endif /* defined(HAVE_RUST) */
619 
620  /* Warn _if_ the tracing subsystem is built in. */
621  tracing_log_warning();
622 
623  int init_rv = options_init_from_torrc(argc,argv);
624  if (init_rv < 0) {
625  log_err(LD_CONFIG,"Reading config failed--see warnings above.");
626  return -1;
627  } else if (init_rv > 0) {
628  // We succeeded, and should exit anyway -- probably the user just said
629  // "--version" or something like that.
630  return 1;
631  }
632 
633  /* Initialize channelpadding and circpad parameters to defaults
634  * until we get a consensus */
637 
638  /* Initialize circuit padding to defaults+torrc until we get a consensus */
640 
641  /* Initialize hidden service DoS subsystem. We need to do this once the
642  * configuration object has been set because it can be accessed. */
643  hs_dos_init();
644 
645  /* Initialize predicted ports list after loading options */
646  predicted_ports_init();
647 
648 #ifndef _WIN32
649  if (geteuid()==0)
650  log_warn(LD_GENERAL,"You are running Tor as root. You don't need to, "
651  "and you probably shouldn't.");
652 #endif
653 
654  /* Scan/clean unparseable descriptors; after reading config */
656 
657  return 0;
658 }
659 
660 /** A lockfile structure, used to prevent two Tors from messing with the
661  * data directory at once. If this variable is non-NULL, we're holding
662  * the lockfile. */
663 static tor_lockfile_t *lockfile = NULL;
664 
665 /** Try to grab the lock file described in <b>options</b>, if we do not
666  * already have it. If <b>err_if_locked</b> is true, warn if somebody else is
667  * holding the lock, and exit if we can't get it after waiting. Otherwise,
668  * return -1 if we can't get the lockfile. Return 0 on success.
669  */
670 int
671 try_locking(const or_options_t *options, int err_if_locked)
672 {
673  if (lockfile)
674  return 0;
675  else {
676  char *fname = options_get_datadir_fname(options, "lock");
677  int already_locked = 0;
678  tor_lockfile_t *lf = tor_lockfile_lock(fname, 0, &already_locked);
679  tor_free(fname);
680  if (!lf) {
681  if (err_if_locked && already_locked) {
682  int r;
683  log_warn(LD_GENERAL, "It looks like another Tor process is running "
684  "with the same data directory. Waiting 5 seconds to see "
685  "if it goes away.");
686 #ifndef _WIN32
687  sleep(5);
688 #else
689  Sleep(5000);
690 #endif
691  r = try_locking(options, 0);
692  if (r<0) {
693  log_err(LD_GENERAL, "No, it's still there. Exiting.");
694  return -1;
695  }
696  return r;
697  }
698  return -1;
699  }
700  lockfile = lf;
701  return 0;
702  }
703 }
704 
705 /** Return true iff we've successfully acquired the lock file. */
706 int
708 {
709  return lockfile != NULL;
710 }
711 
712 /** If we have successfully acquired the lock file, release it. */
713 void
715 {
716  if (lockfile) {
718  lockfile = NULL;
719  }
720 }
721 
722 /**
723  * Remove the specified file, and log a warning if the operation fails for
724  * any reason other than the file not existing. Ignores NULL filenames.
725  */
726 void
727 tor_remove_file(const char *filename)
728 {
729  if (filename && tor_unlink(filename) != 0 && errno != ENOENT) {
730  log_warn(LD_FS, "Couldn't unlink %s: %s",
731  filename, strerror(errno));
732  }
733 }
734 
735 /** Read/create keys as needed, and echo our fingerprint to stdout. */
736 static int
738 {
739  const or_options_t *options = get_options();
740  const char *arg = options->command_arg;
741  char rsa[FINGERPRINT_LEN + 1];
742  crypto_pk_t *k;
743  const ed25519_public_key_t *edkey;
744  const char *nickname = options->Nickname;
745  sandbox_disable_getaddrinfo_cache();
746 
747  bool show_rsa = !strcmp(arg, "") || !strcmp(arg, "rsa");
748  bool show_ed25519 = !strcmp(arg, "ed25519");
749  if (!show_rsa && !show_ed25519) {
750  log_err(LD_GENERAL,
751  "If you give a key type, you must specify 'rsa' or 'ed25519'. Exiting.");
752  return -1;
753  }
754 
755  if (!server_mode(options)) {
756  log_err(LD_GENERAL,
757  "Clients don't have long-term identity keys. Exiting.");
758  return -1;
759  }
760  tor_assert(nickname);
761  if (init_keys() < 0) {
762  log_err(LD_GENERAL, "Error initializing keys; exiting.");
763  return -1;
764  }
765  if (!(k = get_server_identity_key())) {
766  log_err(LD_GENERAL, "Error: missing RSA identity key.");
767  return -1;
768  }
769  if (crypto_pk_get_fingerprint(k, rsa, 1) < 0) {
770  log_err(LD_BUG, "Error computing RSA fingerprint");
771  return -1;
772  }
773  if (!(edkey = get_master_identity_key())) {
774  log_err(LD_GENERAL,"Error: missing ed25519 identity key.");
775  return -1;
776  }
777  if (show_rsa) {
778  printf("%s %s\n", nickname, rsa);
779  }
780  if (show_ed25519) {
781  char ed25519[ED25519_BASE64_LEN + 1];
782  digest256_to_base64(ed25519, (const char *) edkey->pubkey);
783  printf("%s %s\n", nickname, ed25519);
784  }
785  return 0;
786 }
787 
788 /** Entry point for password hashing: take the desired password from
789  * the command line, and print its salted hash to stdout. **/
790 static void
792 {
793 
794  char output[256];
796 
798  key[S2K_RFC2440_SPECIFIER_LEN-1] = (uint8_t)96; /* Hash 64 K of data. */
800  get_options()->command_arg, strlen(get_options()->command_arg),
801  key);
802  base16_encode(output, sizeof(output), key, sizeof(key));
803  printf("16:%s\n",output);
804 }
805 
806 /** Entry point for configuration dumping: write the configuration to
807  * stdout. */
808 static int
810 {
811  const or_options_t *options = get_options();
812  const char *arg = options->command_arg;
813  int how;
814  char *opts;
815 
816  if (!strcmp(arg, "short")) {
817  how = OPTIONS_DUMP_MINIMAL;
818  } else if (!strcmp(arg, "non-builtin")) {
819  // Deprecated since 0.4.5.1-alpha.
820  fprintf(stderr, "'non-builtin' is deprecated; use 'short' instead.\n");
821  how = OPTIONS_DUMP_MINIMAL;
822  } else if (!strcmp(arg, "full")) {
823  how = OPTIONS_DUMP_ALL;
824  } else {
825  fprintf(stderr, "No valid argument to --dump-config found!\n");
826  fprintf(stderr, "Please select 'short' or 'full'.\n");
827 
828  return -1;
829  }
830 
831  opts = options_dump(options, how);
832  printf("%s", opts);
833  tor_free(opts);
834 
835  return 0;
836 }
837 
838 static void
839 init_addrinfo(void)
840 {
841  if (! server_mode(get_options()) || get_options()->Address) {
842  /* We don't need to seed our own hostname, because we won't be calling
843  * resolve_my_address on it.
844  */
845  return;
846  }
847  char hname[256];
848 
849  // host name to sandbox
850  gethostname(hname, sizeof(hname));
851  tor_add_addrinfo(hname);
852 }
853 
854 static sandbox_cfg_t*
855 sandbox_init_filter(void)
856 {
857  const or_options_t *options = get_options();
859  int i;
860 
862  get_cachedir_fname("cached-status"));
863 
864 #define OPEN(name) \
865  sandbox_cfg_allow_open_filename(&cfg, tor_strdup(name))
866 
867 #define OPENDIR(dir) \
868  sandbox_cfg_allow_opendir_dirname(&cfg, tor_strdup(dir))
869 
870 #define OPEN_DATADIR(name) \
871  sandbox_cfg_allow_open_filename(&cfg, get_datadir_fname(name))
872 
873 #define OPEN_DATADIR2(name, name2) \
874  sandbox_cfg_allow_open_filename(&cfg, get_datadir_fname2((name), (name2)))
875 
876 #define OPEN_DATADIR_SUFFIX(name, suffix) do { \
877  OPEN_DATADIR(name); \
878  OPEN_DATADIR(name suffix); \
879  } while (0)
880 
881 #define OPEN_DATADIR2_SUFFIX(name, name2, suffix) do { \
882  OPEN_DATADIR2(name, name2); \
883  OPEN_DATADIR2(name, name2 suffix); \
884  } while (0)
885 
886 // KeyDirectory is a directory, but it is only opened in check_private_dir
887 // which calls open instead of opendir
888 #define OPEN_KEY_DIRECTORY() \
889  OPEN(options->KeyDirectory)
890 #define OPEN_CACHEDIR(name) \
891  sandbox_cfg_allow_open_filename(&cfg, get_cachedir_fname(name))
892 #define OPEN_CACHEDIR_SUFFIX(name, suffix) do { \
893  OPEN_CACHEDIR(name); \
894  OPEN_CACHEDIR(name suffix); \
895  } while (0)
896 #define OPEN_KEYDIR(name) \
897  sandbox_cfg_allow_open_filename(&cfg, get_keydir_fname(name))
898 #define OPEN_KEYDIR_SUFFIX(name, suffix) do { \
899  OPEN_KEYDIR(name); \
900  OPEN_KEYDIR(name suffix); \
901  } while (0)
902 
903  // DataDirectory is a directory, but it is only opened in check_private_dir
904  // which calls open instead of opendir
905  OPEN(options->DataDirectory);
906  OPEN_KEY_DIRECTORY();
907 
908  OPEN_CACHEDIR_SUFFIX("cached-certs", ".tmp");
909  OPEN_CACHEDIR_SUFFIX("cached-consensus", ".tmp");
910  OPEN_CACHEDIR_SUFFIX("unverified-consensus", ".tmp");
911  OPEN_CACHEDIR_SUFFIX("unverified-microdesc-consensus", ".tmp");
912  OPEN_CACHEDIR_SUFFIX("cached-microdesc-consensus", ".tmp");
913  OPEN_CACHEDIR_SUFFIX("cached-microdescs", ".tmp");
914  OPEN_CACHEDIR_SUFFIX("cached-microdescs.new", ".tmp");
915  OPEN_CACHEDIR_SUFFIX("cached-descriptors", ".tmp");
916  OPEN_CACHEDIR_SUFFIX("cached-descriptors.new", ".tmp");
917  OPEN_CACHEDIR("cached-descriptors.tmp.tmp");
918  OPEN_CACHEDIR_SUFFIX("cached-extrainfo", ".tmp");
919  OPEN_CACHEDIR_SUFFIX("cached-extrainfo.new", ".tmp");
920  OPEN_CACHEDIR("cached-extrainfo.tmp.tmp");
921 
922  OPEN_DATADIR_SUFFIX("state", ".tmp");
923  OPEN_DATADIR_SUFFIX("sr-state", ".tmp");
924  OPEN_DATADIR_SUFFIX("unparseable-desc", ".tmp");
925  OPEN_DATADIR_SUFFIX("v3-status-votes", ".tmp");
926  OPEN_DATADIR("key-pinning-journal");
927  OPEN("/dev/srandom");
928  OPEN("/dev/urandom");
929  OPEN("/dev/random");
930  OPEN("/etc/hosts");
931  OPEN("/proc/meminfo");
932 
933  if (options->BridgeAuthoritativeDir)
934  OPEN_DATADIR_SUFFIX("networkstatus-bridges", ".tmp");
935 
936  if (authdir_mode(options))
937  OPEN_DATADIR("approved-routers");
938 
939  if (options->ServerDNSResolvConfFile)
941  tor_strdup(options->ServerDNSResolvConfFile));
942  else
943  sandbox_cfg_allow_open_filename(&cfg, tor_strdup("/etc/resolv.conf"));
944 
945  for (i = 0; i < 2; ++i) {
946  if (get_torrc_fname(i)) {
947  sandbox_cfg_allow_open_filename(&cfg, tor_strdup(get_torrc_fname(i)));
948  }
949  }
950 
951  SMARTLIST_FOREACH(options->FilesOpenedByIncludes, char *, f, {
952  if (file_status(f) == FN_DIR) {
953  OPENDIR(f);
954  } else {
955  OPEN(f);
956  }
957  });
958 
959 #define RENAME_SUFFIX(name, suffix) \
960  sandbox_cfg_allow_rename(&cfg, \
961  get_datadir_fname(name suffix), \
962  get_datadir_fname(name))
963 
964 #define RENAME_SUFFIX2(prefix, name, suffix) \
965  sandbox_cfg_allow_rename(&cfg, \
966  get_datadir_fname2(prefix, name suffix), \
967  get_datadir_fname2(prefix, name))
968 
969 #define RENAME_CACHEDIR_SUFFIX(name, suffix) \
970  sandbox_cfg_allow_rename(&cfg, \
971  get_cachedir_fname(name suffix), \
972  get_cachedir_fname(name))
973 
974 #define RENAME_KEYDIR_SUFFIX(name, suffix) \
975  sandbox_cfg_allow_rename(&cfg, \
976  get_keydir_fname(name suffix), \
977  get_keydir_fname(name))
978 
979  RENAME_CACHEDIR_SUFFIX("cached-certs", ".tmp");
980  RENAME_CACHEDIR_SUFFIX("cached-consensus", ".tmp");
981  RENAME_CACHEDIR_SUFFIX("unverified-consensus", ".tmp");
982  RENAME_CACHEDIR_SUFFIX("unverified-microdesc-consensus", ".tmp");
983  RENAME_CACHEDIR_SUFFIX("cached-microdesc-consensus", ".tmp");
984  RENAME_CACHEDIR_SUFFIX("cached-microdescs", ".tmp");
985  RENAME_CACHEDIR_SUFFIX("cached-microdescs", ".new");
986  RENAME_CACHEDIR_SUFFIX("cached-microdescs.new", ".tmp");
987  RENAME_CACHEDIR_SUFFIX("cached-descriptors", ".tmp");
988  RENAME_CACHEDIR_SUFFIX("cached-descriptors", ".new");
989  RENAME_CACHEDIR_SUFFIX("cached-descriptors.new", ".tmp");
990  RENAME_CACHEDIR_SUFFIX("cached-extrainfo", ".tmp");
991  RENAME_CACHEDIR_SUFFIX("cached-extrainfo", ".new");
992  RENAME_CACHEDIR_SUFFIX("cached-extrainfo.new", ".tmp");
993 
994  RENAME_SUFFIX("state", ".tmp");
995  RENAME_SUFFIX("sr-state", ".tmp");
996  RENAME_SUFFIX("unparseable-desc", ".tmp");
997  RENAME_SUFFIX("v3-status-votes", ".tmp");
998 
999  if (options->BridgeAuthoritativeDir)
1000  RENAME_SUFFIX("networkstatus-bridges", ".tmp");
1001 
1002 #define STAT_DATADIR(name) \
1003  sandbox_cfg_allow_stat_filename(&cfg, get_datadir_fname(name))
1004 
1005 #define STAT_CACHEDIR(name) \
1006  sandbox_cfg_allow_stat_filename(&cfg, get_cachedir_fname(name))
1007 
1008 #define STAT_DATADIR2(name, name2) \
1009  sandbox_cfg_allow_stat_filename(&cfg, get_datadir_fname2((name), (name2)))
1010 
1011 #define STAT_KEY_DIRECTORY() \
1012  sandbox_cfg_allow_stat_filename(&cfg, tor_strdup(options->KeyDirectory))
1013 
1014  STAT_DATADIR(NULL);
1015  STAT_DATADIR("lock");
1016  STAT_DATADIR("state");
1017  STAT_DATADIR("router-stability");
1018 
1019  STAT_CACHEDIR("cached-extrainfo.new");
1020 
1021  {
1022  smartlist_t *files = smartlist_new();
1024  SMARTLIST_FOREACH(files, char *, file_name, {
1025  /* steals reference */
1026  sandbox_cfg_allow_open_filename(&cfg, file_name);
1027  });
1028  smartlist_free(files);
1029  }
1030 
1031  {
1032  smartlist_t *files = smartlist_new();
1033  smartlist_t *dirs = smartlist_new();
1035  SMARTLIST_FOREACH(files, char *, file_name, {
1036  char *tmp_name = NULL;
1037  tor_asprintf(&tmp_name, "%s.tmp", file_name);
1038  sandbox_cfg_allow_rename(&cfg,
1039  tor_strdup(tmp_name), tor_strdup(file_name));
1040  /* steals references */
1041  sandbox_cfg_allow_open_filename(&cfg, file_name);
1042  sandbox_cfg_allow_open_filename(&cfg, tmp_name);
1043  });
1044  SMARTLIST_FOREACH(dirs, char *, dir, {
1045  /* steals reference */
1047  });
1048  smartlist_free(files);
1049  smartlist_free(dirs);
1050  }
1051 
1052  {
1053  char *fname;
1054  if ((fname = get_controller_cookie_file_name())) {
1055  sandbox_cfg_allow_open_filename(&cfg, fname);
1056  }
1057  if ((fname = get_ext_or_auth_cookie_file_name())) {
1058  sandbox_cfg_allow_open_filename(&cfg, fname);
1059  }
1060  }
1061 
1063  if (!port->is_unix_addr)
1064  continue;
1065  /* When we open an AF_UNIX address, we want permission to open the
1066  * directory that holds it. */
1067  char *dirname = tor_strdup(port->unix_addr);
1068  if (get_parent_directory(dirname) == 0) {
1069  OPENDIR(dirname);
1070  }
1071  tor_free(dirname);
1072  sandbox_cfg_allow_chmod_filename(&cfg, tor_strdup(port->unix_addr));
1073  sandbox_cfg_allow_chown_filename(&cfg, tor_strdup(port->unix_addr));
1074  } SMARTLIST_FOREACH_END(port);
1075 
1076  if (options->DirPortFrontPage) {
1078  tor_strdup(options->DirPortFrontPage));
1079  }
1080 
1081  // orport
1082  if (server_mode(get_options())) {
1083 
1084  OPEN_KEYDIR_SUFFIX("secret_id_key", ".tmp");
1085  OPEN_KEYDIR_SUFFIX("secret_onion_key", ".tmp");
1086  OPEN_KEYDIR_SUFFIX("secret_onion_key_ntor", ".tmp");
1087  OPEN_KEYDIR("secret_id_key.old");
1088  OPEN_KEYDIR("secret_onion_key.old");
1089  OPEN_KEYDIR("secret_onion_key_ntor.old");
1090 
1091  OPEN_KEYDIR_SUFFIX("ed25519_master_id_secret_key", ".tmp");
1092  OPEN_KEYDIR_SUFFIX("ed25519_master_id_secret_key_encrypted", ".tmp");
1093  OPEN_KEYDIR_SUFFIX("ed25519_master_id_public_key", ".tmp");
1094  OPEN_KEYDIR_SUFFIX("ed25519_signing_secret_key", ".tmp");
1095  OPEN_KEYDIR_SUFFIX("ed25519_signing_secret_key_encrypted", ".tmp");
1096  OPEN_KEYDIR_SUFFIX("ed25519_signing_public_key", ".tmp");
1097  OPEN_KEYDIR_SUFFIX("ed25519_signing_cert", ".tmp");
1098 
1099  OPEN_DATADIR2_SUFFIX("stats", "bridge-stats", ".tmp");
1100  OPEN_DATADIR2_SUFFIX("stats", "dirreq-stats", ".tmp");
1101 
1102  OPEN_DATADIR2_SUFFIX("stats", "entry-stats", ".tmp");
1103  OPEN_DATADIR2_SUFFIX("stats", "exit-stats", ".tmp");
1104  OPEN_DATADIR2_SUFFIX("stats", "buffer-stats", ".tmp");
1105  OPEN_DATADIR2_SUFFIX("stats", "conn-stats", ".tmp");
1106  OPEN_DATADIR2_SUFFIX("stats", "hidserv-stats", ".tmp");
1107  OPEN_DATADIR2_SUFFIX("stats", "hidserv-v3-stats", ".tmp");
1108 
1109  OPEN_DATADIR("approved-routers");
1110  OPEN_DATADIR_SUFFIX("fingerprint", ".tmp");
1111  OPEN_DATADIR_SUFFIX("fingerprint-ed25519", ".tmp");
1112  OPEN_DATADIR_SUFFIX("hashed-fingerprint", ".tmp");
1113  OPEN_DATADIR_SUFFIX("router-stability", ".tmp");
1114 
1115  OPEN("/etc/resolv.conf");
1116 
1117  RENAME_SUFFIX("fingerprint", ".tmp");
1118  RENAME_SUFFIX("fingerprint-ed25519", ".tmp");
1119  RENAME_KEYDIR_SUFFIX("secret_onion_key_ntor", ".tmp");
1120 
1121  RENAME_KEYDIR_SUFFIX("secret_id_key", ".tmp");
1122  RENAME_KEYDIR_SUFFIX("secret_id_key.old", ".tmp");
1123  RENAME_KEYDIR_SUFFIX("secret_onion_key", ".tmp");
1124  RENAME_KEYDIR_SUFFIX("secret_onion_key.old", ".tmp");
1125 
1126  RENAME_SUFFIX2("stats", "bridge-stats", ".tmp");
1127  RENAME_SUFFIX2("stats", "dirreq-stats", ".tmp");
1128  RENAME_SUFFIX2("stats", "entry-stats", ".tmp");
1129  RENAME_SUFFIX2("stats", "exit-stats", ".tmp");
1130  RENAME_SUFFIX2("stats", "buffer-stats", ".tmp");
1131  RENAME_SUFFIX2("stats", "conn-stats", ".tmp");
1132  RENAME_SUFFIX2("stats", "hidserv-stats", ".tmp");
1133  RENAME_SUFFIX2("stats", "hidserv-v3-stats", ".tmp");
1134  RENAME_SUFFIX("hashed-fingerprint", ".tmp");
1135  RENAME_SUFFIX("router-stability", ".tmp");
1136 
1137  RENAME_KEYDIR_SUFFIX("ed25519_master_id_secret_key", ".tmp");
1138  RENAME_KEYDIR_SUFFIX("ed25519_master_id_secret_key_encrypted", ".tmp");
1139  RENAME_KEYDIR_SUFFIX("ed25519_master_id_public_key", ".tmp");
1140  RENAME_KEYDIR_SUFFIX("ed25519_signing_secret_key", ".tmp");
1141  RENAME_KEYDIR_SUFFIX("ed25519_signing_cert", ".tmp");
1142 
1143  sandbox_cfg_allow_rename(&cfg,
1144  get_keydir_fname("secret_onion_key"),
1145  get_keydir_fname("secret_onion_key.old"));
1146  sandbox_cfg_allow_rename(&cfg,
1147  get_keydir_fname("secret_onion_key_ntor"),
1148  get_keydir_fname("secret_onion_key_ntor.old"));
1149 
1150  STAT_KEY_DIRECTORY();
1151  OPEN_DATADIR("stats");
1152  STAT_DATADIR("stats");
1153  STAT_DATADIR2("stats", "dirreq-stats");
1154 
1156  }
1157 
1158  init_addrinfo();
1159 
1160  return cfg;
1161 }
1162 
1163 int
1164 run_tor_main_loop(void)
1165 {
1166  handle_signals();
1169 
1170  /* load the private keys, if we're supposed to have them, and set up the
1171  * TLS context. */
1172  if (! client_identity_key_is_set()) {
1173  if (init_keys() < 0) {
1174  log_err(LD_OR, "Error initializing keys; exiting");
1175  return -1;
1176  }
1177  }
1178 
1179  /* Set up our buckets */
1181 
1182  /* initialize the bootstrap status events to know we're starting up */
1183  control_event_bootstrap(BOOTSTRAP_STATUS_STARTING, 0);
1184 
1185  /* Initialize the keypinning log. */
1186  if (authdir_mode_v3(get_options())) {
1187  char *fname = get_datadir_fname("key-pinning-journal");
1188  int r = 0;
1189  if (keypin_load_journal(fname)<0) {
1190  log_err(LD_DIR, "Error loading key-pinning journal: %s",strerror(errno));
1191  r = -1;
1192  }
1193  if (keypin_open_journal(fname)<0) {
1194  log_err(LD_DIR, "Error opening key-pinning journal: %s",strerror(errno));
1195  r = -1;
1196  }
1197  tor_free(fname);
1198  if (r)
1199  return r;
1200  }
1201  {
1202  /* This is the old name for key-pinning-journal. These got corrupted
1203  * in a couple of cases by #16530, so we started over. See #16580 for
1204  * the rationale and for other options we didn't take. We can remove
1205  * this code once all the authorities that ran 0.2.7.1-alpha-dev are
1206  * upgraded.
1207  */
1208  char *fname = get_datadir_fname("key-pinning-entries");
1209  unlink(fname);
1210  tor_free(fname);
1211  }
1212 
1213  if (trusted_dirs_reload_certs()) {
1214  log_warn(LD_DIR,
1215  "Couldn't load all cached v3 certificates. Starting anyway.");
1216  }
1218  return -1;
1219  }
1220  /* load the routers file, or assign the defaults. */
1221  if (router_reload_router_list()) {
1222  return -1;
1223  }
1224  /* load the networkstatuses. (This launches a download for new routers as
1225  * appropriate.)
1226  */
1227  const time_t now = time(NULL);
1228  directory_info_has_arrived(now, 1, 0);
1229 
1231  /* launch cpuworkers. Need to do this *after* we've read the onion key. */
1232  cpu_init();
1233  }
1235 
1236  /* Setup shared random protocol subsystem. */
1237  if (authdir_mode_v3(get_options())) {
1238  if (sr_init(1) < 0) {
1239  return -1;
1240  }
1241  }
1242 
1243  /* initialize dns resolve map, spawn workers if needed */
1244  if (dns_init() < 0) {
1245  if (get_options()->ServerDNSAllowBrokenConfig)
1246  log_warn(LD_GENERAL, "Couldn't set up any working nameservers. "
1247  "Network not up yet? Will try again soon.");
1248  else {
1249  log_err(LD_GENERAL,"Error initializing dns subsystem; exiting. To "
1250  "retry instead, set the ServerDNSAllowBrokenResolvConf option.");
1251  }
1252  }
1253 
1254 #ifdef HAVE_SYSTEMD
1255  {
1256  const int r = sd_notify(0, "READY=1");
1257  if (r < 0) {
1258  log_warn(LD_GENERAL, "Unable to send readiness to systemd: %s",
1259  strerror(r));
1260  } else if (r > 0) {
1261  log_notice(LD_GENERAL, "Signaled readiness to systemd");
1262  } else {
1263  log_info(LD_GENERAL, "Systemd NOTIFY_SOCKET not present.");
1264  }
1265  }
1266 #endif /* defined(HAVE_SYSTEMD) */
1267 
1268  return do_main_loop();
1269 }
1270 
1271 /** Install the publish/subscribe relationships for all the subsystems. */
1272 void
1274 {
1275  pubsub_builder_t *builder = pubsub_builder_new();
1276  int r = subsystems_add_pubsub(builder);
1277  tor_assert(r == 0);
1278  r = tor_mainloop_connect_pubsub(builder); // consumes builder
1279  tor_assert(r == 0);
1280 }
1281 
1282 /** Connect the mainloop to its publish/subscribe message delivery events if
1283  * appropriate, and configure the global channels appropriately. */
1284 void
1286 {
1287  if (get_options()->command == CMD_RUN_TOR) {
1289  /* XXXX For each pubsub channel, its delivery strategy should be set at
1290  * this XXXX point, using tor_mainloop_set_delivery_strategy().
1291  */
1294  }
1295 }
1296 
1297 /* Main entry point for the Tor process. Called from tor_main(), and by
1298  * anybody embedding Tor. */
1299 int
1301 {
1302  int result = 0;
1303 
1304 #ifdef EVENT_SET_MEM_FUNCTIONS_IMPLEMENTED
1305  event_set_mem_functions(tor_malloc_, tor_realloc_, tor_free_);
1306 #endif
1307 
1308  subsystems_init();
1309 
1311 
1312  int argc = tor_cfg->argc + tor_cfg->argc_owned;
1313  char **argv = tor_calloc(argc, sizeof(char*));
1314  memcpy(argv, tor_cfg->argv, tor_cfg->argc*sizeof(char*));
1315  if (tor_cfg->argc_owned)
1316  memcpy(argv + tor_cfg->argc, tor_cfg->argv_owned,
1317  tor_cfg->argc_owned*sizeof(char*));
1318 
1319  int done = 0;
1320  result = nt_service_parse_options(argc, argv, &done);
1321  if (POSSIBLE(done))
1322  goto done;
1323 
1324  pubsub_install();
1325 
1326  {
1327  int init_rv = tor_init(argc, argv);
1328  if (init_rv) {
1329  tor_free_all(0);
1330  result = (init_rv < 0) ? -1 : 0;
1331  goto done;
1332  }
1333  }
1334 
1335  pubsub_connect();
1336 
1337  if (get_options()->Sandbox && get_options()->command == CMD_RUN_TOR) {
1338  sandbox_cfg_t* cfg = sandbox_init_filter();
1339 
1340  if (sandbox_init(cfg)) {
1341  tor_free(argv);
1342  log_err(LD_BUG,"Failed to create syscall sandbox filter");
1343  tor_free_all(0);
1344  return -1;
1345  }
1346  tor_make_getaddrinfo_cache_active();
1347 
1348  // registering libevent rng
1349 #ifdef HAVE_EVUTIL_SECURE_RNG_SET_URANDOM_DEVICE_FILE
1350  evutil_secure_rng_set_urandom_device_file(
1351  (char*) sandbox_intern_string("/dev/urandom"));
1352 #endif
1353  }
1354 
1355  switch (get_options()->command) {
1356  case CMD_RUN_TOR:
1357  nt_service_set_state(SERVICE_RUNNING);
1358  result = run_tor_main_loop();
1359  break;
1360  case CMD_KEYGEN:
1361  result = load_ed_keys(get_options(), time(NULL)) < 0;
1362  break;
1363  case CMD_KEY_EXPIRATION:
1364  init_keys();
1365  result = log_cert_expiration();
1366  break;
1367  case CMD_LIST_FINGERPRINT:
1368  result = do_list_fingerprint();
1369  break;
1370  case CMD_HASH_PASSWORD:
1371  do_hash_password();
1372  result = 0;
1373  break;
1374  case CMD_VERIFY_CONFIG:
1375  if (quiet_level == QUIET_NONE)
1376  printf("Configuration was valid\n");
1377  result = 0;
1378  break;
1379  case CMD_DUMP_CONFIG:
1380  result = do_dump_config();
1381  break;
1382  case CMD_RUN_UNITTESTS: /* only set by test.c */
1383  case CMD_IMMEDIATE: /* Handled in config.c */
1384  default:
1385  log_warn(LD_BUG,"Illegal command number %d: internal error.",
1386  get_options()->command);
1387  result = -1;
1388  }
1389  tor_cleanup();
1390  done:
1391  tor_free(argv);
1392  return result;
1393 }
pubsub_connect
void pubsub_connect(void)
Definition: main.c:1285
or_options_t::ServerDNSResolvConfFile
char * ServerDNSResolvConfFile
Definition: or_options_st.h:618
routermode.h
Header file for routermode.c.
net_is_disabled
int net_is_disabled(void)
Definition: netstatus.c:25
tor_free
#define tor_free(p)
Definition: malloc.h:52
cpuworker_log_onionskin_overhead
void cpuworker_log_onionskin_overhead(int severity, int onionskin_type, const char *onionskin_type_name)
Definition: cpuworker.c:292
do_list_fingerprint
static int do_list_fingerprint(void)
Definition: main.c:737
routerlist_reset_warnings
void routerlist_reset_warnings(void)
Definition: routerlist.c:1533
tor_free_
void tor_free_(void *mem)
Definition: malloc.c:227
do_dump_config
static int do_dump_config(void)
Definition: main.c:809
tor_init_connection_lists
void tor_init_connection_lists(void)
Definition: mainloop.c:414
tor_api_internal.h
Internal declarations for in-process Tor API.
set_options
int set_options(or_options_t *new_val, char **msg)
Definition: config.c:968
CMD_RUN_UNITTESTS
@ CMD_RUN_UNITTESTS
Definition: tor_cmdline_mode.h:29
router_reload_router_list
int router_reload_router_list(void)
Definition: routerlist.c:460
DELIV_IMMEDIATE
@ DELIV_IMMEDIATE
Definition: mainloop_pubsub.h:52
compress.h
Headers for compress.c.
options_dump
char * options_dump(const or_options_t *options, int how_to_dump)
Definition: config.c:2929
ED25519_BASE64_LEN
#define ED25519_BASE64_LEN
Definition: x25519_sizes.h:43
CMD_LIST_FINGERPRINT
@ CMD_LIST_FINGERPRINT
Definition: tor_cmdline_mode.h:21
CMD_RUN_TOR
@ CMD_RUN_TOR
Definition: tor_cmdline_mode.h:20
approx_time
time_t approx_time(void)
Definition: approx_time.c:32
sandbox.h
Header file for sandbox.c.
tor_init
int tor_init(int argc, char *argv[])
Definition: main.c:540
get_bytes_read
uint64_t get_bytes_read(void)
Definition: mainloop.c:465
port_cfg_st.h
Listener port configuration structure.
bwhist_init
void bwhist_init(void)
Definition: bwhist.c:139
netstatus.h
Header for netstatus.c.
tor_assert
#define tor_assert(expr)
Definition: util_bug.h:102
control.h
Header file for control.c.
routerkeys.h
Header for routerkeys.c.
LD_BUG
#define LD_BUG
Definition: log.h:86
get_parent_directory
int get_parent_directory(char *fname)
Definition: path.c:195
authcert.h
Header file for authcert.c.
or_options_t::FilesOpenedByIncludes
struct smartlist_t * FilesOpenedByIncludes
Definition: or_options_st.h:1027
channel.h
Header file for channel.c.
time_of_process_start
time_t time_of_process_start
Definition: mainloop.c:144
bwhist.h
Header for feature/stats/bwhist.c.
LD_GENERAL
#define LD_GENERAL
Definition: log.h:62
sandbox_cfg_allow_openat_filename
int sandbox_cfg_allow_openat_filename(sandbox_cfg_t **cfg, char *file)
Definition: sandbox.c:1889
tor_main_configuration_t::argv
char ** argv
Definition: tor_api_internal.h:23
base16_encode
void base16_encode(char *dest, size_t destlen, const char *src, size_t srclen)
Definition: binascii.c:478
RELAY_PAYLOAD_SIZE
#define RELAY_PAYLOAD_SIZE
Definition: or.h:606
connection_bucket_init
void connection_bucket_init(void)
Definition: connection.c:3720
sandbox_cfg_allow_open_filename
int sandbox_cfg_allow_open_filename(sandbox_cfg_t **cfg, char *file)
Definition: sandbox.c:1882
process_descs.h
Header file for process_descs.c.
control_event_bootstrap
void control_event_bootstrap(bootstrap_status_t status, int progress)
Definition: control_bootstrap.c:188
circpad_machines_init
void circpad_machines_init(void)
Definition: circuitpadding.c:2773
pubsub_build.h
Header used for constructing the OO publish-subscribe facility.
circpad_new_consensus_params
void circpad_new_consensus_params(const networkstatus_t *ns)
Definition: circuitpadding.c:1318
note_user_activity
void note_user_activity(time_t now)
Definition: netstatus.c:63
uname.h
Header for uname.c.
dump_routerlist_mem_usage
void dump_routerlist_mem_usage(int severity)
Definition: routerlist.c:1060
CMD_IMMEDIATE
@ CMD_IMMEDIATE
Definition: tor_cmdline_mode.h:27
trace.h
Header for trace.c.
crypto_init.h
Headers for crypto_init.c.
get_torrc_fname
const char * get_torrc_fname(int defaults_fname)
Definition: config.c:4749
dump_cell_pool_usage
void dump_cell_pool_usage(int severity)
Definition: relay.c:2531
notify_pending_waitpid_callbacks
void notify_pending_waitpid_callbacks(void)
Definition: waitpid.c:141
channel_dumpstats
void channel_dumpstats(int severity)
Definition: channel.c:2071
stats_n_relay_cells_delivered
uint64_t stats_n_relay_cells_delivered
Definition: relay.c:132
tor_mainloop_connect_pubsub_events
void tor_mainloop_connect_pubsub_events(void)
Definition: mainloop_pubsub.c:84
pubsub_builder_t
struct pubsub_builder_t pubsub_builder_t
Definition: pubsub_build.h:28
quiet
int quiet
Definition: config.c:2470
smartlist_new
smartlist_t * smartlist_new(void)
Definition: smartlist_core.c:26
lockfile.h
Header for lockfile.c.
quiet_level.h
Declare the quiet_level enumeration and global.
or_connection_t
Definition: or_connection_st.h:22
circuit_dump_by_conn
void circuit_dump_by_conn(connection_t *conn, int severity)
Definition: circuitlist.c:1394
tor_snprintf
int tor_snprintf(char *str, size_t size, const char *format,...)
Definition: printf.c:27
S2K_RFC2440_SPECIFIER_LEN
#define S2K_RFC2440_SPECIFIER_LEN
Definition: crypto_s2k.h:21
sr_init
int sr_init(int save_to_disk)
Definition: shared_random.c:1270
get_version
const char * get_version(void)
Definition: version.c:38
circuitpadding.h
Header file for circuitpadding.c.
stats_n_relay_cells_processed
uint64_t stats_n_relay_cells_processed
Definition: command.c:72
statefile.h
Header for statefile.c.
stats_n_created_cells_processed
uint64_t stats_n_created_cells_processed
Definition: command.c:70
hs_init
void hs_init(void)
Definition: hs_common.c:1826
cpuworkers_rotate_keyinfo
void cpuworkers_rotate_keyinfo(void)
Definition: cpuworker.c:188
truncate_logs
void truncate_logs(void)
Definition: log.c:1456
SMARTLIST_FOREACH
#define SMARTLIST_FOREACH(sl, type, var, cmd)
Definition: smartlist_foreach.h:112
get_or_state
or_state_t * get_or_state(void)
Definition: statefile.c:220
init_keys
int init_keys(void)
Definition: router.c:950
dump_dns_mem_usage
void dump_dns_mem_usage(int severity)
Definition: dns.c:2129
hs_dos.h
Header file containing denial of service defenses for the HS subsystem for all versions.
networkstatus.h
Header file for networkstatus.c.
tor_cleanup
void tor_cleanup(void)
Definition: shutdown.c:60
libc.h
Header for lib/osinfo/libc.c.
crypto_get_library_version_string
const char * crypto_get_library_version_string(void)
Definition: crypto_init.c:191
tor_run_main
int tor_run_main(const tor_main_configuration_t *tor_cfg)
Definition: main.c:1300
tor_main_configuration_t::argc
int argc
Definition: tor_api_internal.h:21
digest256_to_base64
void digest256_to_base64(char *d64, const char *digest)
Definition: crypto_format.c:304
CMD_VERIFY_CONFIG
@ CMD_VERIFY_CONFIG
Definition: tor_cmdline_mode.h:23
get_bytes_written
uint64_t get_bytes_written(void)
Definition: mainloop.c:475
hibernate.h
Header file for hibernate.c.
shutdown.h
Header file for shutdown.c.
rep_hist_dump_stats
void rep_hist_dump_stats(time_t now, int severity)
Definition: rephist.c:541
tor_remove_file
void tor_remove_file(const char *filename)
Definition: main.c:727
or_options_t::TruncateLogFile
int TruncateLogFile
Definition: or_options_st.h:77
circuitlist.h
Header file for circuitlist.c.
mainloop.h
Header file for mainloop.c.
DIGEST_LEN
#define DIGEST_LEN
Definition: digest_sizes.h:20
get_uname
const char * get_uname(void)
Definition: uname.c:67
or_options_t::BridgeAuthoritativeDir
int BridgeAuthoritativeDir
Definition: or_options_st.h:242
keypin_open_journal
int keypin_open_journal(const char *fname)
Definition: keypin.c:303
options_init_from_torrc
int options_init_from_torrc(int argc, char **argv)
Definition: config.c:4469
accounting_is_enabled
int accounting_is_enabled(const or_options_t *options)
Definition: hibernate.c:305
generate_ed_link_cert
int generate_ed_link_cert(const or_options_t *options, time_t now, int force)
Definition: routerkeys.c:365
signal_callback
static void signal_callback(evutil_socket_t fd, short events, void *arg)
Definition: main.c:207
get_min_log_level
int get_min_log_level(void)
Definition: log.c:1426
hs_service_lists_fnames_for_sandbox
void hs_service_lists_fnames_for_sandbox(smartlist_t *file_list, smartlist_t *dir_list)
Definition: hs_service.c:3956
crypto_format.h
Header for crypto_format.c.
resolve.h
Header for resolve.c.
tor_free_all
void tor_free_all(int postfork)
Definition: shutdown.c:111
dumpstats
static void dumpstats(int severity)
Definition: main.c:333
CMD_HASH_PASSWORD
@ CMD_HASH_PASSWORD
Definition: tor_cmdline_mode.h:22
get_controller_cookie_file_name
char * get_controller_cookie_file_name(void)
Definition: control_auth.c:48
tor_realloc_
void * tor_realloc_(void *ptr, size_t size)
Definition: malloc.c:118
command.h
Header file for command.c.
sandbox_intern_string
#define sandbox_intern_string(s)
Definition: sandbox.h:110
rend_service_dump_stats
void rend_service_dump_stats(int severity)
Definition: rendservice.c:4384
routerparse_init
void routerparse_init(void)
Definition: routerparse.c:1235
tortls.h
Headers for tortls.c.
LD_FS
#define LD_FS
Definition: log.h:70
pubsub_builder_new
pubsub_builder_t * pubsub_builder_new(void)
Definition: pubsub_build.c:56
control_auth.h
Header file for control_auth.c.
sandbox_init
int sandbox_init(sandbox_cfg_t *cfg)
Definition: sandbox.c:1858
rep_hist_init
void rep_hist_init(void)
Definition: rephist.c:220
LD_OR
#define LD_OR
Definition: log.h:92
add_default_log_for_quiet_level
void add_default_log_for_quiet_level(quiet_level_t quiet)
Definition: quiet_level.c:24
timers_initialize
void timers_initialize(void)
Definition: timers.c:205
rephist_total_num
uint32_t rephist_total_num
Definition: rephist.c:94
dns_init
int dns_init(void)
Definition: dns.c:224
CONN_TYPE_OR
#define CONN_TYPE_OR
Definition: connection.h:44
shared_random.h
This file contains ABI/API of the shared random protocol defined in proposal #250....
tor_compress_version_str
const char * tor_compress_version_str(compress_method_t method)
Definition: compress.c:417
ed25519_public_key_t
Definition: crypto_ed25519.h:23
tor_api.h
Public C API for the Tor network service.
tor_unlink
int tor_unlink(const char *pathname)
Definition: files.c:154
crypto_s2k.h
Header for crypto_s2k.c.
control_event_signal
int control_event_signal(uintptr_t signal_num)
Definition: control_events.c:1633
meminfo.h
Header for meminfo.c.
keypin.h
Header for keypin.c.
risky_option_list
const char risky_option_list[]
Definition: risky_options.c:18
secret_to_key_rfc2440
void secret_to_key_rfc2440(char *key_out, size_t key_out_len, const char *secret, size_t secret_len, const char *s2k_specifier)
Definition: crypto_s2k.c:203
authmode.h
Header file for directory authority mode.
do_signewnym
void do_signewnym(time_t now)
Definition: mainloop.c:1318
port_cfg_t
Definition: port_cfg_st.h:19
get_connection_array
smartlist_t * get_connection_array(void)
Definition: mainloop.c:453
consdiffmgr_register_with_sandbox
int consdiffmgr_register_with_sandbox(struct sandbox_cfg_elem_t **cfg)
Definition: consdiffmgr.c:847
stats_n_padding_cells_processed
uint64_t stats_n_padding_cells_processed
Definition: channeltls.c:81
tor_lockfile_t
Definition: lockfile.c:38
lockfile
static tor_lockfile_t * lockfile
Definition: main.c:663
router_reset_descriptor_download_failures
void router_reset_descriptor_download_failures(void)
Definition: routerlist.c:2890
consdiffmgr_enable_background_compression
void consdiffmgr_enable_background_compression(void)
Definition: consdiffmgr.c:1908
routerlist.h
Header file for routerlist.c.
subsystems_add_pubsub
int subsystems_add_pubsub(pubsub_builder_t *builder)
Definition: subsysmgr.c:195
directory_info_has_arrived
void directory_info_has_arrived(time_t now, int from_cache, int suppress_logs)
Definition: mainloop.c:1117
predict_ports.h
Header file for predict_ports.c.
risky_options.h
Header for risky_options.c.
do_main_loop
int do_main_loop(void)
Definition: mainloop.c:2345
try_locking
int try_locking(const or_options_t *options, int err_if_locked)
Definition: main.c:671
rendservice.h
Header file for rendservice.c.
LD_CONFIG
#define LD_CONFIG
Definition: log.h:68
buffers.h
Header file for buffers.c.
or_options_t::command_arg
char * command_arg
Definition: or_options_st.h:69
connection_is_listener
int connection_is_listener(connection_t *conn)
Definition: connection.c:4929
dir_server_mode
int dir_server_mode(const or_options_t *options)
Definition: routermode.c:23
tor_libevent_get_version_str
const char * tor_libevent_get_version_str(void)
Definition: compat_libevent.c:212
command
tor_cmdline_mode_t command
Definition: config.c:2468
config_parse_commandline
parsed_cmdline_t * config_parse_commandline(int argc, char **argv, int ignore_errors)
Definition: config.c:2542
CMD_KEYGEN
@ CMD_KEYGEN
Definition: tor_cmdline_mode.h:25
tor_malloc_
void * tor_malloc_(size_t size)
Definition: malloc.c:32
connection_t
Definition: connection_st.h:45
rendcache.h
Header file for rendcache.c.
dirserv_load_fingerprint_file
int dirserv_load_fingerprint_file(void)
Definition: process_descs.c:187
tor_main_configuration_t::argv_owned
char ** argv_owned
Definition: tor_api_internal.h:28
ext_orport.h
Header for ext_orport.c.
LOG_INFO
#define LOG_INFO
Definition: log.h:45
log_set_application_name
void log_set_application_name(const char *name)
Definition: log.c:211
crypto_rand.h
Common functions for using (pseudo-)random number generators.
waitpid.h
Headers for waitpid.c.
control_events.h
Header file for control_events.c.
get_options
const or_options_t * get_options(void)
Definition: config.c:932
parsed_cmdline_t::quiet_level
quiet_level_t quiet_level
Definition: config.h:200
signal_value
int signal_value
Definition: main.c:443
tor_mainloop_connect_pubsub
int tor_mainloop_connect_pubsub(struct pubsub_builder_t *builder)
Definition: mainloop_pubsub.c:60
tor_libc_get_version_str
const char * tor_libc_get_version_str(void)
Definition: libc.c:44
or_options_t::ReloadTorrcOnSIGHUP
int ReloadTorrcOnSIGHUP
Definition: or_options_st.h:838
addressmap.h
Header for addressmap.c.
dns_reset
int dns_reset(void)
Definition: dns.c:238
buf_allocation
size_t buf_allocation(const buf_t *buf)
Definition: buffers.c:401
channel_listener_dumpstats
void channel_listener_dumpstats(int severity)
Definition: channel.c:2102
tor_compress_supports_method
int tor_compress_supports_method(compress_method_t method)
Definition: compress.c:304
tor_tls_get_buffer_sizes
int tor_tls_get_buffer_sizes(tor_tls_t *tls, size_t *rbuf_capacity, size_t *rbuf_bytes, size_t *wbuf_capacity, size_t *wbuf_bytes)
Definition: tortls_nss.c:697
tor_main_configuration_t::argc_owned
int argc_owned
Definition: tor_api_internal.h:26
tor_libevent_get_base
struct event_base * tor_libevent_get_base(void)
Definition: compat_libevent.c:196
connection_dump_buffer_mem_stats
void connection_dump_buffer_mem_stats(int severity)
Definition: connection.c:5510
connection_describe
const char * connection_describe(const connection_t *conn)
Definition: connection.c:544
hs_dos_init
void hs_dos_init(void)
Definition: hs_dos.c:225
relay.h
Header file for relay.c.
connection.h
Header file for connection.c.
client_identity_key_is_set
int client_identity_key_is_set(void)
Definition: router.c:429
signal_event
struct event * signal_event
Definition: main.c:448
update_networkstatus_downloads
void update_networkstatus_downloads(time_t now)
Definition: networkstatus.c:1303
confline.h
Header for confline.c.
timers.h
Header for timers.c.
or_options_t::DisableSignalHandlers
int DisableSignalHandlers
Definition: or_options_st.h:1032
handle_signals
void handle_signals(void)
Definition: main.c:486
router_reload_consensus_networkstatus
int router_reload_consensus_networkstatus(void)
Definition: networkstatus.c:272
server_mode
int server_mode(const or_options_t *options)
Definition: routermode.c:34
router_reset_status_download_failures
void router_reset_status_download_failures(void)
Definition: dirlist.c:135
get_configured_ports
const smartlist_t * get_configured_ports(void)
Definition: config.c:6605
crypto_pk_get_fingerprint
int crypto_pk_get_fingerprint(crypto_pk_t *pk, char *fp_out, int add_space)
Definition: crypto_rsa.c:229
main.h
Header file for main.c.
cpuworker.h
Header file for cpuworker.c.
do_hash_password
static void do_hash_password(void)
Definition: main.c:791
tor_asprintf
int tor_asprintf(char **strp, const char *fmt,...)
Definition: printf.c:75
or_connection_st.h
OR connection structure.
get_ext_or_auth_cookie_file_name
char * get_ext_or_auth_cookie_file_name(void)
Definition: ext_orport.c:127
hibernate_begin_shutdown
void hibernate_begin_shutdown(void)
Definition: hibernate.c:927
SMARTLIST_FOREACH_BEGIN
#define SMARTLIST_FOREACH_BEGIN(sl, type, var)
Definition: smartlist_foreach.h:78
channelpadding_new_consensus_params
void channelpadding_new_consensus_params(const networkstatus_t *ns)
Definition: channelpadding.c:93
crypto_pk_t
Definition: crypto_rsa_nss.c:37
circuit_mark_all_dirty_circs_as_unusable
void circuit_mark_all_dirty_circs_as_unusable(void)
Definition: circuitlist.c:2122
log_heartbeat
int log_heartbeat(time_t now)
Definition: status.c:155
parsed_cmdline_t::command
tor_cmdline_mode_t command
Definition: config.h:196
schedule_rescan_periodic_events
void schedule_rescan_periodic_events(void)
Definition: mainloop.c:1574
stats_n_data_bytes_packaged
uint64_t stats_n_data_bytes_packaged
Definition: relay.c:2056
QUIET_NONE
@ QUIET_NONE
Definition: quiet_level.h:18
router_reset_warnings
void router_reset_warnings(void)
Definition: router.c:3579
tor_shutdown_event_loop_and_exit
void tor_shutdown_event_loop_and_exit(int exitcode)
Definition: mainloop.c:766
or_options_t::DataDirectory
char * DataDirectory
Definition: or_options_st.h:84
or_options_t::Nickname
char * Nickname
Definition: or_options_st.h:97
subsysmgr.h
Header for subsysmgr.c.
process_signal
static void process_signal(int sig)
Definition: main.c:220
have_lockfile
int have_lockfile(void)
Definition: main.c:707
release_lockfile
void release_lockfile(void)
Definition: main.c:714
tor_mainloop_set_delivery_strategy
int tor_mainloop_set_delivery_strategy(const char *msg_channel_name, deliv_strategy_t strategy)
Definition: mainloop_pubsub.c:140
stats_n_relay_cells_relayed
uint64_t stats_n_relay_cells_relayed
Definition: relay.c:128
cpu_init
void cpu_init(void)
Definition: cpuworker.c:83
config.h
Header file for config.c.
init_protocol_warning_severity_level
void init_protocol_warning_severity_level(void)
Definition: config.c:1174
subsystems_init
int subsystems_init(void)
Definition: subsysmgr.c:114
do_hup
static int do_hup(void)
Definition: main.c:119
CMD_DUMP_CONFIG
@ CMD_DUMP_CONFIG
Definition: tor_cmdline_mode.h:24
dumpmemusage
static void dumpmemusage(int severity)
Definition: main.c:319
sandbox_cfg_allow_stat_filename
int sandbox_cfg_allow_stat_filename(sandbox_cfg_t **cfg, char *file)
Definition: sandbox.c:1903
ntmain.h
Header file for ntmain.c.
set_network_participation
void set_network_participation(bool participation)
Definition: netstatus.c:101
LD_NET
#define LD_NET
Definition: log.h:66
sandbox_cfg_new
sandbox_cfg_t * sandbox_cfg_new(void)
Definition: sandbox.c:1852
pubsub_install
void pubsub_install(void)
Definition: main.c:1273
tor_log
void tor_log(int severity, log_domain_mask_t domain, const char *format,...)
Definition: log.c:590
rephist_total_alloc
uint64_t rephist_total_alloc
Definition: rephist.c:92
tor_lockfile_lock
tor_lockfile_t * tor_lockfile_lock(const char *filename, int blocking, int *locked_out)
Definition: lockfile.c:63
addressmap_init
void addressmap_init(void)
Definition: addressmap.c:90
or_options_t
Definition: or_options_st.h:64
crypto_rand
void crypto_rand(char *to, size_t n)
Definition: crypto_rand.c:477
addressmap_clear_transient
void addressmap_clear_transient(void)
Definition: addressmap.c:311
tor_main_configuration_t
Definition: tor_api_internal.h:19
accounting_record_bandwidth_usage
int accounting_record_bandwidth_usage(time_t now, or_state_t *state)
Definition: hibernate.c:705
dns.h
Header file for dns.c.
stats_n_create_cells_processed
uint64_t stats_n_create_cells_processed
Definition: command.c:68
tor_lockfile_unlock
void tor_lockfile_unlock(tor_lockfile_t *lockfile)
Definition: lockfile.c:121
keypin_load_journal
int keypin_load_journal(const char *fname)
Definition: keypin.c:450
hs_service_dump_stats
void hs_service_dump_stats(int severity)
Definition: hs_service.c:4161
parsed_cmdline_t
Definition: config.h:189
routerparse.h
Header file for routerparse.c.
LD_DIR
#define LD_DIR
Definition: log.h:88
load_ed_keys
int load_ed_keys(const or_options_t *options, time_t now)
Definition: routerkeys.c:55
stats_n_destroy_cells_processed
uint64_t stats_n_destroy_cells_processed
Definition: command.c:74
FINGERPRINT_LEN
#define FINGERPRINT_LEN
Definition: crypto_rsa.h:34
log_cert_expiration
int log_cert_expiration(void)
Definition: routerkeys.c:606
or_connection_t::tls
struct tor_tls_t * tls
Definition: or_connection_st.h:44
rend_cache_init
void rend_cache_init(void)
Definition: rendcache.c:68
switch_logs_debug
void switch_logs_debug(void)
Definition: log.c:1441
tor_libc_get_name
const char * tor_libc_get_name(void)
Definition: libc.c:32
or_options_t::DirPortFrontPage
char * DirPortFrontPage
Definition: or_options_st.h:621
smartlist_t
Definition: smartlist_core.h:26
trusted_dirs_reload_certs
int trusted_dirs_reload_certs(void)
Definition: authcert.c:324
TO_OR_CONN
or_connection_t * TO_OR_CONN(connection_t *c)
Definition: connection_or.c:108
compat_libevent.h
Header for compat_libevent.c.
torversion.h
Header for version.c.
quiet_level_t
quiet_level_t
Definition: quiet_level.h:16
quiet_level
quiet_level_t quiet_level
Definition: quiet_level.c:20
update_current_time
void update_current_time(time_t now)
Definition: mainloop.c:2196
stats_n_data_bytes_received
uint64_t stats_n_data_bytes_received
Definition: relay.c:2062
status.h
Header for status.c.
rephist.h
Header file for rephist.c.
try_to_register
int try_to_register
Definition: main.c:446
reset_user_activity
void reset_user_activity(time_t now)
Definition: netstatus.c:82
connection_or.h
Header file for connection_or.c.
crypto_get_library_name
const char * crypto_get_library_name(void)
Definition: crypto_init.c:178
authdir_mode
int authdir_mode(const or_options_t *options)
Definition: authmode.c:25
sandbox_cfg_t
struct sandbox_cfg_elem_t sandbox_cfg_t
Definition: sandbox.h:35
stats_n_data_cells_packaged
uint64_t stats_n_data_cells_packaged
Definition: relay.c:2052
mainloop_pubsub.h
Header for mainloop_pubsub.c.
POSSIBLE
#define POSSIBLE(expr)
Definition: compat_compiler.h:246
tor_log_mallinfo
void tor_log_mallinfo(int severity)
Definition: meminfo.c:44
initialize_mainloop_events
void initialize_mainloop_events(void)
Definition: mainloop.c:2331
or.h
Master header file for Tor-specific functionality.
tor_compress_log_init_warnings
void tor_compress_log_init_warnings(void)
Definition: compress.c:682
stats_n_data_cells_received
uint64_t stats_n_data_cells_received
Definition: relay.c:2058
CMD_KEY_EXPIRATION
@ CMD_KEY_EXPIRATION
Definition: tor_cmdline_mode.h:26
consdiffmgr.h
Header for consdiffmgr.c.
tor_log_get_logfile_names
void tor_log_get_logfile_names(smartlist_t *out)
Definition: log.c:683