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

[tor-commits] [tor/master] Merge remote-tracking branch 'Ryman/bug6384'



commit 25a3ae922f2f378c16c5930b76c33917480120d8
Merge: f4db0f4 b539b37
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Fri Sep 13 12:55:53 2013 -0400

    Merge remote-tracking branch 'Ryman/bug6384'
    
    Conflicts:
    	src/or/config.c
    	src/or/main.c

 changes/bug6384              |    2 ++
 src/common/compat_libevent.c |    8 +++++++
 src/common/compat_libevent.h |    1 +
 src/common/crypto.c          |   49 +++++++++++++++++++++++++++++++-----------
 src/common/crypto.h          |    1 +
 src/common/torgzip.c         |   16 ++++++++++++++
 src/common/torgzip.h         |    6 ++++++
 src/or/config.c              |   19 ++++++++++++++++
 src/or/main.c                |   10 +++++----
 9 files changed, 95 insertions(+), 17 deletions(-)

diff --cc src/or/config.c
index 9a8d1e7,b00f0d6..5ce7bad
--- a/src/or/config.c
+++ b/src/or/config.c
@@@ -1794,48 -1791,15 +1795,49 @@@ options_act(const or_options_t *old_opt
    return 0;
  }
  
 -/** Helper: Read a list of configuration options from the command line.
 - * If successful, put them in *<b>result</b> and return 0, and return
 - * -1 and leave *<b>result</b> alone. */
 -static int
 -config_get_commandlines(int argc, char **argv, config_line_t **result)
 +static const struct {
 +  const char *name;
 +  int takes_argument;
 +} CMDLINE_ONLY_OPTIONS[] = {
 +  { "-f",                     1 },
 +  { "--defaults-torrc",       1 },
 +  { "--hash-password",        1 },
 +  { "--dump-config",          1 },
 +  { "--list-fingerprint",     0 },
 +  { "--verify-config",        0 },
 +  { "--ignore-missing-torrc", 0 },
 +  { "--quiet",                0 },
 +  { "--hush",                 0 },
 +  { "--version",              0 },
++  { "--library-versions",     0 },
 +  { "-h",                     0 },
 +  { "--help",                 0 },
 +  { "--list-torrc-options",   0 },
 +  { "--digests",              0 },
 +  { "--nt-service",           0 },
 +  { "-nt-service",            0 },
 +  { NULL, 0 },
 +};
 +
 +/** Helper: Read a list of configuration options from the command line.  If
 + * successful, or if ignore_errors is set, put them in *<b>result</b>, put the
 + * commandline-only options in *<b>cmdline_result</b>, and return 0;
 + * otherwise, return -1 and leave *<b>result</b> and <b>cmdline_result</b>
 + * alone. */
 +int
 +config_parse_commandline(int argc, char **argv, int ignore_errors,
 +                         config_line_t **result,
 +                         config_line_t **cmdline_result)
  {
 +  config_line_t *param = NULL;
 +
    config_line_t *front = NULL;
    config_line_t **new = &front;
 -  char *s;
 +
 +  config_line_t *front_cmdline = NULL;
 +  config_line_t **new_cmdline = &front_cmdline;
 +
 +  char *s, *arg;
    int i = 1;
  
    while (i < argc) {
@@@ -3932,24 -3817,48 +3934,41 @@@ options_init_from_torrc(int argc, char 
      printf("Tor version %s.\n",get_version());
      exit(0);
    }
+ 
 -  if (argc > 1 && (!strcmp(argv[1],"--digests"))) {
 +  if (config_line_find(cmdline_only_options, "--digests")) {
      printf("Tor version %s.\n",get_version());
      printf("%s", libor_get_digests());
      printf("%s", tor_get_digests());
      exit(0);
    }
  
 -  if (argc > 1 && (!strcmp(argv[1],"--library-versions"))) {
++  if (config_line_find(cmdline_only_options, "--library-versions")) {
+     printf("Tor version %s. \n", get_version());
+     printf("Library versions\tCompiled\t\tRuntime\n");
+     printf("Libevent\t\t%-15s\t\t%s\n",
+                       tor_libevent_get_header_version_str(),
+                       tor_libevent_get_version_str());
+     printf("OpenSSL \t\t%-15s\t\t%s\n",
+                       crypto_openssl_get_header_version_str(),
+                       crypto_openssl_get_version_str());
+     printf("Zlib    \t\t%-15s\t\t%s\n",
+                       tor_zlib_get_header_version_str(),
+                       tor_zlib_get_version_str());
+     //TODO: Hex versions?
+     exit(0);
+   }
+ 
 -  /* Go through command-line variables */
 -  if (!global_cmdline_options) {
 -    /* Or we could redo the list every time we pass this place.
 -     * It does not really matter */
 -    if (config_get_commandlines(argc, argv, &global_cmdline_options) < 0) {
 -      goto err;
 -    }
 -  }
 -
    command = CMD_RUN_TOR;
 -  for (i = 1; i < argc; ++i) {
 -    if (!strcmp(argv[i],"--list-fingerprint")) {
 +  for (p_index = cmdline_only_options; p_index; p_index = p_index->next) {
 +    if (!strcmp(p_index->key,"--list-fingerprint")) {
        command = CMD_LIST_FINGERPRINT;
 -    } else if (!strcmp(argv[i],"--hash-password")) {
 +    } else if (!strcmp(p_index->key, "--hash-password")) {
        command = CMD_HASH_PASSWORD;
 -      command_arg = tor_strdup( (i < argc-1) ? argv[i+1] : "");
 -      ++i;
 -    } else if (!strcmp(argv[i],"--verify-config")) {
 +      command_arg = p_index->value;
 +    } else if (!strcmp(p_index->key, "--dump-config")) {
 +      command = CMD_DUMP_CONFIG;
 +      command_arg = p_index->value;
 +    } else if (!strcmp(p_index->key, "--verify-config")) {
        command = CMD_VERIFY_CONFIG;
      }
    }
diff --cc src/or/main.c
index ceee29c,2d6ca74..ac756de
--- a/src/or/main.c
+++ b/src/or/main.c
@@@ -2339,28 -2333,19 +2339,29 @@@ tor_init(int argc, char *argv[]
    addressmap_init(); /* Init the client dns cache. Do it always, since it's
                        * cheap. */
  
 +  {
    /* We search for the "quiet" option first, since it decides whether we
     * will log anything at all to the command line. */
 -  for (i=1;i<argc;++i) {
 -    if (!strcmp(argv[i], "--hush"))
 -      quiet = 1;
 -    if (!strcmp(argv[i], "--quiet"))
 -      quiet = 2;
 -    /* --version implies --quiet */
 -    if (!strcmp(argv[i], "--version"))
 -      quiet = 2;
 -    if (!strcmp(argv[i], "--library-versions"))
 -      quiet = 2;
 +    config_line_t *opts = NULL, *cmdline_opts = NULL;
 +    const config_line_t *cl;
 +    (void) config_parse_commandline(argc, argv, 1, &opts, &cmdline_opts);
 +    for (cl = cmdline_opts; cl; cl = cl->next) {
 +      if (!strcmp(cl->key, "--hush"))
 +        quiet = 1;
 +      if (!strcmp(cl->key, "--quiet") ||
 +          !strcmp(cl->key, "--dump-config"))
 +        quiet = 2;
-       /* --version, --digests, and --help imply --husth */
++      /* --version, --digests, and --help imply --hush */
 +      if (!strcmp(cl->key, "--version") || !strcmp(cl->key, "--digests") ||
 +          !strcmp(cl->key, "--list-torrc-options") ||
++          !strcmp(cl->key, "--library-versions") ||
 +          !strcmp(cl->key, "-h") || !strcmp(cl->key, "--help"))
 +        quiet = 1;
 +    }
 +    config_free_lines(opts);
 +    config_free_lines(cmdline_opts);
    }
 +
   /* give it somewhere to log to initially */
    switch (quiet) {
      case 2:



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits