Merge remote-tracking branch 'fjoncourt/master'
authorMichael Rash <mbr@cipherdyne.org>
Sun, 28 Apr 2013 02:26:38 +0000 (22:26 -0400)
committerMichael Rash <mbr@cipherdyne.org>
Sun, 28 Apr 2013 02:26:38 +0000 (22:26 -0400)
This merges changes from Franck Joncourt for issues #55 (log module for fwknop)
and #64 (hostname resolution not working for -P icmp spoofing).

1  2 
client/config_init.c
client/fwknop.c
client/spa_comm.c
test/test-fwknop.pl

@@@ -587,10 -617,10 +617,10 @@@ parse_rc_param(fko_cli_options_t *optio
          else if(strcasecmp(val, "resolve") == 0)
              options->resolve_ip_http = 1;
          else /* Assume IP address */
 -            strlcpy(options->allow_ip_str, val, MAX_IPV4_STR_LEN);
 +            strlcpy(options->allow_ip_str, val, sizeof(options->allow_ip_str));
      }
      /* Time Offset */
-     else if(CONF_VAR_IS(var, "TIME_OFFSET"))
+     else if (conf_key_ndx == FWKNOP_CLI_ARG_TIME_OFFSET)
      {
          if(val[0] == '-')
          {
              options->encryption_mode = tmpint;
      }
      /* Use GPG ? */
-     else if(CONF_VAR_IS(var, "USE_GPG"))
+     else if (conf_key_ndx == FWKNOP_CLI_ARG_USE_GPG)
      {
-         if(val[0] == 'y' || val[0] == 'Y')
+         if (is_yes_str(val))
              options->use_gpg = 1;
+         else;
      }
      /* Use GPG Agent ? */
-     else if(CONF_VAR_IS(var, "USE_GPG_AGENT"))
+     else if (conf_key_ndx == FWKNOP_CLI_ARG_USE_GPG_AGENT)
      {
-         if(val[0] == 'y' || val[0] == 'Y')
+         if (is_yes_str(val))
              options->use_gpg_agent = 1;
+         else;
      }
      /* GPG Recipient */
-     else if(CONF_VAR_IS(var, "GPG_RECIPIENT"))
+     else if (conf_key_ndx == FWKNOP_CLI_ARG_GPG_RECIPIENT)
      {
 -        strlcpy(options->gpg_recipient_key, val, MAX_GPG_KEY_ID);
 +        strlcpy(options->gpg_recipient_key, val, sizeof(options->gpg_recipient_key));
      }
      /* GPG Signer */
-     else if(CONF_VAR_IS(var, "GPG_SIGNER"))
+     else if (conf_key_ndx == FWKNOP_CLI_ARG_GPG_SIGNER)
      {
 -        strlcpy(options->gpg_signer_key, val, MAX_GPG_KEY_ID);
 +        strlcpy(options->gpg_signer_key, val, sizeof(options->gpg_signer_key));
      }
      /* GPG Homedir */
-     else if(CONF_VAR_IS(var, "GPG_HOMEDIR"))
+     else if (conf_key_ndx == FWKNOP_CLI_ARG_GPG_HOMEDIR)
      {
 -        strlcpy(options->gpg_home_dir, val, MAX_PATH_LEN);
 +        strlcpy(options->gpg_home_dir, val, sizeof(options->gpg_home_dir));
      }
      /* Spoof User */
-     else if(CONF_VAR_IS(var, "SPOOF_USER"))
+     else if (conf_key_ndx == FWKNOP_CLI_ARG_SPOOF_USER)
      {
 -        strlcpy(options->spoof_user, val, MAX_USERNAME_LEN);
 +        strlcpy(options->spoof_user, val, sizeof(options->spoof_user));
      }
      /* Spoof Source IP */
-     else if(CONF_VAR_IS(var, "SPOOF_SOURCE_IP"))
+     else if (conf_key_ndx == FWKNOP_CLI_ARG_SPOOF_SOURCE_IP)
      {
 -        strlcpy(options->spoof_ip_src_str, val, MAX_IPV4_STR_LEN);
 +        strlcpy(options->spoof_ip_src_str, val, sizeof(options->spoof_ip_src_str));
      }
      /* ACCESS request */
-     else if(CONF_VAR_IS(var, "ACCESS"))
+     else if (conf_key_ndx == FWKNOP_CLI_ARG_ACCESS)
      {
 -        strlcpy(options->access_str, val, MAX_LINE_LEN);
 +        strlcpy(options->access_str, val, sizeof(options->access_str));
      }
      /* SPA Server (destination) */
-     else if(CONF_VAR_IS(var, "SPA_SERVER"))
+     else if (conf_key_ndx == FWKNOP_CLI_ARG_SPA_SERVER)
      {
 -        strlcpy(options->spa_server_str, val, MAX_SERVER_STR_LEN);
 +        strlcpy(options->spa_server_str, val, sizeof(options->spa_server_str));
      }
      /* Rand port ? */
-     else if(CONF_VAR_IS(var, "RAND_PORT"))
+     else if (conf_key_ndx == FWKNOP_CLI_ARG_RAND_PORT)
      {
-         if(val[0] == 'y' || val[0] == 'Y')
+         if (is_yes_str(val))
              options->rand_port = 1;
+         else;
      }
      /* Rijndael key */
-     else if(CONF_VAR_IS(var, "KEY"))
+     else if (conf_key_ndx == FWKNOP_CLI_ARG_KEY_RIJNDAEL)
      {
 -        strlcpy(options->key, val, MAX_KEY_LEN);
 +        strlcpy(options->key, val, sizeof(options->key));
          options->have_key = 1;
      }
      /* Rijndael key (base-64 encoded) */
      {
          if (! is_base64((unsigned char *) val, strlen(val)))
          {
-             fprintf(stderr,
-                 "KEY_BASE64 argument '%s' doesn't look like base64-encoded data.\n",
+             log_msg(LOG_VERBOSITY_WARNING,
+                 "KEY_BASE64 argument '%s' doesn't look like base64-encoded data.",
                  val);
-             return(-1);
+             parse_error = -1;
          }
 -        strlcpy(options->key_base64, val, MAX_B64_KEY_LEN);
 +        strlcpy(options->key_base64, val, sizeof(options->key_base64));
          options->have_base64_key = 1;
      }
      /* HMAC digest type */
      {
          if (! is_base64((unsigned char *) val, strlen(val)))
          {
-             fprintf(stderr,
-                 "HMAC_KEY_BASE64 argument '%s' doesn't look like base64-encoded data.\n",
+             log_msg(LOG_VERBOSITY_WARNING,
+                 "HMAC_KEY_BASE64 argument '%s' doesn't look like base64-encoded data.",
                  val);
-             return(-1);
+             parse_error = -1;
          }
 -        strlcpy(options->hmac_key_base64, val, MAX_B64_KEY_LEN);
 +        strlcpy(options->hmac_key_base64, val, sizeof(options->hmac_key_base64));
          options->have_hmac_base64_key = 1;
      }
  
      /* HMAC key */
-     else if(CONF_VAR_IS(var, "HMAC_KEY"))
+     else if (conf_key_ndx == FWKNOP_CLI_ARG_KEY_HMAC)
      {
 -        strlcpy(options->hmac_key, val, MAX_KEY_LEN);
 +        strlcpy(options->hmac_key, val, sizeof(options->hmac_key));
          options->have_hmac_key = 1;
      }
  
      /* Key file */
-     else if(CONF_VAR_IS(var, "KEY_FILE"))
+     else if (conf_key_ndx == FWKNOP_CLI_ARG_KEY_FILE)
      {
 -        strlcpy(options->get_key_file, val, MAX_PATH_LEN);
 +        strlcpy(options->get_key_file, val, sizeof(options->get_key_file));
      }
      /* NAT Access Request */
-     else if(CONF_VAR_IS(var, "NAT_ACCESS"))
+     else if (conf_key_ndx == FWKNOP_CLI_ARG_NAT_ACCESS)
      {
 -        strlcpy(options->nat_access_str, val, MAX_PATH_LEN);
 +        strlcpy(options->nat_access_str, val, sizeof(options->nat_access_str));
      }
      /* HTTP User Agent */
-     else if(CONF_VAR_IS(var, "HTTP_USER_AGENT"))
+     else if (conf_key_ndx == FWKNOP_CLI_ARG_HTTP_USER_AGENT)
      {
 -        strlcpy(options->http_user_agent, val, HTTP_MAX_USER_AGENT_LEN);
 +        strlcpy(options->http_user_agent, val, sizeof(options->http_user_agent));
      }
      /* Resolve URL */
-     else if(CONF_VAR_IS(var, "RESOLVE_URL"))
+     else if (conf_key_ndx == FWKNOP_CLI_ARG_RESOLVE_URL)
      {
          if(options->resolve_url != NULL)
              free(options->resolve_url);
diff --cc client/fwknop.c
Simple merge
Simple merge
Simple merge