Fossil SCM

Reimplement the default test-http behavior while retaining the ability to use http to take advantage of Fossil capabilities with SSH URLs.

andybradford 2013-08-09 07:29 ssh-test-http
Commit 7c9347f9c70db96454a70963950012d9ca707955
--- src/clone.c
+++ src/clone.c
@@ -96,10 +96,11 @@
9696
** --private Also clone private branches
9797
** --ssl-identity=filename Use the SSL identity if requested by the server
9898
** --ssh-fossil|-f /fossil Use this path as remote fossil command
9999
** --ssh-command|-c 'command' Use this SSH command
100100
** --ssh-fossil-user|-l user Fossil user to use for SSH if different.
101
+** --ssh-use-http|-h Enable http instead of test-http
101102
**
102103
** See also: init
103104
*/
104105
void clone_cmd(void){
105106
char *zPassword;
@@ -200,10 +201,11 @@
200201
}
201202
zFossilUser = find_option("ssh-fossil-user","l",1);
202203
if( zFossilUser && zFossilUser[0] ){
203204
g.zFossilUser = mprintf("%s", zFossilUser);
204205
}
206
+ g.fSshUseHttp = find_option("ssh-use-http","h",0)!=0;
205207
}
206208
207209
/*
208210
** Set SSH options discovered in global variables (set from command line
209211
** options).
@@ -216,6 +218,9 @@
216218
db_set("ssh-command", g.zSshCmd, 0);
217219
}
218220
if( g.zFossilUser && g.zFossilUser[0] ){
219221
db_set("ssh-fossil-user", g.zFossilUser, 0);
220222
}
223
+ if( g.fSshUseHttp ){
224
+ db_set_int("ssh-use-http", 1, 0);
225
+ }
221226
}
222227
--- src/clone.c
+++ src/clone.c
@@ -96,10 +96,11 @@
96 ** --private Also clone private branches
97 ** --ssl-identity=filename Use the SSL identity if requested by the server
98 ** --ssh-fossil|-f /fossil Use this path as remote fossil command
99 ** --ssh-command|-c 'command' Use this SSH command
100 ** --ssh-fossil-user|-l user Fossil user to use for SSH if different.
 
101 **
102 ** See also: init
103 */
104 void clone_cmd(void){
105 char *zPassword;
@@ -200,10 +201,11 @@
200 }
201 zFossilUser = find_option("ssh-fossil-user","l",1);
202 if( zFossilUser && zFossilUser[0] ){
203 g.zFossilUser = mprintf("%s", zFossilUser);
204 }
 
