Index: cadaver-0.23.3/src/cadaver.c =================================================================== --- cadaver-0.23.3.orig/src/cadaver.c 2014-12-11 16:34:42.324917933 +0300 +++ cadaver-0.23.3/src/cadaver.c 2014-12-11 16:37:30.464128652 +0300 @@ -86,6 +86,7 @@ const char *lock_store_fn = NULL; static char *progname; /* argv[0] */ static char *rcfile; +static char *netrcfile; /* Global state: */ char *proxy_hostname; @@ -133,6 +134,7 @@ " -t, --tolerant Allow cd/open into non-WebDAV enabled collection.\n" " -F, --forcecert Do not stop on certificate errors (DANGEROUS!).\n" " -r, --rcfile=FILE Read script from FILE instead of ~/.cadaverrc.\n" +" -n, --netrcfile=FILE Read auth data from FILE instead of ~/.netrc.\n" " -p, --proxy=PROXY[:PORT] Use proxy host PROXY and optional proxy port PORT.\n" " -V, --version Display version information.\n" " -h, --help Display this help message.\n" @@ -450,10 +452,11 @@ { "tolerant", no_argument, NULL, 't' }, { "forcecert", no_argument, NULL, 'F' }, { "rcfile", required_argument, NULL, 'r' }, + { "netrcfile", required_argument, NULL, 'n' }, { 0, 0, 0, 0 } }; int optc; - while ((optc = getopt_long(argc, argv, "ehtFp:r:V", opts, NULL)) != -1) { + while ((optc = getopt_long(argc, argv, "ehtFp:r:n:V", opts, NULL)) != -1) { switch (optc) { case 'h': usage(); exit(-1); case 'V': execute_about(); exit(-1); @@ -461,6 +464,7 @@ case 't': tolerant = 1; break; case 'F': forcecert = 1; break; case 'r': rcfile = strdup(optarg); break; + case 'n': netrcfile = strdup(optarg); break; case '?': default: printf(_("Try `%s --help' for more information.\n"), progname); @@ -598,8 +602,13 @@ static void init_netrc(void) { #ifdef ENABLE_NETRC - char *netrc = ne_concat(getenv("HOME"), "/.netrc", NULL); - netrc_list = parse_netrc(netrc); + if (netrcfile == NULL) { + char *netrc = ne_concat(getenv("HOME"), "/.netrc", NULL); + netrc_list = parse_netrc(netrc); + } else { + netrc_list = parse_netrc(netrcfile); + free(netrcfile); + } #endif } @@ -887,16 +896,16 @@ /* Options before rcfile, so rcfile settings can * override defaults */ - tmp = ne_concat(home, "/.cadaver-locks", NULL); + tmp = ne_concat("/tmp/.cadaver-locks", NULL); set_option(opt_lockstore, tmp); init_options(); - init_netrc(); init_signals(); init_locking(); parse_args(argc, argv); + init_netrc(); ret = init_rcfile(); init_readline();