Fossil SCM

Fix remote-url overwriting by proxy url bug and use the http_proxy environment variable only when explicitly requested by setting the proxy setting to "system".

mgagnon 2022-05-11 15:42 trunk merge
Commit a791d5e8058b32852d992a04a0b1d0f2814fc93660cb197568a5f1e6a384c0cd
3 files changed +2 -4 +9 -3 +12 -4
+2 -4
--- src/db.c
+++ src/db.c
@@ -4368,14 +4368,12 @@
43684368
** which will cause the client to avoid generating a delta
43694369
** manifest.
43704370
*/
43714371
/*
43724372
** SETTING: proxy width=32 default=off
4373
-** URL of the HTTP proxy. If undefined or "off" then
4374
-** the "http_proxy" environment variable is consulted.
4375
-** If the http_proxy environment variable is undefined
4376
-** then a direct HTTP connection is used.
4373
+** URL of the HTTP proxy. If "system", the "http_proxy" environment variable is
4374
+** consulted. If undefined or "off", a direct HTTP connection is used.
43774375
*/
43784376
/*
43794377
** SETTING: redirect-to-https default=0 width=-1
43804378
** Specifies whether or not to redirect http:// requests to
43814379
** https:// URIs. A value of 0 (the default) means not to
43824380
--- src/db.c
+++ src/db.c
@@ -4368,14 +4368,12 @@
4368 ** which will cause the client to avoid generating a delta
4369 ** manifest.
4370 */
4371 /*
4372 ** SETTING: proxy width=32 default=off
4373 ** URL of the HTTP proxy. If undefined or "off" then
4374 ** the "http_proxy" environment variable is consulted.
4375 ** If the http_proxy environment variable is undefined
4376 ** then a direct HTTP connection is used.
4377 */
4378 /*
4379 ** SETTING: redirect-to-https default=0 width=-1
4380 ** Specifies whether or not to redirect http:// requests to
4381 ** https:// URIs. A value of 0 (the default) means not to
4382
--- src/db.c
+++ src/db.c
@@ -4368,14 +4368,12 @@
4368 ** which will cause the client to avoid generating a delta
4369 ** manifest.
4370 */
4371 /*
4372 ** SETTING: proxy width=32 default=off
4373 ** URL of the HTTP proxy. If "system", the "http_proxy" environment variable is
4374 ** consulted. If undefined or "off", a direct HTTP connection is used.
 
 
4375 */
4376 /*
4377 ** SETTING: redirect-to-https default=0 width=-1
4378 ** Specifies whether or not to redirect http:// requests to
4379 ** https:// URIs. A value of 0 (the default) means not to
4380
+9 -3
--- src/sync.c
+++ src/sync.c
@@ -24,16 +24,22 @@
2424
/*
2525
** Explain what type of sync operation is about to occur
2626
*/
2727
static void sync_explain(unsigned syncFlags){
2828
if( g.url.isAlias ){
29
+ const char *url;
30
+ if( g.url.useProxy ){
31
+ url = g.url.proxyUrlCanonical;
32
+ }else{
33
+ url = g.url.canonical;
34
+ }
2935
if( (syncFlags & (SYNC_PUSH|SYNC_PULL))==(SYNC_PUSH|SYNC_PULL) ){
30
- fossil_print("Sync with %s\n", g.url.canonical);
36
+ fossil_print("Sync with %s\n", url);
3137
}else if( syncFlags & SYNC_PUSH ){
32
- fossil_print("Push to %s\n", g.url.canonical);
38
+ fossil_print("Push to %s\n", url);
3339
}else if( syncFlags & SYNC_PULL ){
34
- fossil_print("Pull from %s\n", g.url.canonical);
40
+ fossil_print("Pull from %s\n", url);
3541
}
3642
}
3743
}
3844
3945
4046
--- src/sync.c
+++ src/sync.c
@@ -24,16 +24,22 @@
24 /*
25 ** Explain what type of sync operation is about to occur
26 */
27 static void sync_explain(unsigned syncFlags){
28 if( g.url.isAlias ){
 
 
 
 
 
 
29 if( (syncFlags & (SYNC_PUSH|SYNC_PULL))==(SYNC_PUSH|SYNC_PULL) ){
30 fossil_print("Sync with %s\n", g.url.canonical);
31 }else if( syncFlags & SYNC_PUSH ){
32 fossil_print("Push to %s\n", g.url.canonical);
33 }else if( syncFlags & SYNC_PULL ){
34 fossil_print("Pull from %s\n", g.url.canonical);
35 }
36 }
37 }
38
39
40
--- src/sync.c
+++ src/sync.c
@@ -24,16 +24,22 @@
24 /*
25 ** Explain what type of sync operation is about to occur
26 */
27 static void sync_explain(unsigned syncFlags){
28 if( g.url.isAlias ){
29 const char *url;
30 if( g.url.useProxy ){
31 url = g.url.proxyUrlCanonical;
32 }else{
33 url = g.url.canonical;
34 }
35 if( (syncFlags & (SYNC_PUSH|SYNC_PULL))==(SYNC_PUSH|SYNC_PULL) ){
36 fossil_print("Sync with %s\n", url);
37 }else if( syncFlags & SYNC_PUSH ){
38 fossil_print("Push to %s\n", url);
39 }else if( syncFlags & SYNC_PULL ){
40 fossil_print("Pull from %s\n", url);
41 }
42 }
43 }
44
45
46
+12 -4
--- src/url.c
+++ src/url.c
@@ -63,11 +63,12 @@
6363
char *canonical; /* Canonical representation of the URL */
6464
char *proxyAuth; /* Proxy-Authorizer: string */
6565
char *fossil; /* The fossil query parameter on ssh: */
6666
unsigned flags; /* Boolean flags controlling URL processing */
6767
int useProxy; /* Used to remember that a proxy is in use */
68
- char *proxyUrlPath;
68
+ char *proxyUrlPath; /* Remember path when proxy is use */
69
+ char *proxyUrlCanonical; /* Remember canonical path when proxy is use */
6970
int proxyOrigPort; /* Tunneled port number for https through proxy */
7071
};
7172
#endif /* INTERFACE */
7273
7374
@@ -534,11 +535,11 @@
534535
void url_enable_proxy(const char *zMsg){
535536
const char *zProxy;
536537
zProxy = zProxyOpt;
537538
if( zProxy==0 ){
538539
zProxy = db_get("proxy", 0);
539
- if( zProxy==0 || zProxy[0]==0 || is_false(zProxy) ){
540
+ if( fossil_strcmp(zProxy, "system")==0 ){
540541
zProxy = fossil_getenv("http_proxy");
541542
}
542543
}
543544
if( zProxy && zProxy[0] && !is_false(zProxy)
544545
&& !g.url.isSsh && !g.url.isFile ){
@@ -564,10 +565,11 @@
564565
}
565566
g.url.user = zOriginalUser;
566567
g.url.passwd = zOriginalPasswd;
567568
g.url.isHttps = fOriginalIsHttps;
568569
g.url.useProxy = 1;
570
+ g.url.proxyUrlCanonical = zOriginalUrl;;
569571
g.url.proxyUrlPath = zOriginalUrlPath;
570572
g.url.proxyOrigPort = iOriginalPort;
571573
g.url.flags = uOriginalFlags;
572574
}
573575
}
@@ -722,14 +724,20 @@
722724
/*
723725
** Remember the URL and password if requested.
724726
*/
725727
void url_remember(void){
726728
if( g.url.flags & URL_REMEMBER ){
729
+ const char *url;
730
+ if( g.url.useProxy ){
731
+ url = g.url.proxyUrlCanonical;
732
+ }else{
733
+ url = g.url.canonical;
734
+ }
727735
if( g.url.flags & URL_USE_PARENT ){
728
- db_set("parent-project-url", g.url.canonical, 0);
736
+ db_set("parent-project-url", url, 0);
729737
}else{
730
- db_set("last-sync-url", g.url.canonical, 0);
738
+ db_set("last-sync-url", url, 0);
731739
}
732740
if( g.url.user!=0 && g.url.passwd!=0 && ( g.url.flags & URL_REMEMBER_PW ) ){
733741
if( g.url.flags & URL_USE_PARENT ){
734742
db_set("parent-project-pw", obscure(g.url.passwd), 0);
735743
}else{
736744
--- src/url.c
+++ src/url.c
@@ -63,11 +63,12 @@
63 char *canonical; /* Canonical representation of the URL */
64 char *proxyAuth; /* Proxy-Authorizer: string */
65 char *fossil; /* The fossil query parameter on ssh: */
66 unsigned flags; /* Boolean flags controlling URL processing */
67 int useProxy; /* Used to remember that a proxy is in use */
68 char *proxyUrlPath;
 
69 int proxyOrigPort; /* Tunneled port number for https through proxy */
70 };
71 #endif /* INTERFACE */
72
73
@@ -534,11 +535,11 @@
534 void url_enable_proxy(const char *zMsg){
535 const char *zProxy;
536 zProxy = zProxyOpt;
537 if( zProxy==0 ){
538 zProxy = db_get("proxy", 0);
539 if( zProxy==0 || zProxy[0]==0 || is_false(zProxy) ){
540 zProxy = fossil_getenv("http_proxy");
541 }
542 }
543 if( zProxy && zProxy[0] && !is_false(zProxy)
544 && !g.url.isSsh && !g.url.isFile ){
@@ -564,10 +565,11 @@
564 }
565 g.url.user = zOriginalUser;
566 g.url.passwd = zOriginalPasswd;
567 g.url.isHttps = fOriginalIsHttps;
568 g.url.useProxy = 1;
 
569 g.url.proxyUrlPath = zOriginalUrlPath;
570 g.url.proxyOrigPort = iOriginalPort;
571 g.url.flags = uOriginalFlags;
572 }
573 }
@@ -722,14 +724,20 @@
722 /*
723 ** Remember the URL and password if requested.
724 */
725 void url_remember(void){
726 if( g.url.flags & URL_REMEMBER ){
 
 
 
 
 
 
727 if( g.url.flags & URL_USE_PARENT ){
728 db_set("parent-project-url", g.url.canonical, 0);
729 }else{
730 db_set("last-sync-url", g.url.canonical, 0);
731 }
732 if( g.url.user!=0 && g.url.passwd!=0 && ( g.url.flags & URL_REMEMBER_PW ) ){
733 if( g.url.flags & URL_USE_PARENT ){
734 db_set("parent-project-pw", obscure(g.url.passwd), 0);
735 }else{
736
--- src/url.c
+++ src/url.c
@@ -63,11 +63,12 @@
63 char *canonical; /* Canonical representation of the URL */
64 char *proxyAuth; /* Proxy-Authorizer: string */
65 char *fossil; /* The fossil query parameter on ssh: */
66 unsigned flags; /* Boolean flags controlling URL processing */
67 int useProxy; /* Used to remember that a proxy is in use */
68 char *proxyUrlPath; /* Remember path when proxy is use */
69 char *proxyUrlCanonical; /* Remember canonical path when proxy is use */
70 int proxyOrigPort; /* Tunneled port number for https through proxy */
71 };
72 #endif /* INTERFACE */
73
74
@@ -534,11 +535,11 @@
535 void url_enable_proxy(const char *zMsg){
536 const char *zProxy;
537 zProxy = zProxyOpt;
538 if( zProxy==0 ){
539 zProxy = db_get("proxy", 0);
540 if( fossil_strcmp(zProxy, "system")==0 ){
541 zProxy = fossil_getenv("http_proxy");
542 }
543 }
544 if( zProxy && zProxy[0] && !is_false(zProxy)
545 && !g.url.isSsh && !g.url.isFile ){
@@ -564,10 +565,11 @@
565 }
566 g.url.user = zOriginalUser;
567 g.url.passwd = zOriginalPasswd;
568 g.url.isHttps = fOriginalIsHttps;
569 g.url.useProxy = 1;
570 g.url.proxyUrlCanonical = zOriginalUrl;;
571 g.url.proxyUrlPath = zOriginalUrlPath;
572 g.url.proxyOrigPort = iOriginalPort;
573 g.url.flags = uOriginalFlags;
574 }
575 }
@@ -722,14 +724,20 @@
724 /*
725 ** Remember the URL and password if requested.
726 */
727 void url_remember(void){
728 if( g.url.flags & URL_REMEMBER ){
729 const char *url;
730 if( g.url.useProxy ){
731 url = g.url.proxyUrlCanonical;
732 }else{
733 url = g.url.canonical;
734 }
735 if( g.url.flags & URL_USE_PARENT ){
736 db_set("parent-project-url", url, 0);
737 }else{
738 db_set("last-sync-url", url, 0);
739 }
740 if( g.url.user!=0 && g.url.passwd!=0 && ( g.url.flags & URL_REMEMBER_PW ) ){
741 if( g.url.flags & URL_USE_PARENT ){
742 db_set("parent-project-pw", obscure(g.url.passwd), 0);
743 }else{
744

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button