~ubuntu-branches/debian/sid/subversion/sid

« back to all changes in this revision

Viewing changes to subversion/libsvn_subr/cmdline.c

  • Committer: Package Import Robot
  • Author(s): James McCoy
  • Date: 2015-08-07 21:32:47 UTC
  • mfrom: (0.2.15) (4.1.7 experimental)
  • Revision ID: package-import@ubuntu.com-20150807213247-ozyewtmgsr6tkewl
Tags: 1.9.0-1
* Upload to unstable
* New upstream release.
  + Security fixes
    - CVE-2015-3184: Mixed anonymous/authenticated path-based authz with
      httpd 2.4
    - CVE-2015-3187: svn_repos_trace_node_locations() reveals paths hidden
      by authz
* Add >= 2.7 requirement for python-all-dev Build-Depends, needed to run
  tests.
* Remove Build-Conflicts against ruby-test-unit.  (Closes: #791844)
* Remove patches/apache_module_dependency in favor of expressing the
  dependencies in authz_svn.load/dav_svn.load.
* Build-Depend on apache2-dev (>= 2.4.16) to ensure ap_some_authn_required()
  is available when building mod_authz_svn and Depend on apache2-bin (>=
  2.4.16) for runtime support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
#else
35
35
#include <crtdbg.h>
36
36
#include <io.h>
 
37
#include <conio.h>
37
38
#endif
38
39
 
39
40
#include <apr.h>                /* for STDIN_FILENO */
62
63
 
63
64
#include "private/svn_cmdline_private.h"
64
65
#include "private/svn_utf_private.h"
 
66
#include "private/svn_sorts_private.h"
65
67
#include "private/svn_string_private.h"
66
68
 
67
69
#include "svn_private_config.h"
68
70
 
69
71
#include "win32_crashrpt.h"
70
72
 
 
73
#if defined(WIN32) && defined(_MSC_VER) && (_MSC_VER < 1400)
 
74
/* Before Visual Studio 2005, the C runtime didn't handle encodings for the
 
75
   for the stdio output handling. */
 
76
#define CMDLINE_USE_CUSTOM_ENCODING
 
77
 
71
78
/* The stdin encoding. If null, it's the same as the native encoding. */
72
79
static const char *input_encoding = NULL;
73
80
 
74
81
/* The stdout encoding. If null, it's the same as the native encoding. */
75
82
static const char *output_encoding = NULL;
 
83
#elif defined(WIN32) && defined(_MSC_VER)
 
84
/* For now limit this code to Visual C++, as the result is highly dependent
 
85
   on the CRT implementation */
 
86
#define USE_WIN32_CONSOLE_SHORTCUT
 
87
 
 
88
/* When TRUE, stdout/stderr is directly connected to a console */
 
89
static svn_boolean_t shortcut_stdout_to_console = FALSE;
 
90
static svn_boolean_t shortcut_stderr_to_console = FALSE;
 
91
#endif
76
92
 
77
93
 
78
94
int
114
130
#endif
115
131
 
116
132
#ifdef WIN32
117
 
#if _MSC_VER < 1400
 
133
#ifdef CMDLINE_USE_CUSTOM_ENCODING
118
134
  /* Initialize the input and output encodings. */
119
135
  {
120
136
    static char input_encoding_buffer[16];
128
144
                 "CP%u", (unsigned) GetConsoleOutputCP());
129
145
    output_encoding = output_encoding_buffer;
130
146
  }
131
 
#endif /* _MSC_VER < 1400 */
 
147
#endif /* CMDLINE_USE_CUSTOM_ENCODING */
132
148
 
133
149
#ifdef SVN_USE_WIN32_CRASHHANDLER
134
 
  /* Attach (but don't load) the crash handler */
135
 
  SetUnhandledExceptionFilter(svn__unhandled_exception_filter);
 
150
  if (!getenv("SVN_CMDLINE_DISABLE_CRASH_HANDLER"))
 
