Fossil SCM
Move the SSH shared account code back to the branch to keep the development of this new feature separate.
Commit
56169d0775ca4bb46179df0b834881ec4fffeb12
Parent
ef8b9da03f05103…
7 files changed
+3
-3
+2
-12
-3
+1
-3
+1
+1
-2
+30
-5
+3
-3
| --- src/cgi.c | ||
| +++ src/cgi.c | ||
| @@ -460,15 +460,15 @@ | ||
| 460 | 460 | */ |
| 461 | 461 | void cgi_replace_parameter(const char *zName, const char *zValue){ |
| 462 | 462 | int i; |
| 463 | 463 | for(i=0; i<nUsedQP; i++){ |
| 464 | 464 | if( fossil_strcmp(aParamQP[i].zName,zName)==0 ){ |
| 465 | - aParamQP[i].zValue = mprintf("%s",zValue); | |
| 465 | + aParamQP[i].zValue = zValue; | |
| 466 | 466 | return; |
| 467 | 467 | } |
| 468 | 468 | } |
| 469 | - cgi_set_parameter_nocopy(zName, mprintf("%s",zValue), 0); | |
| 469 | + cgi_set_parameter_nocopy(zName, zValue, 0); | |
| 470 | 470 | } |
| 471 | 471 | |
| 472 | 472 | /* |
| 473 | 473 | ** Add a query parameter. The zName portion is fixed but a copy |
| 474 | 474 | ** must be made of zValue. |
| @@ -1391,11 +1391,11 @@ | ||
| 1391 | 1391 | for(i=0; zToken[i] && zToken[i]!='?'; i++){} |
| 1392 | 1392 | if( zToken[i] ) zToken[i++] = 0; |
| 1393 | 1393 | if( nCycles==0 ){ |
| 1394 | 1394 | cgi_setenv("PATH_INFO", zToken); |
| 1395 | 1395 | }else{ |
| 1396 | - cgi_replace_parameter("PATH_INFO", zToken); | |
| 1396 | + cgi_replace_parameter("PATH_INFO", mprintf("%s",zToken)); | |
| 1397 | 1397 | } |
| 1398 | 1398 | |
| 1399 | 1399 | /* Get all the optional fields that follow the first line. |
| 1400 | 1400 | */ |
| 1401 | 1401 | while( fgets(zLine,sizeof(zLine),g.httpIn) ){ |
| 1402 | 1402 |
| --- src/cgi.c | |
| +++ src/cgi.c | |
| @@ -460,15 +460,15 @@ | |
| 460 | */ |
| 461 | void cgi_replace_parameter(const char *zName, const char *zValue){ |
| 462 | int i; |
| 463 | for(i=0; i<nUsedQP; i++){ |
| 464 | if( fossil_strcmp(aParamQP[i].zName,zName)==0 ){ |
| 465 | aParamQP[i].zValue = mprintf("%s",zValue); |
| 466 | return; |
| 467 | } |
| 468 | } |
| 469 | cgi_set_parameter_nocopy(zName, mprintf("%s",zValue), 0); |
| 470 | } |
| 471 | |
| 472 | /* |
| 473 | ** Add a query parameter. The zName portion is fixed but a copy |
| 474 | ** must be made of zValue. |
| @@ -1391,11 +1391,11 @@ | |
| 1391 | for(i=0; zToken[i] && zToken[i]!='?'; i++){} |
| 1392 | if( zToken[i] ) zToken[i++] = 0; |
| 1393 | if( nCycles==0 ){ |
| 1394 | cgi_setenv("PATH_INFO", zToken); |
| 1395 | }else{ |
| 1396 | cgi_replace_parameter("PATH_INFO", zToken); |
| 1397 | } |
| 1398 | |
| 1399 | /* Get all the optional fields that follow the first line. |
| 1400 | */ |
| 1401 | while( fgets(zLine,sizeof(zLine),g.httpIn) ){ |
| 1402 |
| --- src/cgi.c | |
| +++ src/cgi.c | |
| @@ -460,15 +460,15 @@ | |
| 460 | */ |
| 461 | void cgi_replace_parameter(const char *zName, const char *zValue){ |
| 462 | int i; |
| 463 | for(i=0; i<nUsedQP; i++){ |
| 464 | if( fossil_strcmp(aParamQP[i].zName,zName)==0 ){ |
| 465 | aParamQP[i].zValue = zValue; |
| 466 | return; |
| 467 | } |
| 468 | } |
| 469 | cgi_set_parameter_nocopy(zName, zValue, 0); |
| 470 | } |
| 471 | |
| 472 | /* |
| 473 | ** Add a query parameter. The zName portion is fixed but a copy |
| 474 | ** must be made of zValue. |
| @@ -1391,11 +1391,11 @@ | |
| 1391 | for(i=0; zToken[i] && zToken[i]!='?'; i++){} |
| 1392 | if( zToken[i] ) zToken[i++] = 0; |
| 1393 | if( nCycles==0 ){ |
| 1394 | cgi_setenv("PATH_INFO", zToken); |
| 1395 | }else{ |
| 1396 | cgi_replace_parameter("PATH_INFO", mprintf("%s",zToken)); |
| 1397 | } |
| 1398 | |
| 1399 | /* Get all the optional fields that follow the first line. |
| 1400 | */ |
| 1401 | while( fgets(zLine,sizeof(zLine),g.httpIn) ){ |
| 1402 |
+2
-12
| --- src/clone.c | ||
| +++ src/clone.c | ||
| @@ -90,29 +90,27 @@ | ||
| 90 | 90 | ** URL must be in one of the following form: ([...] mean optional) |
| 91 | 91 | ** HTTP/HTTPS protocol: |
| 92 | 92 | ** http[s]://[userid[:password]@]host[:port][/path] |
| 93 | 93 | ** |
| 94 | 94 | ** SSH protocol: |
| 95 | -** ssh://[userid[:password]@]host[:port]/path/to/repo.fossil | |
| 95 | +** ssh://[userid[:password]@]host[:port]/path/to/repo.fossil\\ | |
| 96 | +** [?fossil=path/to/fossil.exe] | |
| 96 | 97 | ** |
| 97 | 98 | ** Filesystem: |
| 98 | 99 | ** [file://]path/to/repo.fossil |
| 99 | 100 | ** |
| 100 | 101 | ** Note: For ssh and filesystem, path must have an extra leading |
| 101 | 102 | ** '/' to use an absolute path. |
| 102 | 103 | ** |
| 103 | -** Note: the userid for SSH is the SSH account, not the Fossil account. | |
| 104 | -** | |
| 105 | 104 | ** By default, your current login name is used to create the default |
| 106 | 105 | ** admin user. This can be overridden using the -A|--admin-user |
| 107 | 106 | ** parameter. |
| 108 | 107 | ** |
| 109 | 108 | ** Options: |
| 110 | 109 | ** --admin-user|-A USERNAME Make USERNAME the administrator |
| 111 | 110 | ** --private Also clone private branches |
| 112 | 111 | ** --ssl-identity=filename Use the SSL identity if requested by the server |
| 113 | -** --ssh-fossil|-f /fossil Use this path as remote fossil command | |
| 114 | 112 | ** --ssh-command|-c 'command' Use this SSH command |
| 115 | 113 | ** --ssh-fossil-user|-l user Fossil user to use for SSH if different. |
| 116 | 114 | ** |
| 117 | 115 | ** See also: init |
| 118 | 116 | */ |
| @@ -199,18 +197,13 @@ | ||
| 199 | 197 | |
| 200 | 198 | /* |
| 201 | 199 | ** Look for SSH clone command line options and setup in globals. |
| 202 | 200 | */ |
| 203 | 201 | void clone_ssh_find_options(void){ |
| 204 | - const char *zSshFossilCmd; /* Path to remote fossil command for SSH */ | |
| 205 | 202 | const char *zSshCmd; /* SSH command string */ |
| 206 | 203 | const char *zFossilUser; /* Fossil user if login specified for SSH */ |
| 207 | 204 | |
| 208 | - zSshFossilCmd = find_option("ssh-fossil","f",1); | |
| 209 | - if( zSshFossilCmd && zSshFossilCmd[0] ){ | |
| 210 | - g.zSshFossilCmd = mprintf("%s", zSshFossilCmd); | |
| 211 | - } | |
| 212 | 205 | zSshCmd = find_option("ssh-command","c",1); |
| 213 | 206 | if( zSshCmd && zSshCmd[0] ){ |
| 214 | 207 | g.zSshCmd = mprintf("%s", zSshCmd); |
| 215 | 208 | } |
| 216 | 209 | zFossilUser = find_option("ssh-fossil-user","l",1); |
| @@ -222,15 +215,12 @@ | ||
| 222 | 215 | /* |
| 223 | 216 | ** Set SSH options discovered in global variables (set from command line |
| 224 | 217 | ** options). |
| 225 | 218 | */ |
| 226 | 219 | void clone_ssh_db_set_options(void){ |
| 227 | - if( g.zSshFossilCmd && g.zSshFossilCmd[0] ){ | |
| 228 | - db_set("ssh-fossil", g.zSshFossilCmd, 0); | |
| 229 | - } | |
| 230 | 220 | if( g.zSshCmd && g.zSshCmd[0] ){ |
| 231 | 221 | db_set("ssh-command", g.zSshCmd, 0); |
| 232 | 222 | } |
| 233 | 223 | if( g.zFossilUser && g.zFossilUser[0] ){ |
| 234 | 224 | db_set("ssh-fossil-user", g.zFossilUser, 0); |
| 235 | 225 | } |
| 236 | 226 | } |
| 237 | 227 |
| --- src/clone.c | |
| +++ src/clone.c | |
| @@ -90,29 +90,27 @@ | |
| 90 | ** URL must be in one of the following form: ([...] mean optional) |
| 91 | ** HTTP/HTTPS protocol: |
| 92 | ** http[s]://[userid[:password]@]host[:port][/path] |
| 93 | ** |
| 94 | ** SSH protocol: |
| 95 | ** ssh://[userid[:password]@]host[:port]/path/to/repo.fossil |
| 96 | ** |
| 97 | ** Filesystem: |
| 98 | ** [file://]path/to/repo.fossil |
| 99 | ** |
| 100 | ** Note: For ssh and filesystem, path must have an extra leading |
| 101 | ** '/' to use an absolute path. |
| 102 | ** |
| 103 | ** Note: the userid for SSH is the SSH account, not the Fossil account. |
| 104 | ** |
| 105 | ** By default, your current login name is used to create the default |
| 106 | ** admin user. This can be overridden using the -A|--admin-user |
| 107 | ** parameter. |
| 108 | ** |
| 109 | ** Options: |
| 110 | ** --admin-user|-A USERNAME Make USERNAME the administrator |
| 111 | ** --private Also clone private branches |
| 112 | ** --ssl-identity=filename Use the SSL identity if requested by the server |
| 113 | ** --ssh-fossil|-f /fossil Use this path as remote fossil command |
| 114 | ** --ssh-command|-c 'command' Use this SSH command |
| 115 | ** --ssh-fossil-user|-l user Fossil user to use for SSH if different. |
| 116 | ** |
| 117 | ** See also: init |
| 118 | */ |
| @@ -199,18 +197,13 @@ | |
| 199 | |
| 200 | /* |
| 201 | ** Look for SSH clone command line options and setup in globals. |
| 202 | */ |
| 203 | void clone_ssh_find_options(void){ |
| 204 | const char *zSshFossilCmd; /* Path to remote fossil command for SSH */ |
| 205 | const char *zSshCmd; /* SSH command string */ |
| 206 | const char *zFossilUser; /* Fossil user if login specified for SSH */ |
| 207 | |
| 208 | zSshFossilCmd = find_option("ssh-fossil","f",1); |
| 209 | if( zSshFossilCmd && zSshFossilCmd[0] ){ |
| 210 | g.zSshFossilCmd = mprintf("%s", zSshFossilCmd); |
| 211 | } |
| 212 | zSshCmd = find_option("ssh-command","c",1); |
| 213 | if( zSshCmd && zSshCmd[0] ){ |
| 214 | g.zSshCmd = mprintf("%s", zSshCmd); |
| 215 | } |
| 216 | zFossilUser = find_option("ssh-fossil-user","l",1); |
| @@ -222,15 +215,12 @@ | |
| 222 | /* |
| 223 | ** Set SSH options discovered in global variables (set from command line |
| 224 | ** options). |
| 225 | */ |
| 226 | void clone_ssh_db_set_options(void){ |
| 227 | if( g.zSshFossilCmd && g.zSshFossilCmd[0] ){ |
| 228 | db_set("ssh-fossil", g.zSshFossilCmd, 0); |
| 229 | } |
| 230 | if( g.zSshCmd && g.zSshCmd[0] ){ |
| 231 | db_set("ssh-command", g.zSshCmd, 0); |
| 232 | } |
| 233 | if( g.zFossilUser && g.zFossilUser[0] ){ |
| 234 | db_set("ssh-fossil-user", g.zFossilUser, 0); |
| 235 | } |
| 236 | } |
| 237 |
| --- src/clone.c | |
| +++ src/clone.c | |
| @@ -90,29 +90,27 @@ | |
| 90 | ** URL must be in one of the following form: ([...] mean optional) |
| 91 | ** HTTP/HTTPS protocol: |
| 92 | ** http[s]://[userid[:password]@]host[:port][/path] |
| 93 | ** |
| 94 | ** SSH protocol: |
| 95 | ** ssh://[userid[:password]@]host[:port]/path/to/repo.fossil\\ |
| 96 | ** [?fossil=path/to/fossil.exe] |
| 97 | ** |
| 98 | ** Filesystem: |
| 99 | ** [file://]path/to/repo.fossil |
| 100 | ** |
| 101 | ** Note: For ssh and filesystem, path must have an extra leading |
| 102 | ** '/' to use an absolute path. |
| 103 | ** |
| 104 | ** By default, your current login name is used to create the default |
| 105 | ** admin user. This can be overridden using the -A|--admin-user |
| 106 | ** parameter. |
| 107 | ** |
| 108 | ** Options: |
| 109 | ** --admin-user|-A USERNAME Make USERNAME the administrator |
| 110 | ** --private Also clone private branches |
| 111 | ** --ssl-identity=filename Use the SSL identity if requested by the server |
| 112 | ** --ssh-command|-c 'command' Use this SSH command |
| 113 | ** --ssh-fossil-user|-l user Fossil user to use for SSH if different. |
| 114 | ** |
| 115 | ** See also: init |
| 116 | */ |
| @@ -199,18 +197,13 @@ | |
| 197 | |
| 198 | /* |
| 199 | ** Look for SSH clone command line options and setup in globals. |
| 200 | */ |
| 201 | void clone_ssh_find_options(void){ |
| 202 | const char *zSshCmd; /* SSH command string */ |
| 203 | const char *zFossilUser; /* Fossil user if login specified for SSH */ |
| 204 | |
| 205 | zSshCmd = find_option("ssh-command","c",1); |
| 206 | if( zSshCmd && zSshCmd[0] ){ |
| 207 | g.zSshCmd = mprintf("%s", zSshCmd); |
| 208 | } |
| 209 | zFossilUser = find_option("ssh-fossil-user","l",1); |
| @@ -222,15 +215,12 @@ | |
| 215 | /* |
| 216 | ** Set SSH options discovered in global variables (set from command line |
| 217 | ** options). |
| 218 | */ |
| 219 | void clone_ssh_db_set_options(void){ |
| 220 | if( g.zSshCmd && g.zSshCmd[0] ){ |
| 221 | db_set("ssh-command", g.zSshCmd, 0); |
| 222 | } |
| 223 | if( g.zFossilUser && g.zFossilUser[0] ){ |
| 224 | db_set("ssh-fossil-user", g.zFossilUser, 0); |
| 225 | } |
| 226 | } |
| 227 |
M
src/db.c
-3
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -2136,11 +2136,10 @@ | ||
| 2136 | 2136 | { "proxy", 0, 32, 0, "off" }, |
| 2137 | 2137 | { "relative-paths",0, 0, 0, "on" }, |
| 2138 | 2138 | { "repo-cksum", 0, 0, 0, "on" }, |
| 2139 | 2139 | { "self-register", 0, 0, 0, "off" }, |
| 2140 | 2140 | { "ssh-command", 0, 40, 0, "" }, |
| 2141 | - { "ssh-fossil", 0, 40, 0, "" }, | |
| 2142 | 2141 | { "ssl-ca-location",0, 40, 0, "" }, |
| 2143 | 2142 | { "ssl-identity", 0, 40, 0, "" }, |
| 2144 | 2143 | #ifdef FOSSIL_ENABLE_TCL |
| 2145 | 2144 | { "tcl", 0, 0, 0, "off" }, |
| 2146 | 2145 | { "tcl-setup", 0, 40, 0, "" }, |
| @@ -2308,12 +2307,10 @@ | ||
| 2308 | 2307 | ** users can not be deleted. Default: off. |
| 2309 | 2308 | ** |
| 2310 | 2309 | ** ssh-command Command used to talk to a remote machine with |
| 2311 | 2310 | ** the "ssh://" protocol. |
| 2312 | 2311 | ** |
| 2313 | -** ssh-fossil Remote fossil command to run with the "ssh://" protocol. | |
| 2314 | -** | |
| 2315 | 2312 | ** ssl-ca-location The full pathname to a file containing PEM encoded |
| 2316 | 2313 | ** CA root certificates, or a directory of certificates |
| 2317 | 2314 | ** with filenames formed from the certificate hashes as |
| 2318 | 2315 | ** required by OpenSSL. |
| 2319 | 2316 | ** If set, this will override the OS default list of |
| 2320 | 2317 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -2136,11 +2136,10 @@ | |
| 2136 | { "proxy", 0, 32, 0, "off" }, |
| 2137 | { "relative-paths",0, 0, 0, "on" }, |
| 2138 | { "repo-cksum", 0, 0, 0, "on" }, |
| 2139 | { "self-register", 0, 0, 0, "off" }, |
| 2140 | { "ssh-command", 0, 40, 0, "" }, |
| 2141 | { "ssh-fossil", 0, 40, 0, "" }, |
| 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, "" }, |
| @@ -2308,12 +2307,10 @@ | |
| 2308 | ** users can not be deleted. Default: off. |
| 2309 | ** |
| 2310 | ** ssh-command Command used to talk to a remote machine with |
| 2311 | ** the "ssh://" protocol. |
| 2312 | ** |
| 2313 | ** ssh-fossil Remote fossil command to run with the "ssh://" protocol. |
| 2314 | ** |
| 2315 | ** ssl-ca-location The full pathname to a file containing PEM encoded |
| 2316 | ** CA root certificates, or a directory of certificates |
| 2317 | ** with filenames formed from the certificate hashes as |
| 2318 | ** required by OpenSSL. |
| 2319 | ** If set, this will override the OS default list of |
| 2320 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -2136,11 +2136,10 @@ | |
| 2136 | { "proxy", 0, 32, 0, "off" }, |
| 2137 | { "relative-paths",0, 0, 0, "on" }, |
| 2138 | { "repo-cksum", 0, 0, 0, "on" }, |
| 2139 | { "self-register", 0, 0, 0, "off" }, |
| 2140 | { "ssh-command", 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, "" }, |
| @@ -2308,12 +2307,10 @@ | |
| 2307 | ** users can not be deleted. Default: off. |
| 2308 | ** |
| 2309 | ** ssh-command Command used to talk to a remote machine with |
| 2310 | ** the "ssh://" protocol. |
| 2311 | ** |
| 2312 | ** ssl-ca-location The full pathname to a file containing PEM encoded |
| 2313 | ** CA root certificates, or a directory of certificates |
| 2314 | ** with filenames formed from the certificate hashes as |
| 2315 | ** required by OpenSSL. |
| 2316 | ** If set, this will override the OS default list of |
| 2317 |
+1
-3
| --- src/http_transport.c | ||
| +++ src/http_transport.c | ||
| @@ -91,19 +91,17 @@ | ||
| 91 | 91 | int transport_ssh_open(void){ |
| 92 | 92 | /* For SSH we need to create and run SSH fossil http |
| 93 | 93 | ** to talk to the remote machine. |
| 94 | 94 | */ |
| 95 | 95 | static int fPrintSshCmd = 1; /* Print SSH command only once */ |
| 96 | - const char *zSshFossilCmd; /* Path to fossil on remote host */ | |
| 97 | 96 | const char *zSsh; /* The base SSH command */ |
| 98 | 97 | Blob zCmd; /* The SSH command */ |
| 99 | 98 | char *zHost; /* The host name to contact */ |
| 100 | 99 | int n; /* Size of prefix string */ |
| 101 | 100 | |
| 102 | 101 | socket_ssh_resolve_addr(); |
| 103 | 102 | zSsh = db_get("ssh-command", zDefaultSshCmd); |
| 104 | - zSshFossilCmd = db_get("ssh-fossil", "fossil"); | |
| 105 | 103 | blob_init(&zCmd, zSsh, -1); |
| 106 | 104 | if( g.urlPort!=g.urlDfltPort && g.urlPort ){ |
| 107 | 105 | #ifdef __MINGW32__ |
| 108 | 106 | blob_appendf(&zCmd, " -P %d", g.urlPort); |
| 109 | 107 | #else |
| @@ -121,11 +119,11 @@ | ||
| 121 | 119 | } |
| 122 | 120 | n = blob_size(&zCmd); |
| 123 | 121 | blob_append(&zCmd, " ", 1); |
| 124 | 122 | shell_escape(&zCmd, zHost); |
| 125 | 123 | blob_append(&zCmd, " ", 1); |
| 126 | - shell_escape(&zCmd, mprintf("%s", zSshFossilCmd)); | |
| 124 | + shell_escape(&zCmd, mprintf("%s", g.urlFossil)); | |
| 127 | 125 | if( url_ssh_use_http() ){ |
| 128 | 126 | blob_append(&zCmd, " http", 5); |
| 129 | 127 | }else{ |
| 130 | 128 | blob_append(&zCmd, " test-http", 10); |
| 131 | 129 | } |
| 132 | 130 |
| --- src/http_transport.c | |
| +++ src/http_transport.c | |
| @@ -91,19 +91,17 @@ | |
| 91 | int transport_ssh_open(void){ |
| 92 | /* For SSH we need to create and run SSH fossil http |
| 93 | ** to talk to the remote machine. |
| 94 | */ |
| 95 | static int fPrintSshCmd = 1; /* Print SSH command only once */ |
| 96 | const char *zSshFossilCmd; /* Path to fossil on remote host */ |
| 97 | const char *zSsh; /* The base SSH command */ |
| 98 | Blob zCmd; /* The SSH command */ |
| 99 | char *zHost; /* The host name to contact */ |
| 100 | int n; /* Size of prefix string */ |
| 101 | |
| 102 | socket_ssh_resolve_addr(); |
| 103 | zSsh = db_get("ssh-command", zDefaultSshCmd); |
| 104 | zSshFossilCmd = db_get("ssh-fossil", "fossil"); |
| 105 | blob_init(&zCmd, zSsh, -1); |
| 106 | if( g.urlPort!=g.urlDfltPort && g.urlPort ){ |
| 107 | #ifdef __MINGW32__ |
| 108 | blob_appendf(&zCmd, " -P %d", g.urlPort); |
| 109 | #else |
| @@ -121,11 +119,11 @@ | |
| 121 | } |
| 122 | n = blob_size(&zCmd); |
| 123 | blob_append(&zCmd, " ", 1); |
| 124 | shell_escape(&zCmd, zHost); |
| 125 | blob_append(&zCmd, " ", 1); |
| 126 | shell_escape(&zCmd, mprintf("%s", zSshFossilCmd)); |
| 127 | if( url_ssh_use_http() ){ |
| 128 | blob_append(&zCmd, " http", 5); |
| 129 | }else{ |
| 130 | blob_append(&zCmd, " test-http", 10); |
| 131 | } |
| 132 |
| --- src/http_transport.c | |
| +++ src/http_transport.c | |
| @@ -91,19 +91,17 @@ | |
| 91 | int transport_ssh_open(void){ |
| 92 | /* For SSH we need to create and run SSH fossil http |
| 93 | ** to talk to the remote machine. |
| 94 | */ |
| 95 | static int fPrintSshCmd = 1; /* Print SSH command only once */ |
| 96 | const char *zSsh; /* The base SSH command */ |
| 97 | Blob zCmd; /* The SSH command */ |
| 98 | char *zHost; /* The host name to contact */ |
| 99 | int n; /* Size of prefix string */ |
| 100 | |
| 101 | socket_ssh_resolve_addr(); |
| 102 | zSsh = db_get("ssh-command", zDefaultSshCmd); |
| 103 | blob_init(&zCmd, zSsh, -1); |
| 104 | if( g.urlPort!=g.urlDfltPort && g.urlPort ){ |
| 105 | #ifdef __MINGW32__ |
| 106 | blob_appendf(&zCmd, " -P %d", g.urlPort); |
| 107 | #else |
| @@ -121,11 +119,11 @@ | |
| 119 | } |
| 120 | n = blob_size(&zCmd); |
| 121 | blob_append(&zCmd, " ", 1); |
| 122 | shell_escape(&zCmd, zHost); |
| 123 | blob_append(&zCmd, " ", 1); |
| 124 | shell_escape(&zCmd, mprintf("%s", g.urlFossil)); |
| 125 | if( url_ssh_use_http() ){ |
| 126 | blob_append(&zCmd, " http", 5); |
| 127 | }else{ |
| 128 | blob_append(&zCmd, " test-http", 10); |
| 129 | } |
| 130 |
+1
| --- src/json.c | ||
| +++ src/json.c | ||
| @@ -1307,10 +1307,11 @@ | ||
| 1307 | 1307 | CSTR(g, urlPath); |
| 1308 | 1308 | CSTR(g, urlUser); |
| 1309 | 1309 | CSTR(g, urlPasswd); |
| 1310 | 1310 | CSTR(g, urlCanonical); |
| 1311 | 1311 | CSTR(g, urlProxyAuth); |
| 1312 | + CSTR(g, urlFossil); | |
| 1312 | 1313 | CSTR(g, zLogin); |
| 1313 | 1314 | CSTR(g, zSSLIdentity); |
| 1314 | 1315 | CSTR(g, zIpAddr); |
| 1315 | 1316 | CSTR(g, zNonce); |
| 1316 | 1317 | CSTR(g, zCsrfToken); |
| 1317 | 1318 |
| --- src/json.c | |
| +++ src/json.c | |
| @@ -1307,10 +1307,11 @@ | |
| 1307 | CSTR(g, urlPath); |
| 1308 | CSTR(g, urlUser); |
| 1309 | CSTR(g, urlPasswd); |
| 1310 | CSTR(g, urlCanonical); |
| 1311 | CSTR(g, urlProxyAuth); |
| 1312 | CSTR(g, zLogin); |
| 1313 | CSTR(g, zSSLIdentity); |
| 1314 | CSTR(g, zIpAddr); |
| 1315 | CSTR(g, zNonce); |
| 1316 | CSTR(g, zCsrfToken); |
| 1317 |
| --- src/json.c | |
| +++ src/json.c | |
| @@ -1307,10 +1307,11 @@ | |
| 1307 | CSTR(g, urlPath); |
| 1308 | CSTR(g, urlUser); |
| 1309 | CSTR(g, urlPasswd); |
| 1310 | CSTR(g, urlCanonical); |
| 1311 | CSTR(g, urlProxyAuth); |
| 1312 | CSTR(g, urlFossil); |
| 1313 | CSTR(g, zLogin); |
| 1314 | CSTR(g, zSSLIdentity); |
| 1315 | CSTR(g, zIpAddr); |
| 1316 | CSTR(g, zNonce); |
| 1317 | CSTR(g, zCsrfToken); |
| 1318 |
+1
-2
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -136,11 +136,10 @@ | ||
| 136 | 136 | int fQuiet; /* True if -quiet flag is present */ |
| 137 | 137 | int fHttpTrace; /* Trace outbound HTTP requests */ |
| 138 | 138 | int fSystemTrace; /* Trace calls to fossil_system(), --systemtrace */ |
| 139 | 139 | int fSshTrace; /* Trace the SSH setup traffic */ |
| 140 | 140 | int fSshClient; /* HTTP client flags for SSH client */ |
| 141 | - char *zSshFossilCmd; /* Path to remoe fossil command for SSH */ | |
| 142 | 141 | char *zSshCmd; /* SSH command string */ |
| 143 | 142 | char *zFossilUser; /* Fossil user if different from URL user */ |
| 144 | 143 | int fNoSync; /* Do not do an autosync ever. --nosync */ |
| 145 | 144 | char *zPath; /* Name of webpage being served */ |
| 146 | 145 | char *zExtra; /* Extra path information past the webpage name */ |
| @@ -179,10 +178,11 @@ | ||
| 179 | 178 | char *urlPath; /* Pathname for http: */ |
| 180 | 179 | char *urlUser; /* User id for http: */ |
| 181 | 180 | char *urlPasswd; /* Password for http: */ |
| 182 | 181 | char *urlCanonical; /* Canonical representation of the URL */ |
| 183 | 182 | char *urlProxyAuth; /* Proxy-Authorizer: string */ |
| 183 | + char *urlFossil; /* The fossil query parameter on ssh: */ | |
| 184 | 184 | unsigned urlFlags; /* Boolean flags controlling URL processing */ |
| 185 | 185 | |
| 186 | 186 | const char *zLogin; /* Login name. "" if not logged in. */ |
| 187 | 187 | const char *zSSLIdentity; /* Value of --ssl-identity option, filename of |
| 188 | 188 | ** SSL client identity */ |
| @@ -585,11 +585,10 @@ | ||
| 585 | 585 | g.fSqlTrace = find_option("sqltrace", 0, 0)!=0; |
| 586 | 586 | g.fSqlStats = find_option("sqlstats", 0, 0)!=0; |
| 587 | 587 | g.fSystemTrace = find_option("systemtrace", 0, 0)!=0; |
| 588 | 588 | g.fSshTrace = find_option("sshtrace", 0, 0)!=0; |
| 589 | 589 | g.fSshClient = 0; |
| 590 | - g.zSshFossilCmd = 0; | |
| 591 | 590 | g.zSshCmd = 0; |
| 592 | 591 | g.zFossilUser = 0; |
| 593 | 592 | if( g.fSqlTrace ) g.fSqlStats = 1; |
| 594 | 593 | g.fSqlPrint = find_option("sqlprint", 0, 0)!=0; |
| 595 | 594 | g.fHttpTrace = find_option("httptrace", 0, 0)!=0; |
| 596 | 595 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -136,11 +136,10 @@ | |
| 136 | int fQuiet; /* True if -quiet flag is present */ |
| 137 | int fHttpTrace; /* Trace outbound HTTP requests */ |
| 138 | int fSystemTrace; /* Trace calls to fossil_system(), --systemtrace */ |
| 139 | int fSshTrace; /* Trace the SSH setup traffic */ |
| 140 | int fSshClient; /* HTTP client flags for SSH client */ |
| 141 | char *zSshFossilCmd; /* Path to remoe fossil command for SSH */ |
| 142 | char *zSshCmd; /* SSH command string */ |
| 143 | char *zFossilUser; /* Fossil user if different from URL user */ |
| 144 | int fNoSync; /* Do not do an autosync ever. --nosync */ |
| 145 | char *zPath; /* Name of webpage being served */ |
| 146 | char *zExtra; /* Extra path information past the webpage name */ |
| @@ -179,10 +178,11 @@ | |
| 179 | char *urlPath; /* Pathname for http: */ |
| 180 | char *urlUser; /* User id for http: */ |
| 181 | char *urlPasswd; /* Password for http: */ |
| 182 | char *urlCanonical; /* Canonical representation of the URL */ |
| 183 | char *urlProxyAuth; /* Proxy-Authorizer: string */ |
| 184 | unsigned urlFlags; /* Boolean flags controlling URL processing */ |
| 185 | |
| 186 | const char *zLogin; /* Login name. "" if not logged in. */ |
| 187 | const char *zSSLIdentity; /* Value of --ssl-identity option, filename of |
| 188 | ** SSL client identity */ |
| @@ -585,11 +585,10 @@ | |
| 585 | g.fSqlTrace = find_option("sqltrace", 0, 0)!=0; |
| 586 | g.fSqlStats = find_option("sqlstats", 0, 0)!=0; |
| 587 | g.fSystemTrace = find_option("systemtrace", 0, 0)!=0; |
| 588 | g.fSshTrace = find_option("sshtrace", 0, 0)!=0; |
| 589 | g.fSshClient = 0; |
| 590 | g.zSshFossilCmd = 0; |
| 591 | g.zSshCmd = 0; |
| 592 | g.zFossilUser = 0; |
| 593 | if( g.fSqlTrace ) g.fSqlStats = 1; |
| 594 | g.fSqlPrint = find_option("sqlprint", 0, 0)!=0; |
| 595 | g.fHttpTrace = find_option("httptrace", 0, 0)!=0; |
| 596 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -136,11 +136,10 @@ | |
| 136 | int fQuiet; /* True if -quiet flag is present */ |
| 137 | int fHttpTrace; /* Trace outbound HTTP requests */ |
| 138 | int fSystemTrace; /* Trace calls to fossil_system(), --systemtrace */ |
| 139 | int fSshTrace; /* Trace the SSH setup traffic */ |
| 140 | int fSshClient; /* HTTP client flags for SSH client */ |
| 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 */ |
| 145 | char *zExtra; /* Extra path information past the webpage name */ |
| @@ -179,10 +178,11 @@ | |
| 178 | char *urlPath; /* Pathname for http: */ |
| 179 | char *urlUser; /* User id for http: */ |
| 180 | char *urlPasswd; /* Password for http: */ |
| 181 | char *urlCanonical; /* Canonical representation of the URL */ |
| 182 | char *urlProxyAuth; /* Proxy-Authorizer: string */ |
| 183 | char *urlFossil; /* The fossil query parameter on ssh: */ |
| 184 | unsigned urlFlags; /* Boolean flags controlling URL processing */ |
| 185 | |
| 186 | const char *zLogin; /* Login name. "" if not logged in. */ |
| 187 | const char *zSSLIdentity; /* Value of --ssl-identity option, filename of |
| 188 | ** SSL client identity */ |
| @@ -585,11 +585,10 @@ | |
| 585 | g.fSqlTrace = find_option("sqltrace", 0, 0)!=0; |
| 586 | g.fSqlStats = find_option("sqlstats", 0, 0)!=0; |
| 587 | g.fSystemTrace = find_option("systemtrace", 0, 0)!=0; |
| 588 | g.fSshTrace = find_option("sshtrace", 0, 0)!=0; |
| 589 | g.fSshClient = 0; |
| 590 | g.zSshCmd = 0; |
| 591 | g.zFossilUser = 0; |
| 592 | if( g.fSqlTrace ) g.fSqlStats = 1; |
| 593 | g.fSqlPrint = find_option("sqlprint", 0, 0)!=0; |
| 594 | g.fHttpTrace = find_option("httptrace", 0, 0)!=0; |
| 595 |
+30
-5
| --- src/url.c | ||
| +++ src/url.c | ||
| @@ -64,11 +64,11 @@ | ||
| 64 | 64 | ** |
| 65 | 65 | ** http://userid:password@host:port/path |
| 66 | 66 | ** |
| 67 | 67 | ** SSH url format is: |
| 68 | 68 | ** |
| 69 | -** ssh://userid:password@host:port/path | |
| 69 | +** ssh://userid:password@host:port/path?fossil=path/to/fossil.exe | |
| 70 | 70 | ** |
| 71 | 71 | */ |
| 72 | 72 | void url_parse(const char *zUrl, unsigned int urlFlags){ |
| 73 | 73 | int i, j, c; |
| 74 | 74 | char *zFile = 0; |
| @@ -107,10 +107,11 @@ | ||
| 107 | 107 | iStart = 8; |
| 108 | 108 | }else if( zUrl[0]=='s' ){ |
| 109 | 109 | g.urlIsSsh = 1; |
| 110 | 110 | g.urlProtocol = "ssh"; |
| 111 | 111 | g.urlDfltPort = 22; |
| 112 | + g.urlFossil = "fossil"; | |
| 112 | 113 | iStart = 6; |
| 113 | 114 | }else{ |
| 114 | 115 | g.urlIsHttps = 0; |
| 115 | 116 | g.urlProtocol = "http"; |
| 116 | 117 | g.urlDfltPort = 80; |
| @@ -157,21 +158,44 @@ | ||
| 157 | 158 | for(i=0; g.urlPath[i] && g.urlPath[i]!='?'; i++){} |
| 158 | 159 | if( g.urlPath[i] ){ |
| 159 | 160 | g.urlPath[i] = 0; |
| 160 | 161 | i++; |
| 161 | 162 | } |
| 163 | + zExe = mprintf(""); | |
| 164 | + while( g.urlPath[i]!=0 ){ | |
| 165 | + char *zName, *zValue; | |
| 166 | + zName = &g.urlPath[i]; | |
| 167 | + zValue = zName; | |
| 168 | + while( g.urlPath[i] && g.urlPath[i]!='=' ){ i++; } | |
| 169 | + if( g.urlPath[i]=='=' ){ | |
| 170 | + g.urlPath[i] = 0; | |
| 171 | + i++; | |
| 172 | + zValue = &g.urlPath[i]; | |
| 173 | + while( g.urlPath[i] && g.urlPath[i]!='&' ){ i++; } | |
| 174 | + } | |
| 175 | + if( g.urlPath[i] ){ | |
| 176 | + g.urlPath[i] = 0; | |
| 177 | + i++; | |
| 178 | + } | |
| 179 | + if( fossil_strcmp(zName,"fossil")==0 ){ | |
| 180 | + g.urlFossil = zValue; | |
| 181 | + dehttpize(g.urlFossil); | |
| 182 | + zExe = mprintf("%cfossil=%T", cQuerySep, g.urlFossil); | |
| 183 | + cQuerySep = '&'; | |
| 184 | + } | |
| 185 | + } | |
| 162 | 186 | |
| 163 | 187 | dehttpize(g.urlPath); |
| 164 | 188 | if( g.urlDfltPort==g.urlPort ){ |
| 165 | 189 | g.urlCanonical = mprintf( |
| 166 | - "%s://%s%T%T", | |
| 167 | - g.urlProtocol, zLogin, g.urlName, g.urlPath | |
| 190 | + "%s://%s%T%T%s", | |
| 191 | + g.urlProtocol, zLogin, g.urlName, g.urlPath, zExe | |
| 168 | 192 | ); |
| 169 | 193 | }else{ |
| 170 | 194 | g.urlCanonical = mprintf( |
| 171 | - "%s://%s%T:%d%T", | |
| 172 | - g.urlProtocol, zLogin, g.urlName, g.urlPort, g.urlPath | |
| 195 | + "%s://%s%T:%d%T%s", | |
| 196 | + g.urlProtocol, zLogin, g.urlName, g.urlPort, g.urlPath, zExe | |
| 173 | 197 | ); |
| 174 | 198 | } |
| 175 | 199 | if( g.urlIsSsh && g.urlPath[1] ) g.urlPath++; |
| 176 | 200 | free(zLogin); |
| 177 | 201 | }else if( strncmp(zUrl, "file:", 5)==0 ){ |
| @@ -254,10 +278,11 @@ | ||
| 254 | 278 | fossil_print("g.urlHostname = %s\n", g.urlHostname); |
| 255 | 279 | fossil_print("g.urlPath = %s\n", g.urlPath); |
| 256 | 280 | fossil_print("g.urlUser = %s\n", g.urlUser); |
| 257 | 281 | fossil_print("g.urlPasswd = %s\n", g.urlPasswd); |
| 258 | 282 | fossil_print("g.urlCanonical = %s\n", g.urlCanonical); |
| 283 | + fossil_print("g.urlFossil = %s\n", g.urlFossil); | |
| 259 | 284 | fossil_print("g.urlFlags = 0x%02x\n", g.urlFlags); |
| 260 | 285 | if( g.urlIsFile || g.urlIsSsh ) break; |
| 261 | 286 | if( i==0 ){ |
| 262 | 287 | fossil_print("********\n"); |
| 263 | 288 | url_enable_proxy("Using proxy: "); |
| 264 | 289 |
| --- src/url.c | |
| +++ src/url.c | |
| @@ -64,11 +64,11 @@ | |
| 64 | ** |
| 65 | ** http://userid:password@host:port/path |
| 66 | ** |
| 67 | ** SSH url format is: |
| 68 | ** |
| 69 | ** ssh://userid:password@host:port/path |
| 70 | ** |
| 71 | */ |
| 72 | void url_parse(const char *zUrl, unsigned int urlFlags){ |
| 73 | int i, j, c; |
| 74 | char *zFile = 0; |
| @@ -107,10 +107,11 @@ | |
| 107 | iStart = 8; |
| 108 | }else if( zUrl[0]=='s' ){ |
| 109 | g.urlIsSsh = 1; |
| 110 | g.urlProtocol = "ssh"; |
| 111 | g.urlDfltPort = 22; |
| 112 | iStart = 6; |
| 113 | }else{ |
| 114 | g.urlIsHttps = 0; |
| 115 | g.urlProtocol = "http"; |
| 116 | g.urlDfltPort = 80; |
| @@ -157,21 +158,44 @@ | |
| 157 | for(i=0; g.urlPath[i] && g.urlPath[i]!='?'; i++){} |
| 158 | if( g.urlPath[i] ){ |
| 159 | g.urlPath[i] = 0; |
| 160 | i++; |
| 161 | } |
| 162 | |
| 163 | dehttpize(g.urlPath); |
| 164 | if( g.urlDfltPort==g.urlPort ){ |
| 165 | g.urlCanonical = mprintf( |
| 166 | "%s://%s%T%T", |
| 167 | g.urlProtocol, zLogin, g.urlName, g.urlPath |
| 168 | ); |
| 169 | }else{ |
| 170 | g.urlCanonical = mprintf( |
| 171 | "%s://%s%T:%d%T", |
| 172 | g.urlProtocol, zLogin, g.urlName, g.urlPort, g.urlPath |
| 173 | ); |
| 174 | } |
| 175 | if( g.urlIsSsh && g.urlPath[1] ) g.urlPath++; |
| 176 | free(zLogin); |
| 177 | }else if( strncmp(zUrl, "file:", 5)==0 ){ |
| @@ -254,10 +278,11 @@ | |
| 254 | fossil_print("g.urlHostname = %s\n", g.urlHostname); |
| 255 | fossil_print("g.urlPath = %s\n", g.urlPath); |
| 256 | fossil_print("g.urlUser = %s\n", g.urlUser); |
| 257 | fossil_print("g.urlPasswd = %s\n", g.urlPasswd); |
| 258 | fossil_print("g.urlCanonical = %s\n", g.urlCanonical); |
| 259 | fossil_print("g.urlFlags = 0x%02x\n", g.urlFlags); |
| 260 | if( g.urlIsFile || g.urlIsSsh ) break; |
| 261 | if( i==0 ){ |
| 262 | fossil_print("********\n"); |
| 263 | url_enable_proxy("Using proxy: "); |
| 264 |
| --- src/url.c | |
| +++ src/url.c | |
| @@ -64,11 +64,11 @@ | |
| 64 | ** |
| 65 | ** http://userid:password@host:port/path |
| 66 | ** |
| 67 | ** SSH url format is: |
| 68 | ** |
| 69 | ** ssh://userid:password@host:port/path?fossil=path/to/fossil.exe |
| 70 | ** |
| 71 | */ |
| 72 | void url_parse(const char *zUrl, unsigned int urlFlags){ |
| 73 | int i, j, c; |
| 74 | char *zFile = 0; |
| @@ -107,10 +107,11 @@ | |
| 107 | iStart = 8; |
| 108 | }else if( zUrl[0]=='s' ){ |
| 109 | g.urlIsSsh = 1; |
| 110 | g.urlProtocol = "ssh"; |
| 111 | g.urlDfltPort = 22; |
| 112 | g.urlFossil = "fossil"; |
| 113 | iStart = 6; |
| 114 | }else{ |
| 115 | g.urlIsHttps = 0; |
| 116 | g.urlProtocol = "http"; |
| 117 | g.urlDfltPort = 80; |
| @@ -157,21 +158,44 @@ | |
| 158 | for(i=0; g.urlPath[i] && g.urlPath[i]!='?'; i++){} |
| 159 | if( g.urlPath[i] ){ |
| 160 | g.urlPath[i] = 0; |
| 161 | i++; |
| 162 | } |
| 163 | zExe = mprintf(""); |
| 164 | while( g.urlPath[i]!=0 ){ |
| 165 | char *zName, *zValue; |
| 166 | zName = &g.urlPath[i]; |
| 167 | zValue = zName; |
| 168 | while( g.urlPath[i] && g.urlPath[i]!='=' ){ i++; } |
| 169 | if( g.urlPath[i]=='=' ){ |
| 170 | g.urlPath[i] = 0; |
| 171 | i++; |
| 172 | zValue = &g.urlPath[i]; |
| 173 | while( g.urlPath[i] && g.urlPath[i]!='&' ){ i++; } |
| 174 | } |
| 175 | if( g.urlPath[i] ){ |
| 176 | g.urlPath[i] = 0; |
| 177 | i++; |
| 178 | } |
| 179 | if( fossil_strcmp(zName,"fossil")==0 ){ |
| 180 | g.urlFossil = zValue; |
| 181 | dehttpize(g.urlFossil); |
| 182 | zExe = mprintf("%cfossil=%T", cQuerySep, g.urlFossil); |
| 183 | cQuerySep = '&'; |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | dehttpize(g.urlPath); |
| 188 | if( g.urlDfltPort==g.urlPort ){ |
| 189 | g.urlCanonical = mprintf( |
| 190 | "%s://%s%T%T%s", |
| 191 | g.urlProtocol, zLogin, g.urlName, g.urlPath, zExe |
| 192 | ); |
| 193 | }else{ |
| 194 | g.urlCanonical = mprintf( |
| 195 | "%s://%s%T:%d%T%s", |
| 196 | g.urlProtocol, zLogin, g.urlName, g.urlPort, g.urlPath, zExe |
| 197 | ); |
| 198 | } |
| 199 | if( g.urlIsSsh && g.urlPath[1] ) g.urlPath++; |
| 200 | free(zLogin); |
| 201 | }else if( strncmp(zUrl, "file:", 5)==0 ){ |
| @@ -254,10 +278,11 @@ | |
| 278 | fossil_print("g.urlHostname = %s\n", g.urlHostname); |
| 279 | fossil_print("g.urlPath = %s\n", g.urlPath); |
| 280 | fossil_print("g.urlUser = %s\n", g.urlUser); |
| 281 | fossil_print("g.urlPasswd = %s\n", g.urlPasswd); |
| 282 | fossil_print("g.urlCanonical = %s\n", g.urlCanonical); |
| 283 | fossil_print("g.urlFossil = %s\n", g.urlFossil); |
| 284 | fossil_print("g.urlFlags = 0x%02x\n", g.urlFlags); |
| 285 | if( g.urlIsFile || g.urlIsSsh ) break; |
| 286 | if( i==0 ){ |
| 287 | fossil_print("********\n"); |
| 288 | url_enable_proxy("Using proxy: "); |
| 289 |