82
85
static APR_INLINE svn_error_t *
83
86
parser_getc(parse_context_t *ctx, int *c)
85
if (ctx->have_ungotten_char)
87
*c = ctx->ungotten_char;
88
ctx->have_ungotten_char = FALSE;
93
apr_size_t readlen = 1;
95
SVN_ERR(svn_stream_read(ctx->stream, &char_buf, &readlen));
90
if (ctx->ungotten_char != EOF)
92
*c = ctx->ungotten_char;
93
ctx->ungotten_char = EOF;
95
else if (ctx->buffer_pos < ctx->buffer_size)
97
*c = (unsigned char)ctx->parser_buffer[ctx->buffer_pos];
103
ctx->buffer_size = sizeof(ctx->parser_buffer);
105
SVN_ERR(svn_stream_read(ctx->stream, ctx->parser_buffer,
106
&(ctx->buffer_size)));
108
if (ctx->buffer_pos < ctx->buffer_size)
110
*c = (unsigned char)ctx->parser_buffer[ctx->buffer_pos];
103
119
return SVN_NO_ERROR;
122
/* Simplified version of parser_getc() to be used inside skipping loops.
123
* It will not check for 'ungotton' chars and may or may not ignore '\r'.
125
* In a 'while(cond) getc();' loop, the first iteration must call
126
* parser_getc to handle all the special cases. Later iterations should
127
* use parser_getc_plain for maximum performance.
129
static APR_INLINE svn_error_t *
130
parser_getc_plain(parse_context_t *ctx, int *c)
132
if (ctx->buffer_pos < ctx->buffer_size)
134
*c = (unsigned char)ctx->parser_buffer[ctx->buffer_pos];
140
return parser_getc(ctx, c);
106
143
/* Emulate ungetc() because streams don't support it.
108
145
* Use CTX to store the ungotten character C.
148
184
SVN_ERR(parser_getc(ctx, &ch));
149
while (ch != EOF && ch != '\n')
150
SVN_ERR(parser_getc(ctx, &ch));
185
while (ch != '\n' && ch != EOF)
186
SVN_ERR(parser_getc_plain(ctx, &ch));
153
189
return SVN_NO_ERROR;
192
/* Skip a UTF-8 Byte Order Mark if found. */
193
static APR_INLINE svn_error_t *
194
skip_bom(parse_context_t *ctx)
198
SVN_ERR(parser_getc(ctx, &ch));
201
const unsigned char *buf = (unsigned char *)ctx->parser_buffer;
202
/* This makes assumptions about the implementation of parser_getc and
203
* the use of skip_bom. Specifically that parser_getc() will get all
204
* of the BOM characters into the parse_context_t buffer. This can
205
* safely be assumed as long as we only try to use skip_bom() at the
206
* start of the stream and the buffer is longer than 3 characters. */
207
SVN_ERR_ASSERT(ctx->buffer_size > ctx->buffer_pos + 1);
208
if (buf[ctx->buffer_pos] == 0xBB && buf[ctx->buffer_pos + 1] == 0xBF)
209
ctx->buffer_pos += 2;
211
SVN_ERR(parser_ungetc(ctx, ch));
214
SVN_ERR(parser_ungetc(ctx, ch));
157
219
/* Parse a single option value */
158
220
static svn_error_t *
365
426
svn_config__parse_file(svn_config_t *cfg, const char *file,
366
svn_boolean_t must_exist, apr_pool_t *pool)
427
svn_boolean_t must_exist, apr_pool_t *result_pool)
368
429
svn_error_t *err = SVN_NO_ERROR;
371
430
svn_stream_t *stream;
431
apr_pool_t *scratch_pool = svn_pool_create(result_pool);
373
err = svn_stream_open_readonly(&stream, file, pool, pool);
433
err = svn_stream_open_readonly(&stream, file, scratch_pool, scratch_pool);
375
435
if (! must_exist && err && APR_STATUS_IS_ENOENT(err->apr_err))
377
437
svn_error_clear(err);
438
svn_pool_destroy(scratch_pool);
378
439
return SVN_NO_ERROR;
385
ctx.stream = svn_subst_stream_translated(stream, "\n", TRUE, NULL, FALSE,
388
ctx.have_ungotten_char = FALSE;
389
ctx.section = svn_stringbuf_create("", pool);
390
ctx.option = svn_stringbuf_create("", pool);
391
ctx.value = svn_stringbuf_create("", pool);
444
err = svn_config__parse_stream(cfg, stream, result_pool, scratch_pool);
446
if (err != SVN_NO_ERROR)
448
/* Add the filename to the error stack. */
449
err = svn_error_createf(err->apr_err, err,
450
"Error while parsing config file: %s:",
451
svn_dirent_local_style(file, scratch_pool));
454
/* Close the streams (and other cleanup): */
455
svn_pool_destroy(scratch_pool);
461
svn_config__parse_stream(svn_config_t *cfg, svn_stream_t *stream,
462
apr_pool_t *result_pool, apr_pool_t *scratch_pool)
464
parse_context_t *ctx;
467
ctx = apr_palloc(scratch_pool, sizeof(*ctx));
470
ctx->stream = stream;
472
ctx->ungotten_char = EOF;
473
ctx->section = svn_stringbuf_create_empty(scratch_pool);
474
ctx->option = svn_stringbuf_create_empty(scratch_pool);
475
ctx->value = svn_stringbuf_create_empty(scratch_pool);
477
ctx->buffer_size = 0;
479
SVN_ERR(skip_bom(ctx));
395
SVN_ERR(skip_whitespace(&ctx, &ch, &count));
483
SVN_ERR(skip_whitespace(ctx, &ch, &count));
399
487
case '[': /* Start of section header */
401
SVN_ERR(parse_section_name(&ch, &ctx, pool));
489
SVN_ERR(parse_section_name(&ch, ctx, scratch_pool));
403
491
return svn_error_createf(SVN_ERR_MALFORMED_FILE, NULL,
404
"%s:%d: Section header"
492
"line %d: Section header"
405
493
" must start in the first column",
406
svn_dirent_local_style(file, pool),
410
497
case '#': /* Comment */
413
SVN_ERR(skip_to_eoln(&ctx, &ch));
500
SVN_ERR(skip_to_eoln(ctx, &ch));
417
504
return svn_error_createf(SVN_ERR_MALFORMED_FILE, NULL,
419
506
" must start in the first column",
420
svn_dirent_local_style(file, pool),
424
510
case '\n': /* Empty line */
428
514
case EOF: /* End of file or read error */
432
if (svn_stringbuf_isempty(ctx.section))
518
if (svn_stringbuf_isempty(ctx->section))
433
519
return svn_error_createf(SVN_ERR_MALFORMED_FILE, NULL,
434
"%s:%d: Section header expected",
435
svn_dirent_local_style(file, pool),
520
"line %d: Section header expected",
437
522
else if (count != 0)
438
523
return svn_error_createf(SVN_ERR_MALFORMED_FILE, NULL,
439
"%s:%d: Option expected",
440
svn_dirent_local_style(file, pool),
524
"line %d: Option expected",
443
SVN_ERR(parse_option(&ch, &ctx, pool));
527
SVN_ERR(parse_option(&ch, ctx, scratch_pool));
447
531
while (ch != EOF);
449
/* Close the streams (and other cleanup): */
450
return svn_stream_close(ctx.stream);
761
846
"### ssl-pkcs11-provider Name of PKCS#11 provider to use." NL
762
847
"### http-library Which library to use for http/https"
764
"### connections (neon or serf)" NL
849
"### connections." NL
850
"### http-bulk-updates Whether to request bulk update" NL
851
"### responses or to fetch each file" NL
852
"### in an individual request. " NL
765
853
"### store-passwords Specifies whether passwords used" NL
766
854
"### to authenticate against a" NL
767
855
"### Subversion server may be cached" NL
768
856
"### to disk in any way." NL
857
#ifndef SVN_DISABLE_PLAINTEXT_PASSWORD_STORAGE
769
858
"### store-plaintext-passwords Specifies whether passwords may" NL
770
859
"### be cached on disk unencrypted." NL
771
861
"### store-ssl-client-cert-pp Specifies whether passphrase used" NL
772
862
"### to authenticate against a client" NL
773
863
"### certificate may be cached to disk" NL
774
864
"### in any way" NL
865
#ifndef SVN_DISABLE_PLAINTEXT_PASSWORD_STORAGE
775
866
"### store-ssl-client-cert-pp-plaintext" NL
776
867
"### Specifies whether client cert" NL
777
868
"### passphrases may be cached on disk" NL
778
869
"### unencrypted (i.e., as plaintext)." NL
779
871
"### store-auth-creds Specifies whether any auth info" NL
780
"### (passwords as well as server certs)"
872
"### (passwords, server certs, etc.)" NL
782
873
"### may be cached to disk." NL
783
874
"### username Specifies the default username." NL
785
876
"### Set store-passwords to 'no' to avoid storing passwords on disk" NL
786
"### in any way, including in password stores. It defaults to 'yes',"
788
"### but Subversion will never save your password to disk in plaintext"
790
"### unless you tell it to." NL
877
"### in any way, including in password stores. It defaults to" NL
878
"### 'yes', but Subversion will never save your password to disk in" NL
879
"### plaintext unless explicitly configured to do so." NL
791
880
"### Note that this option only prevents saving of *new* passwords;" NL
792
881
"### it doesn't invalidate existing passwords. (To do that, remove" NL
793
882
"### the cache files by hand as described in the Subversion book.)" NL
884
#ifndef SVN_DISABLE_PLAINTEXT_PASSWORD_STORAGE
795
885
"### Set store-plaintext-passwords to 'no' to avoid storing" NL
796
886
"### passwords in unencrypted form in the auth/ area of your config" NL
797
887
"### directory. Set it to 'yes' to allow Subversion to store" NL
833
926
"### HTTP timeouts, if given, are specified in seconds. A timeout" NL
834
927
"### of 0, i.e. zero, causes a builtin default to be used." NL
929
"### Most users will not need to explicitly set the http-library" NL
930
"### option, but valid values for the option include:" NL
931
"### 'serf': Serf-based module (Subversion 1.5 - present)" NL
932
"### 'neon': Neon-based module (Subversion 1.0 - 1.7)" NL
933
"### Availability of these modules may depend on your specific" NL
934
"### Subversion distribution." NL
836
936
"### The commented-out examples below are intended only to" NL
837
937
"### demonstrate how to use this file; any resemblance to actual" NL
838
938
"### servers, living or dead, is entirely coincidental." NL
895
994
"# http-proxy-username = defaultusername" NL
896
995
"# http-proxy-password = defaultpassword" NL
897
996
"# http-compression = no" NL
899
"# http-auth-types = basic;digest;negotiate" NL
901
997
"# No http-timeout, so just use the builtin default." NL
902
998
"# No neon-debug-mask, so neon debugging is disabled." NL
903
999
"# ssl-authority-files = /path/to/CAcert.pem;/path/to/CAcert2.pem" NL
905
1001
"# Password / passphrase caching parameters:" NL
906
1002
"# store-passwords = no" NL
907
"# store-plaintext-passwords = no" NL
908
1003
"# store-ssl-client-cert-pp = no" NL
909
"# store-ssl-client-cert-pp-plaintext = no" NL;
1004
#ifndef SVN_DISABLE_PLAINTEXT_PASSWORD_STORAGE
1005
"# store-plaintext-passwords = no" NL
1006
"# store-ssl-client-cert-pp-plaintext = no" NL
911
1010
err = svn_io_file_open(&f, path,
912
1011
(APR_WRITE | APR_CREATE | APR_EXCL),
1095
1202
"# *.png = svn:mime-type=image/png" NL
1096
1203
"# *.jpg = svn:mime-type=image/jpeg" NL
1097
1204
"# Makefile = svn:eol-style=native" NL
1206
"### Section for configuring working copies." NL
1208
"### Set to a list of the names of specific clients that should use" NL
1209
"### exclusive SQLite locking of working copies. This increases the"NL
1210
"### performance of the client but prevents concurrent access by" NL
1211
"### other clients. Third-party clients may also support this" NL
1213
"### Possible values:" NL
1214
"### svn (the command line client)" NL
1215
"# exclusive-locking-clients =" NL
1216
"### Set to true to enable exclusive SQLite locking of working" NL
1217
"### copies by all clients using the 1.8 APIs. Enabling this may" NL
1218
"### cause some clients to fail to work properly. This does not have"NL
1219
"### to be set for exclusive-locking-clients to work." NL
1220
"# exclusive-locking = false" NL;
1100
1222
err = svn_io_file_open(&f, path,
1101
1223
(APR_WRITE | APR_CREATE | APR_EXCL),