151
    {
 
152
      /* Attach (but don't load) the crash handler */
 
153
      SetUnhandledExceptionFilter(svn__unhandled_exception_filter);
136
154
 
137
155
#if _MSC_VER >= 1400
138
 
  /* ### This should work for VC++ 2002 (=1300) and later */
139
 
  /* Show the abort message on STDERR instead of a dialog to allow
140
 
     scripts (e.g. our testsuite) to continue after an abort without
141
 
     user intervention. Allow overriding for easier debugging. */
142
 
  if (!getenv("SVN_CMDLINE_USE_DIALOG_FOR_ABORT"))
143
 
    {
144
 
      /* In release mode: Redirect abort() errors to stderr */
145
 
      _set_error_mode(_OUT_TO_STDERR);
 
156
      /* ### This should work for VC++ 2002 (=1300) and later */
 
157
      /* Show the abort message on STDERR instead of a dialog to allow
 
158
         scripts (e.g. our testsuite) to continue after an abort without
 
159
         user intervention. Allow overriding for easier debugging. */
 
160
      if (!getenv("SVN_CMDLINE_USE_DIALOG_FOR_ABORT"))
 
161
        {
 
162
          /* In release mode: Redirect abort() errors to stderr */
 
163
          _set_error_mode(_OUT_TO_STDERR);
146
164
 
147
 
      /* In _DEBUG mode: Redirect all debug output (E.g. assert() to stderr.
148
 
         (Ignored in release builds) */
149
 
      _CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDERR);
150
 
      _CrtSetReportFile( _CRT_ERROR, _CRTDBG_FILE_STDERR);
151
 
      _CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDERR);
152
 
      _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
153
 
      _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
154
 
      _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
155
 
    }
 
165
          /* In _DEBUG mode: Redirect all debug output (E.g. assert() to stderr.
 
166
             (Ignored in release builds) */
 
167
          _CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDERR);
 
168
          _CrtSetReportFile( _CRT_ERROR, _CRTDBG_FILE_STDERR);
 
169
          _CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDERR);
 
170
          _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
 
171
          _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
 
172
          _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
 
173
        }
156
174
#endif /* _MSC_VER >= 1400 */
157
 
 
 
175
    }
158
176
#endif /* SVN_USE_WIN32_CRASHHANDLER */
159
177
 
160
178
#endif /* WIN32 */
247
265
      return EXIT_FAILURE;
248
266
    }
249
267
 
 
268
#ifdef USE_WIN32_CONSOLE_SHORTCUT
 
269
  if (_isatty(STDOUT_FILENO))
 
270
    {
 
271
      DWORD ignored;
 
272
      HANDLE stdout_handle = GetStdHandle(STD_OUTPUT_HANDLE);
 
273
 
 
274
       /* stdout is a char device handle, but is it the console? */
 
275
       if (GetConsoleMode(stdout_handle, &ignored))
 
276
        shortcut_stdout_to_console = TRUE;
 
277
 
 
278
       /* Don't close stdout_handle */
 
279
    }
 
280
  if (_isatty(STDERR_FILENO))
 
281
    {
 
282
      DWORD ignored;
 
283
      HANDLE stderr_handle = GetStdHandle(STD_ERROR_HANDLE);
 
284
 
 
285
       /* stderr is a char device handle, but is it the console? */
 
286
      if (GetConsoleMode(stderr_handle, &ignored))
 
287
          shortcut_stderr_to_console = TRUE;
 
288
 
 
289
      /* Don't close stderr_handle */
 
290
    }
 
291
#endif
 
292
 
250
293
  return EXIT_SUCCESS;
251
294
}
252
295
 
256
299
                              const char *src,
257
300
                              apr_pool_t *pool)
258
301
{
259
 
  if (output_encoding == NULL)
260
 
    return svn_utf_cstring_from_utf8(dest, src, pool);
261
 
  else
 
302
#ifdef CMDLINE_USE_CUSTOM_ENCODING
 
303
  if (output_encoding != NULL)
262
304
    return svn_utf_cstring_from_utf8_ex2(dest, src, output_encoding, pool);
 
305
#endif
 
306
 
 
307
  return svn_utf_cstring_from_utf8(dest, src, pool);
263
308
}
264
309
 
265
310
 
277
322
                            const char *src,
278
323
                            apr_pool_t *pool)
