| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * cmdline.c : Helpers for command-line programs. | 2 * cmdline.c : Helpers for command-line programs. |
| 3 * | 3 * |
| 4 * ==================================================================== | 4 * ==================================================================== |
| 5 * Copyright (c) 2000-2007 CollabNet. All rights reserved. | 5 * Copyright (c) 2003-2008 CollabNet. All rights reserved. |
| 6 * | 6 * |
| 7 * This software is licensed as described in the file COPYING, which | 7 * This software is licensed as described in the file COPYING, which |
| 8 * you should have received as part of this distribution. The terms | 8 * you should have received as part of this distribution. The terms |
| 9 * are also available at http://subversion.tigris.org/license-1.html. | 9 * are also available at http://subversion.tigris.org/license-1.html. |
| 10 * If newer versions of this license are posted there, you may use a | 10 * If newer versions of this license are posted there, you may use a |
| 11 * newer version instead, at your option. | 11 * newer version instead, at your option. |
| 12 * | 12 * |
| 13 * This software consists of voluntary contributions made by many | 13 * This software consists of voluntary contributions made by many |
| 14 * individuals. For exact contribution history, see the revision | 14 * individuals. For exact contribution history, see the revision |
| 15 * history and logs, available at http://subversion.tigris.org/. | 15 * history and logs, available at http://subversion.tigris.org/. |
| 16 * ==================================================================== | 16 * ==================================================================== |
| 17 */ | 17 */ |
| 18 | 18 |
| 19 | 19 |
| 20 #include <stdlib.h> /* for atexit() */ | 20 #include <stdlib.h> /* for atexit() */ |
| 21 #include <stdio.h> /* for setvbuf() */ | 21 #include <stdio.h> /* for setvbuf() */ |
| 22 #include <locale.h> /* for setlocale() */ | 22 #include <locale.h> /* for setlocale() */ |
| 23 | 23 |
| 24 #ifndef WIN32 | 24 #ifndef WIN32 |
| 25 #include <sys/types.h> | 25 #include <sys/types.h> |
| 26 #include <sys/stat.h> | 26 #include <sys/stat.h> |
| 27 #include <fcntl.h> | 27 #include <fcntl.h> |
| 28 #include <unistd.h> | 28 #include <unistd.h> |
| 29 #endif | 29 #endif |
| 30 | 30 |
| 31 #include <apr_errno.h> /* for apr_strerror */ | 31 #include <apr_errno.h> /* for apr_strerror */ |
| 32 #include <apr_general.h> /* for apr_initialize/apr_terminate */ | 32 #include <apr_general.h> /* for apr_initialize/apr_terminate */ |
| 33 #include <apr_atomic.h> /* for apr_atomic_init */ | 33 #include <apr_atomic.h> /* for apr_atomic_init */ |
| 34 #include <apr_strings.h> /* for apr_snprintf */ | 34 #include <apr_strings.h> /* for apr_snprintf */ |
| 35 #include <apr_pools.h> | 35 #include <apr_pools.h> |
| 36 | 36 |
| 37 #include "svn_cmdline.h" | 37 #include "svn_cmdline.h" |
| 38 #include "svn_dso.h" | 38 #include "svn_dso.h" |
| 39 #include "svn_path.h" | 39 #include "svn_path.h" |
| 40 #include "svn_pools.h" | 40 #include "svn_pools.h" |
| 41 #include "svn_error.h" | 41 #include "svn_error.h" |
| 42 #include "svn_nls.h" | 42 #include "svn_nls.h" |
| 43 #include "svn_auth.h" | 43 #include "svn_auth.h" |
| 44 #include "svn_version.h" | |
| 44 #include "utf_impl.h" | 45 #include "utf_impl.h" |
| 45 #include "svn_config.h" | 46 #include "svn_config.h" |
| 46 | 47 |
| 47 #include "svn_private_config.h" | 48 #include "svn_private_config.h" |
| 48 | 49 |
| 49 #include "win32_crashrpt.h" | 50 #include "win32_crashrpt.h" |
| 50 | 51 |
| 51 /* The stdin encoding. If null, it's the same as the native encoding. */ | 52 /* The stdin encoding. If null, it's the same as the native encoding. */ |
| 52 static const char *input_encoding = NULL; | 53 static const char *input_encoding = NULL; |
| 53 | 54 |
| 54 /* The stdout encoding. If null, it's the same as the native encoding. */ | 55 /* The stdout encoding. If null, it's the same as the native encoding. */ |
| 55 static const char *output_encoding = NULL; | 56 static const char *output_encoding = NULL; |
| 56 | 57 |
| 57 | 58 |
| 58 int | 59 int |
| 59 svn_cmdline_init(const char *progname, FILE *error_stream) | 60 svn_cmdline_init(const char *progname, FILE *error_stream) |
| 60 { | 61 { |
| 61 apr_status_t status; | 62 apr_status_t status; |
| 62 apr_pool_t *pool; | 63 apr_pool_t *pool; |
| 63 | 64 |
| 64 #ifndef WIN32 | 65 #ifndef WIN32 |
| 65 { | 66 { |
| 66 struct stat st; | 67 struct stat st; |
| 67 | 68 |
| 68 /* The following makes sure that file descriptors 0 (stdin), 1 | 69 /* The following makes sure that file descriptors 0 (stdin), 1 |
| 69 (stdout) and 2 (stderr) will not be "reused", because if | 70 (stdout) and 2 (stderr) will not be "reused", because if |
| 70 e.g. file descriptor 2 would be reused when opening a file, a | 71 e.g. file descriptor 2 would be reused when opening a file, a |
| 71 write to stderr would write to that file and most likely | 72 write to stderr would write to that file and most likely |
| 72 corrupt it. */ | 73 corrupt it. */ |
| 73 #ifdef AS400_UTF8 | 74 #ifdef AS400_UTF8 |
| 74 /* Even with the UTF support in V5R4 a few functions on OS400 don't | 75 /* Even with the UTF support in V5R4 a few functions on OS400 don't |
| 75 * support UTF-8 string arguments and require EBCDIC paths, including | 76 * support UTF-8 string arguments and require EBCDIC paths, including |
| 76 * open(). */ | 77 * open(). */ |
| 77 #pragma convert(0) | 78 #pragma convert(0) |
| 78 #endif | 79 #endif |
| 79 if ((fstat(0, &st) == -1 && open("/dev/null", O_RDONLY) == -1) || | 80 if ((fstat(0, &st) == -1 && open("/dev/null", O_RDONLY) == -1) || |
| 80 (fstat(1, &st) == -1 && open("/dev/null", O_WRONLY) == -1) || | 81 (fstat(1, &st) == -1 && open("/dev/null", O_WRONLY) == -1) || |
| 81 (fstat(2, &st) == -1 && open("/dev/null", O_WRONLY) == -1)) | 82 (fstat(2, &st) == -1 && open("/dev/null", O_WRONLY) == -1)) |
| 82 #ifdef AS400_UTF8 | 83 #ifdef AS400_UTF8 |
| 83 #pragma convert(1208) | 84 #pragma convert(1208) |
| 84 #endif | 85 #endif |
| 85 { | 86 { |
| 86 if (error_stream) | 87 if (error_stream) |
| 87 fprintf(error_stream, "%s: error: cannot open '/dev/null'\n", | 88 fprintf(error_stream, "%s: error: cannot open '/dev/null'\n", |
| 88 progname); | 89 progname); |
| 89 return EXIT_FAILURE; | 90 return EXIT_FAILURE; |
| 90 } | 91 } |
| 91 } | 92 } |
| 92 #endif | 93 #endif |
| 93 | 94 |
| (...skipping 210 matching lines...) Show 10 above Show 10 below | |
| 304 use it if it was set by the below fputs call. Else, we just return | 305 use it if it was set by the below fputs call. Else, we just return |
| 305 a generic error. */ | 306 a generic error. */ |
| 306 errno = 0; | 307 errno = 0; |
| 307 | 308 |
| 308 if (fputs(out, stream) == EOF) | 309 if (fputs(out, stream) == EOF) |
| 309 { | 310 { |
| 310 if (errno) | 311 if (errno) |
| 311 return svn_error_wrap_apr(errno, _("Write error")); | 312 return svn_error_wrap_apr(errno, _("Write error")); |
| 312 else | 313 else |
| 313 return svn_error_create | 314 return svn_error_create |
| 314 (SVN_ERR_IO_WRITE_ERROR, NULL, NULL); | 315 (SVN_ERR_IO_WRITE_ERROR, NULL, NULL); |
| 315 } | 316 } |
| 316 | 317 |
| 317 return SVN_NO_ERROR; | 318 return SVN_NO_ERROR; |
| 318 } | 319 } |
| 319 | 320 |
| 320 svn_error_t * | 321 svn_error_t * |
| 321 svn_cmdline_fflush(FILE *stream) | 322 svn_cmdline_fflush(FILE *stream) |
| 322 { | 323 { |
| 323 /* See comment in svn_cmdline_fputs about use of errno and stdio. */ | 324 /* See comment in svn_cmdline_fputs about use of errno and stdio. */ |
| 324 errno = 0; | 325 errno = 0; |
| 325 if (fflush(stream) == EOF) | 326 if (fflush(stream) == EOF) |
| 326 { | 327 { |
| 327 if (errno) | 328 if (errno) |
| 328 return svn_error_wrap_apr(errno, _("Write error")); | 329 return svn_error_wrap_apr(errno, _("Write error")); |
| 329 else | 330 else |
| 330 return svn_error_create(SVN_ERR_IO_WRITE_ERROR, NULL, NULL); | 331 return svn_error_create(SVN_ERR_IO_WRITE_ERROR, NULL, NULL); |
| 331 } | 332 } |
| 332 | 333 |
| 333 return SVN_NO_ERROR; | 334 return SVN_NO_ERROR; |
| 334 } | 335 } |
| 335 | 336 |
| 336 const char *svn_cmdline_output_encoding(apr_pool_t *pool) | 337 const char *svn_cmdline_output_encoding(apr_pool_t *pool) |
| 337 { | 338 { |
| 338 if (output_encoding) | 339 if (output_encoding) |
| 339 return apr_pstrdup(pool, output_encoding); | 340 return apr_pstrdup(pool, output_encoding); |
| 340 else | 341 else |
| 341 return SVN_APR_LOCALE_CHARSET; | 342 return SVN_APR_LOCALE_CHARSET; |
| 342 } | 343 } |
| 343 | 344 |
| 344 int | 345 int |
| 345 svn_cmdline_handle_exit_error(svn_error_t *err, | 346 svn_cmdline_handle_exit_error(svn_error_t *err, |
| 346 apr_pool_t *pool, | 347 apr_pool_t *pool, |
| 347 const char *prefix) | 348 const char *prefix) |
| 348 { | 349 { |
| 349 svn_handle_error2(err, stderr, FALSE, prefix); | 350 svn_handle_error2(err, stderr, FALSE, prefix); |
| 350 svn_error_clear(err); | 351 svn_error_clear(err); |
| 351 if (pool) | 352 if (pool) |
| 352 svn_pool_destroy(pool); | 353 svn_pool_destroy(pool); |
| 353 return EXIT_FAILURE; | 354 return EXIT_FAILURE; |
| 355 } | |
| 356 | |
| 357 /* Return dynamically loaded authentication simple provider. */ | |
| 358 static svn_boolean_t | |
| 359 get_auth_simple_provider(svn_auth_provider_object_t **provider, | |
| 360 const char *provider_name, | |
| 361 apr_pool_t *pool) | |
| 362 { | |
| 363 apr_dso_handle_t *dso; | |
| 364 apr_dso_handle_sym_t provider_symbol; | |
| 365 const char *libname; | |
| 366 const char *funcname; | |
| 367 svn_boolean_t ret = FALSE; | |
| 368 libname = apr_psprintf(pool, | |
| 369 "libsvn_auth_%s-%d.so.0", | |
| 370 provider_name, | |
| 371 SVN_VER_MAJOR); | |
| 372 funcname = apr_psprintf(pool, "svn_auth_get_%s_simple_provider", provider_name ); | |
|
sussman
2008/05/15 15:14:41
Line >80 chars.
| |
| 373 svn_dso_load(&dso, libname); | |
| 374 if (dso) | |
| 375 { | |
| 376 if (! apr_dso_sym(&provider_symbol, dso, funcname)) | |
| 377 { | |
| 378 svn_auth_simple_provider_func_t func; | |
| 379 func = (svn_auth_simple_provider_func_t) provider_symbol; | |
| 380 func(provider, pool); | |
| 381 ret = TRUE; | |
| 382 } | |
| 383 } | |
| 384 return ret; | |
| 354 } | 385 } |
| 355 | 386 |
| 356 svn_error_t * | 387 svn_error_t * |
| 357 svn_cmdline_setup_auth_baton(svn_auth_baton_t **ab, | 388 svn_cmdline_setup_auth_baton(svn_auth_baton_t **ab, |
| 358 svn_boolean_t non_interactive, | 389 svn_boolean_t non_interactive, |
| 359 const char *auth_username, | 390 const char *auth_username, |
| 360 const char *auth_password, | 391 const char *auth_password, |
| 361 const char *config_dir, | 392 const char *config_dir, |
| 362 svn_boolean_t no_auth_cache, | 393 svn_boolean_t no_auth_cache, |
| 363 svn_config_t *cfg, | 394 svn_config_t *cfg, |
| 364 svn_cancel_func_t cancel_func, | 395 svn_cancel_func_t cancel_func, |
| 365 void *cancel_baton, | 396 void *cancel_baton, |
| 366 apr_pool_t *pool) | 397 apr_pool_t *pool) |
| 367 { | 398 { |
| 368 svn_boolean_t store_password_val = TRUE; | 399 svn_boolean_t store_password_val = TRUE; |
| 369 svn_boolean_t store_auth_creds_val = TRUE; | 400 svn_boolean_t store_auth_creds_val = TRUE; |
| 370 svn_auth_provider_object_t *provider; | 401 svn_auth_provider_object_t *provider; |
| 371 svn_cmdline_prompt_baton2_t *pb = NULL; | 402 svn_cmdline_prompt_baton2_t *pb = NULL; |
| 372 | 403 |
| 373 /* The whole list of registered providers */ | 404 /* The whole list of registered providers */ |
| 374 apr_array_header_t *providers | 405 apr_array_header_t *providers |
| 375 = apr_array_make(pool, 12, sizeof(svn_auth_provider_object_t *)); | 406 = apr_array_make(pool, 12, sizeof(svn_auth_provider_object_t *)); |
| 376 | 407 |
| 377 /* If we have a cancellation function, cram it and the stuff it | 408 /* If we have a cancellation function, cram it and the stuff it |
| 378 needs into the prompt baton. */ | 409 needs into the prompt baton. */ |
| 379 if (cancel_func) | 410 if (cancel_func) |
| 380 { | 411 { |
| 381 pb = apr_palloc(pool, sizeof(*pb)); | 412 pb = apr_palloc(pool, sizeof(*pb)); |
| 382 pb->cancel_func = cancel_func; | 413 pb->cancel_func = cancel_func; |
| 383 pb->cancel_baton = cancel_baton; | 414 pb->cancel_baton = cancel_baton; |
| 384 pb->config_dir = config_dir; | 415 pb->config_dir = config_dir; |
| 385 } | 416 } |
| 386 | 417 |
| 387 /* Disk-caching auth providers, for both | 418 /* Disk-caching auth providers, for both |
| 388 'username/password' creds and 'username' creds, | 419 'username/password' creds and 'username' creds, |
| 389 which store passwords encrypted. */ | 420 which store passwords encrypted. */ |
| 390 #if defined(WIN32) && !defined(__MINGW32__) | 421 #if defined(WIN32) && !defined(__MINGW32__) |
| 391 svn_auth_get_windows_simple_provider(&provider, pool); | 422 svn_auth_get_windows_simple_provider(&provider, pool); |
| 392 APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider; | 423 APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider; |
| 393 #endif | 424 #endif |
| 394 #ifdef SVN_HAVE_KEYCHAIN_SERVICES | 425 #ifdef SVN_HAVE_KEYCHAIN_SERVICES |
| 395 svn_auth_get_keychain_simple_provider(&provider, pool); | 426 svn_auth_get_keychain_simple_provider(&provider, pool); |
| 396 APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider; | 427 APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider; |
| 428 #endif | |
| 429 #ifdef SVN_HAVE_KWALLET | |
| 430 if (get_auth_simple_provider(&provider, "kwallet", pool)) | |
|
sussman
2008/05/15 15:14:41
I'm confused here. Why does the kwallet provider
| |
| 431 { | |
| 432 APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider; | |
| 433 } | |
| 397 #endif | 434 #endif |
| 398 if (non_interactive == FALSE) | 435 if (non_interactive == FALSE) |
| 399 { | 436 { |
| 400 /* This provider is odd in that it isn't a prompting provider in | 437 /* This provider is odd in that it isn't a prompting provider in |
| 401 the classic sense. That is, it doesn't need to prompt in | 438 the classic sense. That is, it doesn't need to prompt in |
| 402 order to get creds, but it *does* need to prompt the user | 439 order to get creds, but it *does* need to prompt the user |
| 403 regarding the *cache storage* of creds. */ | 440 regarding the *cache storage* of creds. */ |
| 404 svn_auth_get_simple_provider2(&provider, | 441 svn_auth_get_simple_provider2(&provider, |
| 405 svn_cmdline_auth_plaintext_prompt, | 442 svn_cmdline_auth_plaintext_prompt, |
| 406 pb, pool); | 443 pb, pool); |
| 407 } | 444 } |
| 408 else | 445 else |
| 409 { | 446 { |
| 410 svn_auth_get_simple_provider2(&provider, NULL, NULL, pool); | 447 svn_auth_get_simple_provider2(&provider, NULL, NULL, pool); |
| 411 } | 448 } |
| 412 APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider; | 449 APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider; |
| 413 svn_auth_get_username_provider(&provider, pool); | 450 svn_auth_get_username_provider(&provider, pool); |
| 414 APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider; | 451 APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider; |
| 415 | 452 |
| 416 /* The server-cert, client-cert, and client-cert-password providers. */ | 453 /* The server-cert, client-cert, and client-cert-password providers. */ |
| 417 #if defined(WIN32) && !defined(__MINGW32__) | 454 #if defined(WIN32) && !defined(__MINGW32__) |
| 418 svn_auth_get_windows_ssl_server_trust_provider(&provider, pool); | 455 svn_auth_get_windows_ssl_server_trust_provider(&provider, pool); |
| 419 APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider; | 456 APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider; |
| 420 #endif | 457 #endif |
| 421 svn_auth_get_ssl_server_trust_file_provider(&provider, pool); | 458 svn_auth_get_ssl_server_trust_file_provider(&provider, pool); |
| 422 APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider; | 459 APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider; |
| 423 svn_auth_get_ssl_client_cert_file_provider(&provider, pool); | 460 svn_auth_get_ssl_client_cert_file_provider(&provider, pool); |
| 424 APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider; | 461 APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider; |
| 425 svn_auth_get_ssl_client_cert_pw_file_provider(&provider, pool); | 462 svn_auth_get_ssl_client_cert_pw_file_provider(&provider, pool); |
| 426 APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider; | 463 APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider; |
| 427 | 464 |
| 428 if (non_interactive == FALSE) | 465 if (non_interactive == FALSE) |
| 429 { | 466 { |
| 430 /* Two basic prompt providers: username/password, and just username. */ | 467 /* Two basic prompt providers: username/password, and just username. */ |
| 431 svn_auth_get_simple_prompt_provider(&provider, | 468 svn_auth_get_simple_prompt_provider(&provider, |
| 432 svn_cmdline_auth_simple_prompt, | 469 svn_cmdline_auth_simple_prompt, |
| 433 pb, | 470 pb, |
| 434 2, /* retry limit */ | 471 2, /* retry limit */ |
| 435 pool); | 472 pool); |
| 436 APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider; | 473 APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider; |
| 437 | 474 |
| 438 svn_auth_get_username_prompt_provider | 475 svn_auth_get_username_prompt_provider |
| 439 (&provider, svn_cmdline_auth_username_prompt, pb, | 476 (&provider, svn_cmdline_auth_username_prompt, pb, |
| 440 2, /* retry limit */ pool); | 477 2, /* retry limit */ pool); |
| 441 APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider; | 478 APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider; |
| 442 | 479 |
| 443 /* Three ssl prompt providers, for server-certs, client-certs, | 480 /* Three ssl prompt providers, for server-certs, client-certs, |
| 444 and client-cert-passphrases. */ | 481 and client-cert-passphrases. */ |
| 445 svn_auth_get_ssl_server_trust_prompt_provider | 482 svn_auth_get_ssl_server_trust_prompt_provider |
| 446 (&provider, svn_cmdline_auth_ssl_server_trust_prompt, pb, pool); | 483 (&provider, svn_cmdline_auth_ssl_server_trust_prompt, pb, pool); |
| 447 APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider; | 484 APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider; |
| 448 | 485 |
| 449 svn_auth_get_ssl_client_cert_prompt_provider | 486 svn_auth_get_ssl_client_cert_prompt_provider |
| 450 (&provider, svn_cmdline_auth_ssl_client_cert_prompt, pb, 2, pool); | 487 (&provider, svn_cmdline_auth_ssl_client_cert_prompt, pb, 2, pool); |
| 451 APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider; | 488 APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider; |
| 452 | 489 |
| 453 svn_auth_get_ssl_client_cert_pw_prompt_provider | 490 svn_auth_get_ssl_client_cert_pw_prompt_provider |
| 454 (&provider, svn_cmdline_auth_ssl_client_cert_pw_prompt, pb, 2, pool); | 491 (&provider, svn_cmdline_auth_ssl_client_cert_pw_prompt, pb, 2, pool); |
| 455 APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider; | 492 APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider; |
| 456 } | 493 } |
| 457 | 494 |
| 458 /* Build an authentication baton to give to libsvn_client. */ | 495 /* Build an authentication baton to give to libsvn_client. */ |
| 459 svn_auth_open(ab, providers, pool); | 496 svn_auth_open(ab, providers, pool); |
| 460 | 497 |
| 461 /* Place any default --username or --password credentials into the | 498 /* Place any default --username or --password credentials into the |
| 462 auth_baton's run-time parameter hash. */ | 499 auth_baton's run-time parameter hash. */ |
| 463 if (auth_username) | 500 if (auth_username) |
| 464 svn_auth_set_parameter(*ab, SVN_AUTH_PARAM_DEFAULT_USERNAME, | 501 svn_auth_set_parameter(*ab, SVN_AUTH_PARAM_DEFAULT_USERNAME, |
| 465 auth_username); | 502 auth_username); |
| 466 if (auth_password) | 503 if (auth_password) |
| 467 svn_auth_set_parameter(*ab, SVN_AUTH_PARAM_DEFAULT_PASSWORD, | 504 svn_auth_set_parameter(*ab, SVN_AUTH_PARAM_DEFAULT_PASSWORD, |
| 468 auth_password); | 505 auth_password); |
| 469 | 506 |
| 470 /* Same with the --non-interactive option. */ | 507 /* Same with the --non-interactive option. */ |
| 471 if (non_interactive) | 508 if (non_interactive) |
| 472 svn_auth_set_parameter(*ab, SVN_AUTH_PARAM_NON_INTERACTIVE, ""); | 509 svn_auth_set_parameter(*ab, SVN_AUTH_PARAM_NON_INTERACTIVE, ""); |
| 473 | 510 |
| 474 if (config_dir) | 511 if (config_dir) |
| 475 svn_auth_set_parameter(*ab, SVN_AUTH_PARAM_CONFIG_DIR, | 512 svn_auth_set_parameter(*ab, SVN_AUTH_PARAM_CONFIG_DIR, |
| 476 config_dir); | 513 config_dir); |
| 477 | 514 |
| 478 /* Determine whether storing passwords in any form is allowed. | 515 /* Determine whether storing passwords in any form is allowed. |
| 479 * This is the deprecated location for this option, the new | 516 * This is the deprecated location for this option, the new |
| 480 * location is SVN_CONFIG_CATEGORY_SERVERS. The RA layer may | 517 * location is SVN_CONFIG_CATEGORY_SERVERS. The RA layer may |
| 481 * override the value we set here. */ | 518 * override the value we set here. */ |
| 482 SVN_ERR(svn_config_get_bool(cfg, &store_password_val, | 519 SVN_ERR(svn_config_get_bool(cfg, &store_password_val, |
| 483 SVN_CONFIG_SECTION_AUTH, | 520 SVN_CONFIG_SECTION_AUTH, |
| 484 SVN_CONFIG_OPTION_STORE_PASSWORDS, | 521 SVN_CONFIG_OPTION_STORE_PASSWORDS, |
| 485 SVN_CONFIG_DEFAULT_OPTION_STORE_PASSWORDS)); | 522 SVN_CONFIG_DEFAULT_OPTION_STORE_PASSWORDS)); |
| 486 | 523 |
| 487 if (! store_password_val) | 524 if (! store_password_val) |
| 488 svn_auth_set_parameter(*ab, SVN_AUTH_PARAM_DONT_STORE_PASSWORDS, ""); | 525 svn_auth_set_parameter(*ab, SVN_AUTH_PARAM_DONT_STORE_PASSWORDS, ""); |
| 489 | 526 |
| 490 /* Determine whether we are allowed to write to the auth/ area. | 527 /* Determine whether we are allowed to write to the auth/ area. |
| 491 * This is the deprecated location for this option, the new | 528 * This is the deprecated location for this option, the new |
| 492 * location is SVN_CONFIG_CATEGORY_SERVERS. The RA layer may | 529 * location is SVN_CONFIG_CATEGORY_SERVERS. The RA layer may |
| 493 * override the value we set here. */ | 530 * override the value we set here. */ |
| 494 SVN_ERR(svn_config_get_bool(cfg, &store_auth_creds_val, | 531 SVN_ERR(svn_config_get_bool(cfg, &store_auth_creds_val, |
| 495 SVN_CONFIG_SECTION_AUTH, | 532 SVN_CONFIG_SECTION_AUTH, |
| 496 SVN_CONFIG_OPTION_STORE_AUTH_CREDS, | 533 SVN_CONFIG_OPTION_STORE_AUTH_CREDS, |
| 497 SVN_CONFIG_DEFAULT_OPTION_STORE_AUTH_CREDS)); | 534 SVN_CONFIG_DEFAULT_OPTION_STORE_AUTH_CREDS)); |
| 498 | 535 |
| 499 if (no_auth_cache || ! store_auth_creds_val) | 536 if (no_auth_cache || ! store_auth_creds_val) |
| 500 svn_auth_set_parameter(*ab, SVN_AUTH_PARAM_NO_AUTH_CACHE, ""); | 537 svn_auth_set_parameter(*ab, SVN_AUTH_PARAM_NO_AUTH_CACHE, ""); |
| 501 | 538 |
| 502 return SVN_NO_ERROR; | 539 return SVN_NO_ERROR; |
| 503 } | 540 } |
| 504 | 541 |
| 505 svn_error_t * | 542 svn_error_t * |
| 506 svn_cmdline__getopt_init(apr_getopt_t **os, | 543 svn_cmdline__getopt_init(apr_getopt_t **os, |
| 507 int argc, | 544 int argc, |
| 508 const char *argv[], | 545 const char *argv[], |
| 509 apr_pool_t *pool) | 546 apr_pool_t *pool) |
| 510 { | 547 { |
| 511 apr_status_t apr_err; | 548 apr_status_t apr_err; |
| 512 #ifdef AS400_UTF8 | 549 #ifdef AS400_UTF8 |
| 513 /* Convert command line args from EBCDIC to UTF-8. */ | 550 /* Convert command line args from EBCDIC to UTF-8. */ |
| 514 int i; | 551 int i; |
| 515 for (i = 0; i < argc; ++i) | 552 for (i = 0; i < argc; ++i) |
| 516 { | 553 { |
| 517 char *arg_utf8; | 554 char *arg_utf8; |
| 518 SVN_ERR(svn_utf_cstring_to_utf8_ex2(&arg_utf8, argv[i], | 555 SVN_ERR(svn_utf_cstring_to_utf8_ex2(&arg_utf8, argv[i], |
| 519 (const char *)0, pool)); | 556 (const char *)0, pool)); |
| 520 argv[i] = arg_utf8; | 557 argv[i] = arg_utf8; |
| 521 } | 558 } |
| 522 #endif | 559 #endif |
| 523 apr_err = apr_getopt_init(os, pool, argc, argv); | 560 apr_err = apr_getopt_init(os, pool, argc, argv); |
| 524 if (apr_err) | 561 if (apr_err) |
| 525 return svn_error_wrap_apr(apr_err, | 562 return svn_error_wrap_apr(apr_err, |
| 526 _("Error initializing command line arguments")); | 563 _("Error initializing command line arguments")); |
| 527 return SVN_NO_ERROR; | 564 return SVN_NO_ERROR; |
| 528 } | 565 } |
| 529 | 566 |
| 530 | 567 |
| 531 | 568 |
| OLD | NEW |