205 }
206
207 /*
208 ** Set SSH options discovered in global variables (set from command line
209 ** options).
@@ -216,6 +218,9 @@
216 db_set("ssh-command", g.zSshCmd, 0);
217 }
218 if( g.zFossilUser && g.zFossilUser[0] ){
219 db_set("ssh-fossil-user", g.zFossilUser, 0);
220 }
 
 
 
221 }
222
--- src/clone.c
+++ src/clone.c
@@ -96,10 +96,11 @@
96 ** --private Also clone private branches
97 ** --ssl-identity=filename Use the SSL identity if requested by the server
98 ** --ssh-fossil|-f /fossil Use this path as remote fossil command
99 ** --ssh-command|-c 'command' Use this SSH command
100 ** --ssh-fossil-user|-l user Fossil user to use for SSH if different.
101 ** --ssh-use-http|-h Enable http instead of test-http
102 **
103 ** See also: init
104 */
105 void clone_cmd(void){
106 char *zPassword;
@@ -200,10 +201,11 @@
201 }
202 zFossilUser = find_option("ssh-fossil-user","l",1);
203 if( zFossilUser && zFossilUser[0] ){
204 g.zFossilUser = mprintf("%s", zFossilUser);
205 }
206 g.fSshUseHttp = find_option("ssh-use-http","h",0)!=0;
207 }
208
209 /*
210 ** Set SSH options discovered in global variables (set from command line
211 ** options).
@@ -216,6 +218,9 @@
218 db_set("ssh-command", g.zSshCmd, 0);
219 }
220 if( g.zFossilUser && g.zFossilUser[0] ){
221 db_set("ssh-fossil-user", g.zFossilUser, 0);
222 }
223 if( g.fSshUseHttp ){
224 db_set_int("ssh-use-http", 1, 0);
225 }
226 }
227
+3
--- src/db.c
+++ src/db.c
@@ -2136,10 +2136,11 @@
21362136
{ "repo-cksum", 0, 0, 0, "on" },
21372137
{ "self-register", 0, 0, 0, "off" },
21382138
{ "ssh-command", 0, 40, 0, "" },
21392139
{ "ssh-fossil", 0, 40, 0, "" },
21402140
{ "ssh-fossil-user", 0, 40, 0, "" },
2141
+ { "ssh-use-http", 0, 40, 0, "off" },
21412142
{ "ssl-ca-location",0, 40, 0, "" },
21422143
{ "ssl-identity", 0, 40, 0, "" },
21432144
#ifdef FOSSIL_ENABLE_TCL
21442145
{ "tcl", 0, 0, 0, "off" },
21452146
{ "tcl-setup", 0, 40, 0, "" },
@@ -2310,10 +2311,12 @@
23102311
** the "ssh://" protocol.
23112312
**
23122313
** ssh-fossil Remote fossil command to run with the "ssh://" protocol.
23132314
**
23142315
** ssh-fossil-user Fossil user to use instead of the URL user.
2316
+**
2317
+** ssh-use-http Use http instead of test-http. Default: off.
23152318
**
23162319
** ssl-ca-location The full pathname to a file containing PEM encoded
23172320
** CA root certificates, or a directory of certificates
23182321
** with filenames formed from the certificate hashes as
23192322
** required by OpenSSL.
23202323
--- src/db.c
+++ src/db.c
@@ -2136,10 +2136,11 @@
2136 { "repo-cksum", 0, 0, 0, "on" },
2137 { "self-register", 0, 0, 0, "off" },
2138 { "ssh-command", 0, 40, 0, "" },
2139 { "ssh-fossil", 0, 40, 0, "" },
2140 { "ssh-fossil-user", 0, 40, 0, "" },
 
2141 { "ssl-ca-location",0, 40, 0, "" },
2142 { "ssl-identity", 0, 40, 0, "" },
2143 #ifdef FOSSIL_ENABLE_TCL
2144 { "tcl", 0, 0, 0, "off" },
2145 { "tcl-setup", 0, 40, 0, "" },
@@ -2310,10 +2311,12 @@
2310 ** the "ssh://" protocol.
2311 **
2312 ** ssh-fossil Remote fossil command to run with the "ssh://" protocol.
2313 **
2314 ** ssh-fossil-user Fossil user to use instead of the URL user.
 
 
2315 **
2316 ** ssl-ca-location The full pathname to a file containing PEM encoded
2317 ** CA root certificates, or a directory of certificates
2318 ** with filenames formed from the certificate hashes as
2319 ** required by OpenSSL.
2320
--- src/db.c
+++ src/db.c
@@ -2136,10 +2136,11 @@
2136 { "repo-cksum", 0, 0, 0, "on" },
2137 { "self-register", 0, 0, 0, "off" },
2138 { "ssh-command", 0, 40, 0, "" },
2139 { "ssh-fossil", 0, 40, 0, "" },
2140 { "ssh-fossil-user", 0, 40, 0, "" },
2141 { "ssh-use-http", 0, 40, 0, "off" },
2142 { "ssl-ca-location",0, 40, 0, "" },
2143 { "ssl-identity", 0, 40, 0, "" },
2144 #ifdef FOSSIL_ENABLE_TCL
2145 { "tcl", 0, 0, 0, "off" },
2146 { "tcl-setup", 0, 40, 0, "" },
@@ -2310,10 +2311,12 @@
2311 ** the "ssh://" protocol.
2312 **
2313 ** ssh-fossil Remote fossil command to run with the "ssh://" protocol.
2314 **
2315 ** ssh-fossil-user Fossil user to use instead of the URL user.
2316 **
2317 ** ssh-use-http Use http instead of test-http. Default: off.
2318 **
2319 ** ssl-ca-location The full pathname to a file containing PEM encoded
2320 ** CA root certificates, or a directory of certificates
2321 ** with filenames formed from the certificate hashes as
2322 ** required by OpenSSL.
2323
+2 -1
--- src/http.c
+++ src/http.c
@@ -40,11 +40,12 @@
4040
Blob pw; /* The nonce with user password appended */
4141
Blob sig; /* The signature field */
4242
4343
zLogin = url_or_fossil_user();
4444
blob_zero(pLogin);
45
- if( zLogin==0 || fossil_strcmp(g.urlUser, "anonymous")==0 ){
45
+ if( zLogin==0 || fossil_strcmp(g.urlUser, "anonymous")==0 ||
46
+ url_ssh_use_http()==0 ){
4647
return; /* If no login card for users "nobody" and "anonymous" */
4748
}
4849
blob_zero(&nonce);
4950
blob_zero(&pw);
5051
sha1sum_blob(pPayload, &nonce);
5152
--- src/http.c
+++ src/http.c
@@ -40,11 +40,12 @@
40 Blob pw; /* The nonce with user password appended */
41 Blob sig; /* The signature field */
42
43 zLogin = url_or_fossil_user();
44 blob_zero(pLogin);
45 if( zLogin==0 || fossil_strcmp(g.urlUser, "anonymous")==0 ){
 
46 return; /* If no login card for users "nobody" and "anonymous" */
47 }
48 blob_zero(&nonce);
49 blob_zero(&pw);
50 sha1sum_blob(pPayload, &nonce);
51
--- src/http.c
+++ src/http.c
@@ -40,11 +40,12 @@
40 Blob pw; /* The nonce with user password appended */
41 Blob sig; /* The signature field */
42
43 zLogin = url_or_fossil_user();
44 blob_zero(pLogin);
45 if( zLogin==0 || fossil_strcmp(g.urlUser, "anonymous")==0 ||
46 url_ssh_use_http()==0 ){
47 return; /* If no login card for users "nobody" and "anonymous" */
48 }
49 blob_zero(&nonce);
50 blob_zero(&pw);
51 sha1sum_blob(pPayload, &nonce);
52
--- src/http_transport.c
+++ src/http_transport.c
@@ -136,11 +136,15 @@
136136
n = blob_size(&zCmd);
137137
blob_append(&zCmd, " ", 1);
138138
shell_escape(&zCmd, zHost);
139139
blob_append(&zCmd, " ", 1);
140140
shell_escape(&zCmd, mprintf("%s", zSshFossilCmd));
141
- blob_append(&zCmd, " http", 5);
141
+ if( db_get_boolean("ssh-use-http", 0) ){
142
+ blob_append(&zCmd, " http", 5);
143
+ }else{
144
+ blob_append(&zCmd, " test-http", 10);
145
+ }
142146
if( g.urlPath && g.urlPath[0] ){
143147
blob_append(&zCmd, " ", 1);
144148
shell_escape(&zCmd, mprintf("%s", g.urlPath));
145149
}
146150
if( fPrintSshCmd ){
147151
--- src/http_transport.c
+++ src/http_transport.c
@@ -136,11 +136,15 @@
136 n = blob_size(&zCmd);
137 blob_append(&zCmd, " ", 1);
138 shell_escape(&zCmd, zHost);
139 blob_append(&zCmd, " ", 1);
140 shell_escape(&zCmd, mprintf("%s", zSshFossilCmd));
141 blob_append(&zCmd, " http", 5);
 
 
 
 
142 if( g.urlPath && g.urlPath[0] ){
143 blob_append(&zCmd, " ", 1);
144 shell_escape(&zCmd, mprintf("%s", g.urlPath));
145 }
146 if( fPrintSshCmd ){
147
--- src/http_transport.c
+++ src/http_transport.c
@@ -136,11 +136,15 @@
136 n = blob_size(&zCmd);
137 blob_append(&zCmd, " ", 1);
138 shell_escape(&zCmd, zHost);
139 blob_append(&zCmd, " ", 1);
140 shell_escape(&zCmd, mprintf("%s", zSshFossilCmd));
141 if( db_get_boolean("ssh-use-http", 0) ){
142 blob_append(&zCmd, " http", 5);
143 }else{
144 blob_append(&zCmd, " test-http", 10);
145 }
146 if( g.urlPath && g.urlPath[0] ){
147 blob_append(&zCmd, " ", 1);
148 shell_escape(&zCmd, mprintf("%s", g.urlPath));
149 }
150 if( fPrintSshCmd ){
151
+2
--- src/main.c
+++ src/main.c
@@ -134,10 +134,11 @@
134134
int fSqlPrint; /* True if -sqlprint flag is present */
135135
int fQuiet; /* True if -quiet flag is present */
136136
int fHttpTrace; /* Trace outbound HTTP requests */
137137
int fSystemTrace; /* Trace calls to fossil_system(), --systemtrace */
138138
int fSshTrace; /* Trace the SSH setup traffic */
139
+ int fSshUseHttp; /* Use http or test-http mode for SSH */
139140
char *zSshFossilCmd; /* Path to remoe fossil command for SSH */
140141
char *zSshCmd; /* SSH command string */
141142
char *zFossilUser; /* Fossil user if different from URL user */
142143
int fNoSync; /* Do not do an autosync ever. --nosync */
143144
char *zPath; /* Name of webpage being served */
@@ -581,10 +582,11 @@
581582
g.fQuiet = find_option("quiet", 0, 0)!=0;
582583
g.fSqlTrace = find_option("sqltrace", 0, 0)!=0;
583584
g.fSqlStats = find_option("sqlstats", 0, 0)!=0;
584585
g.fSystemTrace = find_option("systemtrace", 0, 0)!=0;
585586
g.fSshTrace = find_option("sshtrace", 0, 0)!=0;
587
+ g.fSshUseHttp = 0;
586588
g.zSshFossilCmd = 0;
587589
g.zSshCmd = 0;
588590
g.zFossilUser = 0;
589591
if( g.fSqlTrace ) g.fSqlStats = 1;
590592
g.fSqlPrint = find_option("sqlprint", 0, 0)!=0;
591593
--- src/main.c
+++ src/main.c
@@ -134,10 +134,11 @@
134 int fSqlPrint; /* True if -sqlprint flag is present */
135 int fQuiet; /* True if -quiet flag is present */
136 int fHttpTrace; /* Trace outbound HTTP requests */
137 int fSystemTrace; /* Trace calls to fossil_system(), --systemtrace */
138 int fSshTrace; /* Trace the SSH setup traffic */
 
139 char *zSshFossilCmd; /* Path to remoe fossil command for SSH */
140 char *zSshCmd; /* SSH command string */
141 char *zFossilUser; /* Fossil user if different from URL user */
142 int fNoSync; /* Do not do an autosync ever. --nosync */
143 char *zPath; /* Name of webpage being served */
@@ -581,10 +582,11 @@
581 g.fQuiet = find_option("quiet", 0, 0)!=0;
582 g.fSqlTrace = find_option("sqltrace", 0, 0)!=0;
583 g.fSqlStats = find_option("sqlstats", 0, 0)!=0;
584 g.fSystemTrace = find_option("systemtrace", 0, 0)!=0;
585 g.fSshTrace = find_option("sshtrace", 0, 0)!=0;
 
586 g.zSshFossilCmd = 0;
587 g.zSshCmd = 0;
588 g.zFossilUser = 0;
589 if( g.fSqlTrace ) g.fSqlStats = 1;
590 g.fSqlPrint = find_option("sqlprint", 0, 0)!=0;
591
--- src/main.c
+++ src/main.c
@@ -134,10 +134,11 @@
134 int fSqlPrint; /* True if -sqlprint flag is present */
135 int fQuiet; /* True if -quiet flag is present */
136 int fHttpTrace; /* Trace outbound HTTP requests */
137 int fSystemTrace; /* Trace calls to fossil_system(), --systemtrace */
138 int fSshTrace; /* Trace the SSH setup traffic */
139 int fSshUseHttp; /* Use http or test-http mode for SSH */
140 char *zSshFossilCmd; /* Path to remoe fossil command for SSH */
141 char *zSshCmd; /* SSH command string */
142 char *zFossilUser; /* Fossil user if different from URL user */
143 int fNoSync; /* Do not do an autosync ever. --nosync */
144 char *zPath; /* Name of webpage being served */
@@ -581,10 +582,11 @@
582 g.fQuiet = find_option("quiet", 0, 0)!=0;
583 g.fSqlTrace = find_option("sqltrace", 0, 0)!=0;
584 g.fSqlStats = find_option("sqlstats", 0, 0)!=0;
585 g.fSystemTrace = find_option("systemtrace", 0, 0)!=0;
586 g.fSshTrace = find_option("sshtrace", 0, 0)!=0;
587 g.fSshUseHttp = 0;
588 g.zSshFossilCmd = 0;
589 g.zSshCmd = 0;
590 g.zFossilUser = 0;
591 if( g.fSqlTrace ) g.fSqlStats = 1;
592 g.fSqlPrint = find_option("sqlprint", 0, 0)!=0;
593
+8 -1
--- src/url.c
+++ src/url.c
@@ -412,11 +412,11 @@
412412
/*
413413
** Prompt the user for the password for g.urlUser. Store the result
414414
** in g.urlPasswd.
415415
*/
416416
void url_prompt_for_password(void){
417
- if( g.urlIsFile ) return;
417
+ if( g.urlIsFile || url_ssh_use_http()==0 ) return;
418418
if( isatty(fileno(stdin))
419419
&& (g.urlFlags & URL_PROMPT_PW)!=0
420420
&& (g.urlFlags & URL_PROMPTED)==0
421421
){
422422
g.urlFlags |= URL_PROMPTED;
@@ -434,10 +434,17 @@
434434
}else{
435435
fossil_fatal("missing or incorrect password for user \"%s\"",
436436
url_or_fossil_user() );
437437
}
438438
}
439
+
440
+/*
441
+** Return true if http mode is in use for "ssh://" URL.
442
+*/
443
+int url_ssh_use_http(void){
444
+ return g.urlIsSsh && ( db_get_boolean("ssh-use-http", 0) || g.fSshUseHttp );
445
+}
439446
440447
/*
441448
** Remember the URL if requested.
442449
*/
443450
void url_remember(void){
444451
--- src/url.c
+++ src/url.c
@@ -412,11 +412,11 @@
412 /*
413 ** Prompt the user for the password for g.urlUser. Store the result
414 ** in g.urlPasswd.
415 */
416 void url_prompt_for_password(void){
417 if( g.urlIsFile ) return;
418 if( isatty(fileno(stdin))
419 && (g.urlFlags & URL_PROMPT_PW)!=0
420 && (g.urlFlags & URL_PROMPTED)==0
421 ){
422 g.urlFlags |= URL_PROMPTED;
@@ -434,10 +434,17 @@
434 }else{
435 fossil_fatal("missing or incorrect password for user \"%s\"",
436 url_or_fossil_user() );
437 }
438 }
 
 
 
 
 
 
 
439
440 /*
441 ** Remember the URL if requested.
442 */
443 void url_remember(void){
444
--- src/url.c
+++ src/url.c
@@ -412,11 +412,11 @@
412 /*
413 ** Prompt the user for the password for g.urlUser. Store the result
414 ** in g.urlPasswd.
415 */
416 void url_prompt_for_password(void){
417 if( g.urlIsFile || url_ssh_use_http()==0 ) return;
418 if( isatty(fileno(stdin))
419 && (g.urlFlags & URL_PROMPT_PW)!=0
420 && (g.urlFlags & URL_PROMPTED)==0
421 ){
422 g.urlFlags |= URL_PROMPTED;
@@ -434,10 +434,17 @@
434 }else{
435 fossil_fatal("missing or incorrect password for user \"%s\"",
436 url_or_fossil_user() );
437 }
438 }
439
440 /*
441 ** Return true if http mode is in use for "ssh://" URL.
442 */
443 int url_ssh_use_http(void){
444 return g.urlIsSsh && ( db_get_boolean("ssh-use-http", 0) || g.fSshUseHttp );
445 }
446
447 /*
448 ** Remember the URL if requested.
449 */
450 void url_remember(void){
451

Keyboard Shortcuts

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