279
324
{
280
 
  if (input_encoding == NULL)
281
 
    return svn_utf_cstring_to_utf8(dest, src, pool);
282
 
  else
 
325
#ifdef CMDLINE_USE_CUSTOM_ENCODING
 
326
  if (input_encoding != NULL)
283
327
    return svn_utf_cstring_to_utf8_ex2(dest, src, input_encoding, pool);
 
328
#endif
 
329
 
 
330
  return svn_utf_cstring_to_utf8(dest, src, pool);
284
331
}
285
332
 
286
333
 
336
383
  svn_error_t *err;
337
384
  const char *out;
338
385
 
 
386
#ifdef USE_WIN32_CONSOLE_SHORTCUT
 
387
  /* For legacy reasons the Visual C++ runtime converts output to the console
 
388
     from the native 'ansi' encoding, to unicode, then back to 'ansi' and then
 
389
     onwards to the console which is implemented as unicode.
 
390
 
 
391
     For operations like 'svn status -v' this may cause about 70% of the total
 
392
     processing time, with absolutely no gain.
 
393
 
 
394
     For this specific scenario this shortcut exists. It has the nice side
 
395
     effect of allowing full unicode output to the console.
 
396
 
 
397
     Note that this shortcut is not used when the output is redirected, as in
 
398
     that case the data is put on the pipe/file after the first conversion to
 
399
     ansi. In this case the most expensive conversion is already avoided.
 
400
   */
 
401
  if ((stream == stdout && shortcut_stdout_to_console)
 
402
      || (stream == stderr && shortcut_stderr_to_console))
 
403
    {
 
404
      WCHAR *result;
 
405
 
 
406
      if (string[0] == '\0')
 
407
        return SVN_NO_ERROR;
 
408
 
 
409
      SVN_ERR(svn_cmdline_fflush(stream)); /* Flush existing output */
 
410
 
 
411
      SVN_ERR(svn_utf__win32_utf8_to_utf16(&result, string, NULL, pool));
 
412
 
 
413
      if (_cputws(result))
 
414
        {
 
415
          if (apr_get_os_error())
 
416
          {
 
417
            return svn_error_wrap_apr(apr_get_os_error(), _("Write error"));
 
418
          }
 
419
        }
 
420
 
 
421
      return SVN_NO_ERROR;
 
422
    }
 
423
#endif
 
424
 
339
425
  err = svn_cmdline_cstring_from_utf8(&out, string, pool);
340
426
 
341
427
  if (err)
393
479
 
394
480
const char *svn_cmdline_output_encoding(apr_pool_t *pool)
395
481
{
 
482
#ifdef CMDLINE_USE_CUSTOM_ENCODING
396
483
  if (output_encoding)
397
484
    return apr_pstrdup(pool, output_encoding);
398
 
  else
399
 
    return SVN_APR_LOCALE_CHARSET;
 
485
#endif
 
486
 
 
487
  return SVN_APR_LOCALE_CHARSET;
400
488
}
401
489
 
402
490
int
419
507
  return EXIT_FAILURE;
420
508
}
421
509
 
 
510
struct trust_server_cert_non_interactive_baton {
 
511
  svn_boolean_t trust_server_cert_unknown_ca;
 
512
  svn_boolean_t trust_server_cert_cn_mismatch;
 
513
  svn_boolean_t trust_server_cert_expired;
 
514
  svn_boolean_t trust_server_cert_not_yet_valid;
 
515
  svn_boolean_t trust_server_cert_other_failure;
 
516
};
 
517
 
422
518
/* This implements 'svn_auth_ssl_server_trust_prompt_func_t'.
423
519
 
424
520
   Don't actually prompt.  Instead, set *CRED_P to valid credentials
425
 
   iff FAILURES is empty or is exactly SVN_AUTH_SSL_UNKNOWNCA.  If
426
 
   there are any other failure bits, then set *CRED_P to null (that
427
 
   is, reject the cert).
 
521
   iff FAILURES is empty or may be accepted according to the flags
 
522
   in BATON. If there are any other failure bits, then set *CRED_P
 
523
   to null (that is, reject the cert).
428
524
 
429
525
   Ignore MAY_SAVE; we don't save certs we never prompted for.
430
526
 
431
 
   Ignore BATON, REALM, and CERT_INFO,
 
527
   Ignore REALM and CERT_INFO,
432
528
 
433
529
   Ignore any further films by George Lucas. */
