dav/main.c

changeset 734
b2cd82149116
parent 733
a7883961b5f4
child 739
bba6a6e221b4
equal deleted inserted replaced
733:a7883961b5f4 734:b2cd82149116
63 va_start(ap, msg); 63 va_start(ap, msg);
64 vfprintf(stderr, msg, ap); 64 vfprintf(stderr, msg, ap);
65 va_end(ap); 65 va_end(ap);
66 } 66 }
67 } 67 }
68
69 static Repository* url2repo(char *url, char **path);
70 static DavSession* connect_to_repo(Repository *repo, char *path, CmdArgs *a);
71 68
72 //define DO_THE_TEST 69 //define DO_THE_TEST
73 //include <libidav/davqlparser.h> 70 //include <libidav/davqlparser.h>
74 //include <libidav/davqlexec.h> 71 //include <libidav/davqlexec.h>
75 //include "tags.h" 72 //include "tags.h"
344 fprintf(stderr, " <repository>/path/\n"); 341 fprintf(stderr, " <repository>/path/\n");
345 fprintf(stderr, "\n"); 342 fprintf(stderr, "\n");
346 } 343 }
347 344
348 345
349 int request_auth2(DavSession *sn, void *userdata) {
350 Repository *repo = userdata;
351
352 char *user = NULL;
353 char ubuf[256];
354 if(repo->user) {
355 user = repo->user;
356 } else {
357 fprintf(stderr, "User: ");
358 fflush(stderr);
359 user = fgets(ubuf, 256, stdin);
360 }
361 if(!user) {
362 return 0;
363 }
364
365 char *password = util_password_input("Password: ");
366 if(!password || strlen(password) == 0) {
367 return 0;
368 }
369
370 size_t ulen = strlen(user);
371 if(user[ulen-1] == '\n') {
372 user[ulen-1] = '\0';
373 }
374
375 dav_session_set_auth(sn, user, password);
376 free(password);
377
378 return 0;
379 }
380
381 static Repository* url2repo_s(sstr_t url, char **path) {
382 *path = NULL;
383
384 int s;
385 if(sstrprefix(url, SC("http://"))) {
386 s = 7;
387 } else if(sstrprefix(url, SC("https://"))) {
388 s = 8;
389 } else {
390 s = 1;
391 }
392
393 // split URL into repository and path
394 sstr_t r = sstrsubs(url, s);
395 sstr_t p = sstrchr(r, '/');
396 r = sstrsubsl(url, 0, url.length-p.length);
397 if(p.length == 0) {
398 p = sstrn("/", 1);
399 }
400
401 Repository *repo = get_repository(r);
402 if(repo) {
403 *path = sstrdup(p).ptr;
404 } else {
405 // TODO: who is responsible for freeing this repository?
406 // how can the callee know, if he has to call free()?
407 repo = calloc(1, sizeof(Repository));
408 repo->name = strdup("");
409 repo->decrypt_content = true;
410 repo->verification = true;
411 repo->authmethods = CURLAUTH_BASIC;
412 if(url.ptr[url.length-1] == '/') {
413 repo->url = sstrdup(url).ptr;
414 *path = strdup("/");
415 } else if (sstrchr(url, '/').length > 0) {
416 // TODO: fix the following workaround after
417 // fixing the inconsistent behavior of util_url_*()
418 repo->url = util_url_base_s(url);
419 sstr_t truncated = sstrdup(url);
420 *path = strdup(util_url_path(truncated.ptr));
421 free(truncated.ptr);
422 } else {
423 repo->url = sstrdup(url).ptr;
424 *path = strdup("/");
425 }
426 }
427
428 return repo;
429 }
430
431 static Repository* url2repo(char *url, char **path) {
432 return url2repo_s(sstr(url), path);
433 }
434 346
435 static int set_session_config(DavSession *sn, CmdArgs *a) { 347 static int set_session_config(DavSession *sn, CmdArgs *a) {
436 char *plain = cmd_getoption(a, "plain"); 348 char *plain = cmd_getoption(a, "plain");
437 char *crypt = cmd_getoption(a, "crypt"); 349 char *crypt = cmd_getoption(a, "crypt");
438 350
461 DavLock *lock = dav_create_lock(sn, locktoken, NULL); 373 DavLock *lock = dav_create_lock(sn, locktoken, NULL);
462 dav_add_collection_lock(sn, "/", lock); 374 dav_add_collection_lock(sn, "/", lock);
463 } 375 }
464 } 376 }
465 377
466 static int decrypt_secrets(CmdArgs *a, PwdStore *secrets) {
467 if(cmd_getoption(a, "noinput")) {
468 return 1;
469 }
470
471 char *ps_password = NULL;
472 if(secrets->unlock_cmd && strlen(secrets->unlock_cmd) > 0) {
473 UcxBuffer *cmd_out = ucx_buffer_new(NULL, 128, UCX_BUFFER_AUTOEXTEND);
474 if(!util_exec_command(secrets->unlock_cmd, cmd_out)) {
475 // command successful, get first line from output without newline
476 // and use that as password for the secretstore
477 size_t len = 0;
478 for(size_t i=0;i<=cmd_out->size;i++) {
479 if(i == cmd_out->size || cmd_out->space[i] == '\n') {
480 len = i;
481 break;
482 }
483 }
484 if(len > 0) {
485 ps_password = malloc(len + 1);
486 memcpy(ps_password, cmd_out->space, len);
487 ps_password[len] = 0;
488 }
489 }
490 ucx_buffer_free(cmd_out);
491 }
492
493 if(!ps_password) {
494 ps_password = util_password_input("Master password: ");
495 if(!ps_password) {
496 return 1;
497 }
498 }
499
500 if(pwdstore_setpassword(secrets, ps_password)) {
501 fprintf(stderr, "Error: cannot create key from password\n");
502 return 1;
503 }
504 if(pwdstore_decrypt(secrets)) {
505 fprintf(stderr, "Error: cannot decrypt secrets store\n");
506 return 1;
507 }
508 return 0;
509 }
510
511 static int get_stored_credentials(CmdArgs *a, char *credid, char **user, char **password) {
512 if(!credid) {
513 return 0;
514 }
515
516 PwdStore *secrets = get_pwdstore();
517 if(!secrets) {
518 fprintf(stderr, "Error: no secrets store available\n");
519 return 0;
520 }
521
522 if(pwdstore_has_id(secrets, credid)) {
523 if(!secrets->isdecrypted) {
524 if(decrypt_secrets(a, secrets)) {
525 return 0;
526 }
527 }
528
529 PwdEntry *s_cred = pwdstore_get(secrets, credid);
530 if(s_cred) {
531 *user = s_cred->user;
532 *password = s_cred->password;
533 return 1;
534 }
535 } else {
536 fprintf(stderr, "Error: credentials id '%s' not found\n", credid);
537 }
538
539 return 0;
540 }
541
542 typedef struct CredLocation {
543 char *id;
544 char *location;
545 } CredLocation;
546
547 static int cmp_url_cred_entry(CredLocation *e1, CredLocation *e2, void *n) {
548 return strcmp(e2->location, e1->location);
549 }
550
551 static void free_cred_location(CredLocation *c) {
552 // c->id is not a copy, therefore we don't have to free it
553 free(c->location);
554 free(c);
555 }
556
557 static int get_location_credentials(CmdArgs *a, Repository *repo, char *path, char **user, char **password) {
558 PwdStore *secrets = get_pwdstore();
559 if(!secrets) {
560 return 0;
561 }
562
563 /*
564 * The list secrets->location contains urls or repo names as
565 * location strings. We need a list, that contains only urls
566 */
567 UcxList *locations = NULL;
568 UCX_FOREACH(elm, secrets->locations) {
569 PwdIndexEntry *e = elm->data;
570
571 UCX_FOREACH(loc, e->locations) {
572 char *path;
573 Repository *r = url2repo(loc->data, &path);
574 CredLocation *urlentry = calloc(1, sizeof(CredLocation));
575 urlentry->id = e->id;
576 urlentry->location = util_concat_path(r->url, path);
577 locations = ucx_list_append(locations, urlentry);
578 }
579 }
580 // the list must be sorted
581 locations = ucx_list_sort(locations, (cmp_func)cmp_url_cred_entry, NULL);
582
583 // create full request url string and remove protocol prefix
584 sstr_t req_url_proto = sstr(util_concat_path(repo->url, path));
585 sstr_t req_url = req_url_proto;
586 if(sstrprefix(req_url, S("http://"))) {
587 req_url = sstrsubs(req_url, 7);
588 } else if(sstrprefix(req_url, S("https://"))) {
589 req_url = sstrsubs(req_url, 8);
590 }
591
592 // iterate over sorted locations and check if a location is a prefix
593 // of the requested url
594 char *id = NULL;
595 int ret = 0;
596 UCX_FOREACH(elm, locations) {
597 CredLocation *cred = elm->data;
598 sstr_t cred_url = sstr(cred->location);
599
600 // remove protocol prefix
601 if(sstrprefix(cred_url, S("http://"))) {
602 cred_url = sstrsubs(cred_url, 7);
603 } else if(sstrprefix(cred_url, S("https://"))) {
604 cred_url = sstrsubs(cred_url, 8);
605 }
606
607 if(sstrprefix(req_url, cred_url)) {
608 id = cred->id;
609 break;
610 }
611 }
612
613 // if an id is found and we can access the decrypted secret store
614 // we can set the user/password
615 if(id && (secrets->isdecrypted || !decrypt_secrets(a, secrets))) {
616 PwdEntry *cred = pwdstore_get(secrets, id);
617 if(cred) {
618 *user = cred->user;
619 *password = cred->password;
620 ret = 1;
621 }
622 }
623
624 free(req_url_proto.ptr);
625 ucx_list_free_content(locations, (ucx_destructor)free_cred_location);
626 ucx_list_free(locations);
627
628 return ret;
629 }
630
631 static DavSession* connect_to_repo(Repository *repo, char *path, CmdArgs *a) {
632 char *user = repo->user;
633 char *password = repo->password;
634
635 if(!user && !password) {
636 if(!get_stored_credentials(a, repo->stored_user, &user, &password)) {
637 get_location_credentials(a, repo, path, &user, &password);
638 }
639 }
640
641 DavSession *sn = dav_session_new_auth(ctx, repo->url, user, password);
642 sn->flags = get_repository_flags(repo);
643 sn->key = dav_context_get_key(ctx, repo->default_key);
644 curl_easy_setopt(sn->handle, CURLOPT_HTTPAUTH, repo->authmethods);
645 curl_easy_setopt(sn->handle, CURLOPT_SSLVERSION, repo->ssl_version);
646 if(repo->cert) {
647 curl_easy_setopt(sn->handle, CURLOPT_CAINFO, repo->cert);
648 }
649 if(!repo->verification || cmd_getoption(a, "insecure")) {
650 curl_easy_setopt(sn->handle, CURLOPT_SSL_VERIFYPEER, 0);
651 curl_easy_setopt(sn->handle, CURLOPT_SSL_VERIFYHOST, 0);
652 }
653 if(!cmd_getoption(a, "noinput")) {
654 dav_session_set_authcallback(sn, request_auth2, repo);
655 }
656 return sn;
657 }
658 378
659 int update_progress(DavResource *res, int64_t total, int64_t now, Progress *p) { 379 int update_progress(DavResource *res, int64_t total, int64_t now, Progress *p) {
660 int ret = 0; 380 int ret = 0;
661 if(res != p->last_resource) { 381 if(res != p->last_resource) {
662 p->cur += p->last_res_total - p->last_res_cur; 382 p->cur += p->last_res_total - p->last_res_cur;
696 } 416 }
697 417
698 char *url = a->argv[0]; 418 char *url = a->argv[0];
699 char *path = NULL; 419 char *path = NULL;
700 Repository *repo = url2repo(url, &path); 420 Repository *repo = url2repo(url, &path);
701 DavSession *sn = connect_to_repo(repo, path, a); 421 DavSession *sn = connect_to_repo(ctx, repo, path, request_auth, a);
702 422
703 if(set_session_config(sn, a)) { 423 if(set_session_config(sn, a)) {
704 return -1; 424 return -1;
705 } 425 }
706 426
875 } 595 }
876 596
877 char *url = a->argv[0]; 597 char *url = a->argv[0];
878 char *path = NULL; 598 char *path = NULL;
879 Repository *repo = url2repo(url, &path); 599 Repository *repo = url2repo(url, &path);
880 DavSession *sn = connect_to_repo(repo, path, a); 600 DavSession *sn = connect_to_repo(ctx, repo, path, request_auth, a);
881 601
882 if(set_session_config(sn, a)) { 602 if(set_session_config(sn, a)) {
883 return -1; 603 return -1;
884 } 604 }
885 605
1121 } 841 }
1122 842
1123 char *url = a->argv[0]; 843 char *url = a->argv[0];
1124 char *path = NULL; 844 char *path = NULL;
1125 Repository *repo = url2repo(url, &path); 845 Repository *repo = url2repo(url, &path);
1126 DavSession *sn = connect_to_repo(repo, path, a); 846 DavSession *sn = connect_to_repo(ctx, repo, path, request_auth, a);
1127 847
1128 if(set_session_config(sn, a)) { 848 if(set_session_config(sn, a)) {
1129 return -1; 849 return -1;
1130 } 850 }
1131 set_session_lock(sn, a); 851 set_session_lock(sn, a);
1419 } 1139 }
1420 1140
1421 char *url = a->argv[0]; 1141 char *url = a->argv[0];
1422 char *path = NULL; 1142 char *path = NULL;
1423 Repository *repo = url2repo(url, &path); 1143 Repository *repo = url2repo(url, &path);
1424 DavSession *sn = connect_to_repo(repo, path, a); 1144 DavSession *sn = connect_to_repo(ctx, repo, path, request_auth, a);
1425 1145
1426 if(set_session_config(sn, a)) { 1146 if(set_session_config(sn, a)) {
1427 return -1; 1147 return -1;
1428 } 1148 }
1429 set_session_lock(sn, a); 1149 set_session_lock(sn, a);
1758 } 1478 }
1759 1479
1760 char *url = a->argv[0]; 1480 char *url = a->argv[0];
1761 char *path = NULL; 1481 char *path = NULL;
1762 Repository *repo = url2repo(url, &path); 1482 Repository *repo = url2repo(url, &path);
1763 DavSession *sn = connect_to_repo(repo, path, a); 1483 DavSession *sn = connect_to_repo(ctx, repo, path, request_auth, a);
1764 1484
1765 int exit_code = -1; 1485 int exit_code = -1;
1766 assert(!!path && !!sn); 1486 assert(!!path && !!sn);
1767 1487
1768 if(set_session_config(sn, a)) { 1488 if(set_session_config(sn, a)) {
1827 1547
1828 char *srcurl = a->argv[0]; 1548 char *srcurl = a->argv[0];
1829 char *srcpath = NULL; 1549 char *srcpath = NULL;
1830 Repository *srcrepo = url2repo(srcurl, &srcpath); 1550 Repository *srcrepo = url2repo(srcurl, &srcpath);
1831 1551
1832 DavSession *srcsn = connect_to_repo(srcrepo, srcpath, a); 1552 DavSession *srcsn = connect_to_repo(ctx, srcrepo, srcpath, request_auth, a);
1833 if(set_session_config(srcsn, a)) { 1553 if(set_session_config(srcsn, a)) {
1834 return -1; 1554 return -1;
1835 } 1555 }
1836 set_session_lock(srcsn, a); 1556 set_session_lock(srcsn, a);
1837 1557
1852 } 1572 }
1853 } else { 1573 } else {
1854 char *srchost = util_url_base(srcrepo->url); 1574 char *srchost = util_url_base(srcrepo->url);
1855 char *desthost = util_url_base(destrepo->url); 1575 char *desthost = util_url_base(destrepo->url);
1856 if(!strcmp(srchost, desthost)) { 1576 if(!strcmp(srchost, desthost)) {
1857 DavSession *destsn = connect_to_repo(destrepo, destpath, a); 1577 DavSession *destsn = connect_to_repo(ctx, destrepo, destpath, request_auth, a);
1858 if(set_session_config(destsn, a)) { 1578 if(set_session_config(destsn, a)) {
1859 return -1; 1579 return -1;
1860 } 1580 }
1861 DavResource *dest = dav_resource_new(destsn, destpath); 1581 DavResource *dest = dav_resource_new(destsn, destpath);
1862 char *desthref = dav_resource_get_href(dest); 1582 char *desthref = dav_resource_get_href(dest);
1904 } 1624 }
1905 1625
1906 char *url = a->argv[0]; 1626 char *url = a->argv[0];
1907 char *path = NULL; 1627 char *path = NULL;
1908 Repository *repo = url2repo(url, &path); 1628 Repository *repo = url2repo(url, &path);
1909 DavSession *sn = connect_to_repo(repo, path, a); 1629 DavSession *sn = connect_to_repo(ctx, repo, path, request_auth, a);
1910 1630
1911 if(set_session_config(sn, a)) { 1631 if(set_session_config(sn, a)) {
1912 return -1; 1632 return -1;
1913 } 1633 }
1914 set_session_lock(sn, a); 1634 set_session_lock(sn, a);
1997 fwrite(str, 1, len, stdout); 1717 fwrite(str, 1, len, stdout);
1998 } else if (a->argc == 1) { 1718 } else if (a->argc == 1) {
1999 char *url = a->argv[0]; 1719 char *url = a->argv[0];
2000 char *path = NULL; 1720 char *path = NULL;
2001 Repository *repo = url2repo(url, &path); 1721 Repository *repo = url2repo(url, &path);
2002 DavSession *sn = connect_to_repo(repo, path, a); 1722 DavSession *sn = connect_to_repo(ctx, repo, path, request_auth, a);
2003 1723
2004 DavResource *res = dav_resource_new(sn, path); 1724 DavResource *res = dav_resource_new(sn, path);
2005 char *date = NULL; 1725 char *date = NULL;
2006 curl_easy_setopt(sn->handle, CURLOPT_HEADERFUNCTION, get_date_header_cb); 1726 curl_easy_setopt(sn->handle, CURLOPT_HEADERFUNCTION, get_date_header_cb);
2007 curl_easy_setopt(sn->handle, CURLOPT_WRITEHEADER, &date); 1727 curl_easy_setopt(sn->handle, CURLOPT_WRITEHEADER, &date);
2028 } 1748 }
2029 1749
2030 char *url = a->argv[0]; 1750 char *url = a->argv[0];
2031 char *path = NULL; 1751 char *path = NULL;
2032 Repository *repo = url2repo(url, &path); 1752 Repository *repo = url2repo(url, &path);
2033 DavSession *sn = connect_to_repo(repo, path, a); 1753 DavSession *sn = connect_to_repo(ctx, repo, path, request_auth, a);
2034 1754
2035 if(set_session_config(sn, a)) { 1755 if(set_session_config(sn, a)) {
2036 return -1; 1756 return -1;
2037 } 1757 }
2038 1758
2102 } 1822 }
2103 1823
2104 char *url = a->argv[0]; 1824 char *url = a->argv[0];
2105 char *path = NULL; 1825 char *path = NULL;
2106 Repository *repo = url2repo(url, &path); 1826 Repository *repo = url2repo(url, &path);
2107 DavSession *sn = connect_to_repo(repo, path, a); 1827 DavSession *sn = connect_to_repo(ctx, repo, path, request_auth, a);
2108 1828
2109 if(set_session_config(sn, a)) { 1829 if(set_session_config(sn, a)) {
2110 return -1; 1830 return -1;
2111 } 1831 }
2112 set_session_lock(sn, a); 1832 set_session_lock(sn, a);
2165 } 1885 }
2166 1886
2167 char *url = a->argv[0]; 1887 char *url = a->argv[0];
2168 char *path = NULL; 1888 char *path = NULL;
2169 Repository *repo = url2repo(url, &path); 1889 Repository *repo = url2repo(url, &path);
2170 DavSession *sn = connect_to_repo(repo, path, a); 1890 DavSession *sn = connect_to_repo(ctx, repo, path, request_auth, a);
2171 1891
2172 if(set_session_config(sn, a)) { 1892 if(set_session_config(sn, a)) {
2173 return -1; 1893 return -1;
2174 } 1894 }
2175 1895
2206 } 1926 }
2207 1927
2208 char *url = a->argv[0]; 1928 char *url = a->argv[0];
2209 char *path = NULL; 1929 char *path = NULL;
2210 Repository *repo = url2repo(url, &path); 1930 Repository *repo = url2repo(url, &path);
2211 DavSession *sn = connect_to_repo(repo, path, a); 1931 DavSession *sn = connect_to_repo(ctx, repo, path, request_auth, a);
2212 ucx_mempool_reg_destr(sn->mp, path, free); 1932 ucx_mempool_reg_destr(sn->mp, path, free);
2213 1933
2214 if(set_session_config(sn, a)) { 1934 if(set_session_config(sn, a)) {
2215 return -1; 1935 return -1;
2216 } 1936 }
2278 } 1998 }
2279 1999
2280 char *url = a->argv[0]; 2000 char *url = a->argv[0];
2281 char *path = NULL; 2001 char *path = NULL;
2282 Repository *repo = url2repo(url, &path); 2002 Repository *repo = url2repo(url, &path);
2283 DavSession *sn = connect_to_repo(repo, path, a); 2003 DavSession *sn = connect_to_repo(ctx, repo, path, request_auth, a);
2284 ucx_mempool_reg_destr(sn->mp, path, free); 2004 ucx_mempool_reg_destr(sn->mp, path, free);
2285 if(set_session_config(sn, a)) { 2005 if(set_session_config(sn, a)) {
2286 return -1; 2006 return -1;
2287 } 2007 }
2288 2008
2338 } 2058 }
2339 2059
2340 char *url = a->argv[0]; 2060 char *url = a->argv[0];
2341 char *path = NULL; 2061 char *path = NULL;
2342 Repository *repo = url2repo(url, &path); 2062 Repository *repo = url2repo(url, &path);
2343 DavSession *sn = connect_to_repo(repo, path, a); 2063 DavSession *sn = connect_to_repo(ctx, repo, path, request_auth, a);
2344 2064
2345 if(set_session_config(sn, a)) { 2065 if(set_session_config(sn, a)) {
2346 return -1; 2066 return -1;
2347 } 2067 }
2348 2068
2434 } 2154 }
2435 2155
2436 char *url = a->argv[0]; 2156 char *url = a->argv[0];
2437 char *path = NULL; 2157 char *path = NULL;
2438 Repository *repo = url2repo(url, &path); 2158 Repository *repo = url2repo(url, &path);
2439 DavSession *sn = connect_to_repo(repo, path, a); 2159 DavSession *sn = connect_to_repo(ctx, repo, path, request_auth, a);
2440 2160
2441 if(set_session_config(sn, a)) { 2161 if(set_session_config(sn, a)) {
2442 return -1; 2162 return -1;
2443 } 2163 }
2444 set_session_lock(sn, a); 2164 set_session_lock(sn, a);
2461 } 2181 }
2462 2182
2463 char *url = a->argv[0]; 2183 char *url = a->argv[0];
2464 char *path = NULL; 2184 char *path = NULL;
2465 Repository *repo = url2repo(url, &path); 2185 Repository *repo = url2repo(url, &path);
2466 DavSession *sn = connect_to_repo(repo, path, a); 2186 DavSession *sn = connect_to_repo(ctx, repo, path, request_auth, a);
2467 2187
2468 if(set_session_config(sn, a)) { 2188 if(set_session_config(sn, a)) {
2469 return -1; 2189 return -1;
2470 } 2190 }
2471 set_session_lock(sn, a); 2191 set_session_lock(sn, a);
2488 } 2208 }
2489 2209
2490 char *url = a->argv[0]; 2210 char *url = a->argv[0];
2491 char *path = NULL; 2211 char *path = NULL;
2492 Repository *repo = url2repo(url, &path); 2212 Repository *repo = url2repo(url, &path);
2493 DavSession *sn = connect_to_repo(repo, path, a); 2213 DavSession *sn = connect_to_repo(ctx, repo, path, request_auth, a);
2494 2214
2495 if(set_session_config(sn, a)) { 2215 if(set_session_config(sn, a)) {
2496 return -1; 2216 return -1;
2497 } 2217 }
2498 set_session_lock(sn, a); 2218 set_session_lock(sn, a);
2514 } 2234 }
2515 2235
2516 char *url = a->argv[0]; 2236 char *url = a->argv[0];
2517 char *path = NULL; 2237 char *path = NULL;
2518 Repository *repo = url2repo(url, &path); 2238 Repository *repo = url2repo(url, &path);
2519 DavSession *sn = connect_to_repo(repo, path, a); 2239 DavSession *sn = connect_to_repo(ctx, repo, path, request_auth, a);
2520 2240
2521 if(set_session_config(sn, a)) { 2241 if(set_session_config(sn, a)) {
2522 return -1; 2242 return -1;
2523 } 2243 }
2524 set_session_lock(sn, a); 2244 set_session_lock(sn, a);
2541 } 2261 }
2542 2262
2543 char *url = a->argv[0]; 2263 char *url = a->argv[0];
2544 char *path = NULL; 2264 char *path = NULL;
2545 Repository *repo = url2repo(url, &path); 2265 Repository *repo = url2repo(url, &path);
2546 DavSession *sn = connect_to_repo(repo, path, a); 2266 DavSession *sn = connect_to_repo(ctx, repo, path, request_auth, a);
2547 2267
2548 if(set_session_config(sn, a)) { 2268 if(set_session_config(sn, a)) {
2549 return -1; 2269 return -1;
2550 } 2270 }
2551 2271
3381 // url completion 3101 // url completion
3382 ucx_map_cstr_put(args->options, "noinput", ""); 3102 ucx_map_cstr_put(args->options, "noinput", "");
3383 3103
3384 char *path = NULL; 3104 char *path = NULL;
3385 Repository *repo = url2repo_s(url, &path); 3105 Repository *repo = url2repo_s(url, &path);
3386 DavSession *sn = connect_to_repo(repo, path, args); 3106 DavSession *sn = connect_to_repo(ctx, repo, path, request_auth, args);
3387 if(!sn) { 3107 if(!sn) {
3388 return 0; 3108 return 0;
3389 } 3109 }
3390 if(set_session_config(sn, args)) { 3110 if(set_session_config(sn, args)) {
3391 return 0; 3111 return 0;

mercurial