434
530
static svn_error_t *
435
 
ssl_trust_unknown_server_cert
436
 
  (svn_auth_cred_ssl_server_trust_t **cred_p,
437
 
   void *baton,
438
 
   const char *realm,
439
 
   apr_uint32_t failures,
440
 
   const svn_auth_ssl_server_cert_info_t *cert_info,
441
 
   svn_boolean_t may_save,
442
 
   apr_pool_t *pool)
 
531
trust_server_cert_non_interactive(svn_auth_cred_ssl_server_trust_t **cred_p,
 
532
                                  void *baton,
 
533
                                  const char *realm,
 
534
                                  apr_uint32_t failures,
 
535
                                  const svn_auth_ssl_server_cert_info_t
 
536
                                    *cert_info,
 
537
                                  svn_boolean_t may_save,
 
538
                                  apr_pool_t *pool)
443
539
{
 
540
  struct trust_server_cert_non_interactive_baton *b = baton;
 
541
  apr_uint32_t non_ignored_failures;
444
542
  *cred_p = NULL;
445
543
 
446
 
  if (failures == 0 || failures == SVN_AUTH_SSL_UNKNOWNCA)
 
544
  /* Mask away bits we are instructed to ignore. */
 
545
  non_ignored_failures = failures & ~(
 
546
        (b->trust_server_cert_unknown_ca ? SVN_AUTH_SSL_UNKNOWNCA : 0)
 
547
      | (b->trust_server_cert_cn_mismatch ? SVN_AUTH_SSL_CNMISMATCH : 0)
 
548
      | (b->trust_server_cert_expired ? SVN_AUTH_SSL_EXPIRED : 0)
 
549
      | (b->trust_server_cert_not_yet_valid ? SVN_AUTH_SSL_NOTYETVALID : 0)
 
550
      | (b->trust_server_cert_other_failure ? SVN_AUTH_SSL_OTHER : 0)
 
551
  );
 
552
 
 
553
  /* If no failures remain, accept the certificate. */
 
554
  if (non_ignored_failures == 0)
447
555
    {
448
556
      *cred_p = apr_pcalloc(pool, sizeof(**cred_p));
449
557
      (*cred_p)->may_save = FALSE;
454
562
}
455
563
 
456
564
svn_error_t *
457
 
svn_cmdline_create_auth_baton(svn_auth_baton_t **ab,
458
 
                              svn_boolean_t non_interactive,
459
 
                              const char *auth_username,
460
 
                              const char *auth_password,
461
 
                              const char *config_dir,
462
 
                              svn_boolean_t no_auth_cache,
463
 
                              svn_boolean_t trust_server_cert,
464
 
                              svn_config_t *cfg,
465
 
                              svn_cancel_func_t cancel_func,
466
 
                              void *cancel_baton,
467
 
                              apr_pool_t *pool)
 
565
svn_cmdline_create_auth_baton2(svn_auth_baton_t **ab,
 
566
                               svn_boolean_t non_interactive,
 
567
                               const char *auth_username,
 
568
                               const char *auth_password,
 
569
                               const char *config_dir,
 
570
                               svn_boolean_t no_auth_cache,
 
571
                               svn_boolean_t trust_server_cert_unknown_ca,
 
572
                               svn_boolean_t trust_server_cert_cn_mismatch,
 
573
                               svn_boolean_t trust_server_cert_expired,
 
574
                               svn_boolean_t trust_server_cert_not_yet_valid,
 
575
                               svn_boolean_t trust_server_cert_other_failure,
 
576
                               svn_config_t *cfg,
 
577
                               svn_cancel_func_t cancel_func,
 
578
                               void *cancel_baton,
 
579
                               apr_pool_t *pool)
 
580
 
468
581
{
469
582
  svn_boolean_t store_password_val = TRUE;
470
583
  svn_boolean_t store_auth_creds_val = TRUE;
505
618
  svn_auth_get_username_provider(&provider, pool);
506
619
  APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
507
620
 
508
 
  /* The windows ssl server certificate CRYPTOAPI provider. */
509
 
  SVN_ERR(svn_auth_get_platform_specific_provider(&provider,
510
 
                                                  "windows",
511
 
                                                  "ssl_server_trust",
512
 
                                                  pool));
513
 
 
514
 
  if (provider)
515
 
    APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
516
 
 
517
 
  /* The windows ssl authority certificate CRYPTOAPI provider. */
518
 
  SVN_ERR(svn_auth_get_platform_specific_provider(&provider,
519
 
                                                  "windows",
520
 
                                                  "ssl_server_authority",
521
 
                                                  pool));
522
 
 
523
 
  if (provider)
524
 
    APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
525
 
 
526
621
  svn_auth_get_ssl_server_trust_file_provider(&provider, pool);
527
622
  APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
528
623
  svn_auth_get_ssl_client_cert_file_provider(&provider, pool);
583
678
          APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
584
679
        }
585
680
    }
586
 
  else if (trust_server_cert)
 
681
  else if (trust_server_cert_unknown_ca || trust_server_cert_cn_mismatch ||
 
682
           trust_server_cert_expired || trust_server_cert_not_yet_valid ||
 
683
           trust_server_cert_other_failure)
587
684
    {
 
685
      struct trust_server_cert_non_interactive_baton *b;
 
686
 
 
687
      b = apr_palloc(pool, sizeof(*b));
 
688
      b->trust_server_cert_unknown_ca = trust_server_cert_unknown_ca;
 
689
      b->trust_server_cert_cn_mismatch = trust_server_cert_cn_mismatch;
 
690
      b->trust_server_cert_expired = trust_server_cert_expired;
 
691
      b->trust_server_cert_not_yet_valid = trust_server_cert_not_yet_valid;
 
692
      b->trust_server_cert_other_failure = trust_server_cert_other_failure;
 
693
 
588
694
      /* Remember, only register this provider if non_interactive. */
589
695
      svn_auth_get_ssl_server_trust_prompt_provider
590
 
        (&provider, ssl_trust_unknown_server_cert, NULL, pool);
 
696
        (&provider, trust_server_cert_non_interactive, b, pool);
591
697
      APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
592
698
    }
593
699
 
689
795
      outstr, pool, svn_xml_protect_pcdata,
690
796
      inherited_prop ? "inherited_property" : "property",
691
797
      "name", propname,
692
 
      "encoding", encoding, NULL);
 
798
      "encoding", encoding, SVN_VA_NULL);
693
799
  else
694
800
    svn_xml_make_open_tag(
695
801
      outstr, pool, svn_xml_protect_pcdata,
696
802
      inherited_prop ? "inherited_property" : "property",
697
 
      "name", propname, NULL);
 
803
      "name", propname, SVN_VA_NULL);
698
804
 
699
805
  svn_stringbuf_appendcstr(*outstr, xml_safe);
700
806
 
705
811
  return;
706
812
}
707
813
 
 
814
/* Return the most similar string to NEEDLE in HAYSTACK, which contains
 
815
 * HAYSTACK_LEN elements.  Return NULL if no string is sufficiently similar.
 
816
 */
 
817
/* See svn_cl__similarity_check() for a more general solution. */
 
818
static const char *
 
819
most_similar(const char *needle_cstr,
 
820
             const char **haystack,
 
821
             apr_size_t haystack_len,
 
822
             apr_pool_t *scratch_pool)
 
823
{
 
824
  const char *max_similar;
 
825
  apr_size_t max_score = 0;
 
826
  apr_size_t i;
 
827
  svn_membuf_t membuf;
 
828
  svn_string_t *needle_str = svn_string_create(needle_cstr, scratch_pool);
 
829
 
 
830
  svn_membuf__create(&membuf, 64, scratch_pool);
 
831
 
 
832
  for (i = 0; i < haystack_len; i++)
 
833
    {
 
834
      apr_size_t score;
 
835
      svn_string_t *hay = svn_string_create(haystack[i], scratch_pool);
 
836
 
 
837
      score = svn_string__similarity(needle_str, hay, &membuf, NULL);
 
838
 
 
839
      /* If you update this factor, consider updating
 
840
       * svn_cl__similarity_check(). */
 
841
      if (score >= (2 * SVN_STRING__SIM_RANGE_MAX + 1) / 3
 
842
          && score > max_score)
 
843
        {
 
844
          max_score = score;
 
845
          max_similar = haystack[i];
 
846
        }
 
847
    }
 
848
 
 
849
  if (max_score)
 
850
    return max_similar;
 
851
  else
 
852
    return NULL;
 
853
}
 
854
 
 
855
/* Verify that NEEDLE is in HAYSTACK, which contains HAYSTACK_LEN elements. */
 
856
static svn_error_t *
 
857
string_in_array(const char *needle,
 
858
                const char **haystack,
 
859
                apr_size_t haystack_len,
 
860
                apr_pool_t *scratch_pool)
 
861
{
 
862
  const char *next_of_kin;
 
863
  apr_size_t i;
 
864
  for (i = 0; i < haystack_len; i++)
 
865
    {
 
866
      if (!strcmp(needle, haystack[i]))
 
867
        return SVN_NO_ERROR;
 
868
    }
 
869
 
 
870
  /* Error. */
 
871
  next_of_kin = most_similar(needle, haystack, haystack_len, scratch_pool);
 
872
  if (next_of_kin)
 
873
    return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
 
874
                             _("Ignoring unknown value '%s'; "
 
875
                               "did you mean '%s'?"),
 
876
                             needle, next_of_kin);
 
877
  else
 
878
    return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
 
879
                             _("Ignoring unknown value '%s'"),
 
880
                             needle);
 
881
}
 
882
 
 
883
#include "config_keys.inc"
 
884
 
 
885
/* Validate the FILE, SECTION, and OPTION components of CONFIG_OPTION are
 
886
 * known.  Warn to stderr if not.  (An unknown value may be either a typo
 
887
 * or added in a newer minor version of Subversion.) */
 
888
static svn_error_t *
 
889
validate_config_option(svn_cmdline__config_argument_t *config_option,
 
890
                       apr_pool_t *scratch_pool)
 
891
{
 
892
  svn_boolean_t arbitrary_keys = FALSE;
 
893
 
 
894
  /* TODO: some day, we could also verify that OPTION is valid for SECTION;
 
895
     i.e., forbid invalid combinations such as config:auth:diff-extensions. */
 
896
 
 
897
#define ARRAYLEN(x) ( sizeof((x)) / sizeof((x)[0]) )
 
898
 
 
899
  SVN_ERR(string_in_array(config_option->file, svn__valid_config_files,
 
900
                          ARRAYLEN(svn__valid_config_files),
 
901
                          scratch_pool));
 
902
  SVN_ERR(string_in_array(config_option->section, svn__valid_config_sections,
 
903
                          ARRAYLEN(svn__valid_config_sections),
 
904
                          scratch_pool));
 
905
 
 
906
  /* Don't validate option names for sections such as servers[group],
 
907
   * config[tunnels], and config[auto-props] that permit arbitrary options. */
 
908
    {
 
909
      int i;
 
910
 
 
911
      for (i = 0; i < ARRAYLEN(svn__empty_config_sections); i++)
 
912
        {
 
913
        if (!strcmp(config_option->section, svn__empty_config_sections[i]))
 
914
          arbitrary_keys = TRUE;
 
915
        }
 
916
    }
 
917
 
 
918
  if (! arbitrary_keys)
 
919
    SVN_ERR(string_in_array(config_option->option, svn__valid_config_options,
 
920
                            ARRAYLEN(svn__valid_config_options),
 
921
                            scratch_pool));
 
922
 
 
923
#undef ARRAYLEN
 
924
 
 
925
  return SVN_NO_ERROR;
 
926
}
 
927
 
708
928
svn_error_t *
709
929
svn_cmdline__parse_config_option(apr_array_header_t *config_options,
710
930
                                 const char *opt_arg,
 
931
                                 const char *prefix,
711
932
                                 apr_pool_t *pool)
712
933
{
713
934
  svn_cmdline__config_argument_t *config_option;
721
942
          if ((equals_sign = strchr(second_colon + 1, '=')) &&
722
943
              (equals_sign != second_colon + 1))
723
944
            {
 
945
              svn_error_t *warning;
 
946
 
724
947
              config_option = apr_pcalloc(pool, sizeof(*config_option));
725
948
              config_option->file = apr_pstrndup(pool, opt_arg,
726
949
                                                 first_colon - opt_arg);
729
952
              config_option->option = apr_pstrndup(pool, second_colon + 1,
730
953
                                                   equals_sign - second_colon - 1);
731
954
 
 
955
              warning = validate_config_option(config_option, pool);
 
956
              if (warning)
 
957
                {
 
958
                  svn_handle_warning2(stderr, warning, prefix);
 
959
                  svn_error_clear(warning);
 
960
                }
 
961
 
732
962
              if (! (strchr(config_option->option, ':')))
733
963
                {
734
964
                  config_option->value = apr_pstrndup(pool, equals_sign + 1,
920
1150
          svn_xml_make_open_tag(
921
1151
            outstr, pool, svn_xml_self_closing,
922
1152
            inherited_props ? "inherited_property" : "property",
923
 
            "name", pname, NULL);
 
1153
            "name", pname, SVN_VA_NULL);
924
1154
        }
925
1155
      else
926
1156
        {
1275
1505
      /* Translate back to UTF8/LF if desired. */
1276
1506
      if (as_text)
1277
1507
        {
1278
 
          err = svn_subst_translate_string2(edited_contents, FALSE, FALSE,
 
1508
          err = svn_subst_translate_string2(edited_contents, NULL, NULL,
1279
1509
                                            *edited_contents, encoding, FALSE,
1280
1510
                                            pool, pool);
1281
1511
          if (err)
1319
1549
 
1320
1550
  return svn_error_trace(err);
1321
1551
}
 
1552
 
 
1553
svn_error_t *
 
1554
svn_cmdline__parse_trust_options(
 
1555
                        svn_boolean_t *trust_server_cert_unknown_ca,
 
1556
                        svn_boolean_t *trust_server_cert_cn_mismatch,
 
1557
                        svn_boolean_t *trust_server_cert_expired,
 
1558
                        svn_boolean_t *trust_server_cert_not_yet_valid,
 
1559
                        svn_boolean_t *trust_server_cert_other_failure,
 
1560
                        const char *opt_arg,
 
1561
                        apr_pool_t *scratch_pool)
 
1562
{
 
1563
  apr_array_header_t *failures;
 
1564
  int i;
 
1565
 
 
1566
  *trust_server_cert_unknown_ca = FALSE;
 
1567
  *trust_server_cert_cn_mismatch = FALSE;
 
1568
  *trust_server_cert_expired = FALSE;
 
1569
  *trust_server_cert_not_yet_valid = FALSE;
 
1570
  *trust_server_cert_other_failure = FALSE;
 
1571
 
 
1572
  failures = svn_cstring_split(opt_arg, ", \n\r\t\v", TRUE, scratch_pool);
 
1573
 
 
1574
  for (i = 0; i < failures->nelts; i++)
 
1575
    {
 
1576
      const char *value = APR_ARRAY_IDX(failures, i, const char *);
 
1577
      if (!strcmp(value, "unknown-ca"))
 
1578
        *trust_server_cert_unknown_ca = TRUE;
 
1579
      else if (!strcmp(value, "cn-mismatch"))
 
1580
        *trust_server_cert_cn_mismatch = TRUE;
 
1581
      else if (!strcmp(value, "expired"))
 
1582
        *trust_server_cert_expired = TRUE;
 
1583
      else if (!strcmp(value, "not-yet-valid"))
 
1584
        *trust_server_cert_not_yet_valid = TRUE;
 
1585
      else if (!strcmp(value, "other"))
 
1586
        *trust_server_cert_other_failure = TRUE;
 
1587
      else
 
1588
        return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
 
1589
                                  _("Unknown value '%s' for %s.\n"
 
1590
                                    "Supported values: %s"),
 
1591
                                  value,
 
1592
                                  "--trust-server-cert-failures",
 
1593
                                  "unknown-ca, cn-mismatch, expired, "
 
1594
                                  "not-yet-valid, other");
 
1595
    }
 
1596
 
 
1597
  return SVN_NO_ERROR;
 
1598
}