Fossil SCM
For the "fossil ui REMOTE:path" command, initially omit the PATH= prefix but add it in if the initial attempt fails to find a fossil executable.
Commit
ed6495baa68341d271e913f13073f27ba34bbd3269c4e88b8a47671565e41fe6
Parent
151406f34c4632b…
2 files changed
+2
-2
+56
-38
+2
-2
| --- src/http.c | ||
| +++ src/http.c | ||
| @@ -291,13 +291,13 @@ | ||
| 291 | 291 | if( iTruth>=99 ){ |
| 292 | 292 | iTruth = !db_get_boolean(z/*works-like:"x"*/, 0); |
| 293 | 293 | } |
| 294 | 294 | if( iTruth ){ |
| 295 | 295 | ans = 1; |
| 296 | - db_set(z/*works-like:"x"*/, "1", 0); | |
| 296 | + db_set(z/*works-like:"x"*/, "1", 1); | |
| 297 | 297 | }else{ |
| 298 | - db_unset(z/*works-like:"x"*/, 0); | |
| 298 | + db_unset(z/*works-like:"x"*/, 1); | |
| 299 | 299 | } |
| 300 | 300 | } |
| 301 | 301 | fossil_free(z); |
| 302 | 302 | return ans; |
| 303 | 303 | } |
| 304 | 304 |
| --- src/http.c | |
| +++ src/http.c | |
| @@ -291,13 +291,13 @@ | |
| 291 | if( iTruth>=99 ){ |
| 292 | iTruth = !db_get_boolean(z/*works-like:"x"*/, 0); |
| 293 | } |
| 294 | if( iTruth ){ |
| 295 | ans = 1; |
| 296 | db_set(z/*works-like:"x"*/, "1", 0); |
| 297 | }else{ |
| 298 | db_unset(z/*works-like:"x"*/, 0); |
| 299 | } |
| 300 | } |
| 301 | fossil_free(z); |
| 302 | return ans; |
| 303 | } |
| 304 |
| --- src/http.c | |
| +++ src/http.c | |
| @@ -291,13 +291,13 @@ | |
| 291 | if( iTruth>=99 ){ |
| 292 | iTruth = !db_get_boolean(z/*works-like:"x"*/, 0); |
| 293 | } |
| 294 | if( iTruth ){ |
| 295 | ans = 1; |
| 296 | db_set(z/*works-like:"x"*/, "1", 1); |
| 297 | }else{ |
| 298 | db_unset(z/*works-like:"x"*/, 1); |
| 299 | } |
| 300 | } |
| 301 | fossil_free(z); |
| 302 | return ans; |
| 303 | } |
| 304 |
+56
-38
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -3343,50 +3343,68 @@ | ||
| 3343 | 3343 | /* If a USER@HOST:REPO argument is supplied, then use SSH to run |
| 3344 | 3344 | ** "fossil ui --nobrowser" on the remote system and to set up a |
| 3345 | 3345 | ** tunnel from the local machine to the remote. */ |
| 3346 | 3346 | FILE *sshIn; |
| 3347 | 3347 | Blob ssh; |
| 3348 | + int bRunning = 0; /* True when fossil starts up on the remote */ | |
| 3349 | + int isRetry; /* True if on the second attempt */ | |
| 3348 | 3350 | char zLine[1000]; |
| 3351 | + | |
| 3349 | 3352 | blob_init(&ssh, 0, 0); |
| 3350 | - transport_ssh_command(&ssh); | |
| 3351 | - db_close_config(); | |
| 3352 | - blob_appendf(&ssh, | |
| 3353 | - " -t -L 127.0.0.1:%d:127.0.0.1:%d %!$", | |
| 3354 | - iPort, iPort, zRemote | |
| 3355 | - ); | |
| 3356 | - if( zFossilCmd==0 ){ | |
| 3357 | - ssh_add_path_argument(&ssh); | |
| 3358 | - blob_append_escaped_arg(&ssh, "fossil", 1); | |
| 3359 | - }else{ | |
| 3360 | - blob_appendf(&ssh, " %$", zFossilCmd); | |
| 3361 | - } | |
| 3362 | - blob_appendf(&ssh, " ui --nobrowser --localauth --port %d", iPort); | |
| 3363 | - if( zNotFound ) blob_appendf(&ssh, " --notfound %!$", zNotFound); | |
| 3364 | - if( zFileGlob ) blob_appendf(&ssh, " --files-urlenc %T", zFileGlob); | |
| 3365 | - if( g.zCkoutAlias ) blob_appendf(&ssh, " --ckout-alias %!$",g.zCkoutAlias); | |
| 3366 | - if( g.zExtRoot ) blob_appendf(&ssh, " --extroot %$", g.zExtRoot); | |
| 3367 | - if( skin_in_use() ) blob_appendf(&ssh, " --skin %s", skin_in_use()); | |
| 3368 | - if( zJsMode ) blob_appendf(&ssh, " --jsmode %s", zJsMode); | |
| 3369 | - if( fCreate ) blob_appendf(&ssh, " --create"); | |
| 3370 | - blob_appendf(&ssh, " %$", g.argv[2]); | |
| 3371 | - fossil_print("%s\n", blob_str(&ssh)); | |
| 3372 | - sshIn = popen(blob_str(&ssh), "r"); | |
| 3373 | - if( sshIn==0 ){ | |
| 3374 | - fossil_fatal("unable to %s", blob_str(&ssh)); | |
| 3375 | - } | |
| 3376 | - while( fgets(zLine, sizeof(zLine), sshIn) ){ | |
| 3377 | - fputs(zLine, stdout); | |
| 3378 | - fflush(stdout); | |
| 3379 | - if( zBrowserCmd && sqlite3_strglob("*Listening for HTTP*",zLine)==0 ){ | |
| 3380 | - char *zCmd = mprintf(zBrowserCmd/*works-like:"%d"*/,iPort); | |
| 3381 | - fossil_system(zCmd); | |
| 3382 | - fossil_free(zCmd); | |
| 3383 | - fossil_free(zBrowserCmd); | |
| 3384 | - zBrowserCmd = 0; | |
| 3385 | - } | |
| 3386 | - } | |
| 3387 | - pclose(sshIn); | |
| 3353 | + for(isRetry=0; isRetry<2 && !bRunning; isRetry++){ | |
| 3354 | + blob_reset(&ssh); | |
| 3355 | + transport_ssh_command(&ssh); | |
| 3356 | + blob_appendf(&ssh, | |
| 3357 | + " -t -L 127.0.0.1:%d:127.0.0.1:%d %!$", | |
| 3358 | + iPort, iPort, zRemote | |
| 3359 | + ); | |
| 3360 | + if( zFossilCmd==0 ){ | |
| 3361 | + if( ssh_needs_path_argument(zRemote,-1) ^ isRetry ){ | |
| 3362 | + ssh_add_path_argument(&ssh); | |
| 3363 | + } | |
| 3364 | + blob_append_escaped_arg(&ssh, "fossil", 1); | |
| 3365 | + }else{ | |
| 3366 | + blob_appendf(&ssh, " %$", zFossilCmd); | |
| 3367 | + } | |
| 3368 | + blob_appendf(&ssh, " ui --nobrowser --localauth --port %d", iPort); | |
| 3369 | + if( zNotFound ) blob_appendf(&ssh, " --notfound %!$", zNotFound); | |
| 3370 | + if( zFileGlob ) blob_appendf(&ssh, " --files-urlenc %T", zFileGlob); | |
| 3371 | + if( g.zCkoutAlias ) blob_appendf(&ssh," --ckout-alias %!$",g.zCkoutAlias); | |
| 3372 | + if( g.zExtRoot ) blob_appendf(&ssh, " --extroot %$", g.zExtRoot); | |
| 3373 | + if( skin_in_use() ) blob_appendf(&ssh, " --skin %s", skin_in_use()); | |
| 3374 | + if( zJsMode ) blob_appendf(&ssh, " --jsmode %s", zJsMode); | |
| 3375 | + if( fCreate ) blob_appendf(&ssh, " --create"); | |
| 3376 | + blob_appendf(&ssh, " %$", g.argv[2]); | |
| 3377 | + if( isRetry ){ | |
| 3378 | + fossil_print("First attempt to run \"fossil\" on %s failed\n" | |
| 3379 | + "Retry: ", zRemote); | |
| 3380 | + } | |
| 3381 | + fossil_print("%s\n", blob_str(&ssh)); | |
| 3382 | + sshIn = popen(blob_str(&ssh), "r"); | |
| 3383 | + if( sshIn==0 ){ | |
| 3384 | + fossil_fatal("unable to %s", blob_str(&ssh)); | |
| 3385 | + } | |
| 3386 | + while( fgets(zLine, sizeof(zLine), sshIn) ){ | |
| 3387 | + fputs(zLine, stdout); | |
| 3388 | + fflush(stdout); | |
| 3389 | + if( !bRunning && sqlite3_strglob("*Listening for HTTP*",zLine)==0 ){ | |
| 3390 | + bRunning = 1; | |
| 3391 | + if( isRetry ){ | |
| 3392 | + ssh_needs_path_argument(zRemote,99); | |
| 3393 | + } | |
| 3394 | + db_close_config(); | |
| 3395 | + if( zBrowserCmd ){ | |
| 3396 | + char *zCmd = mprintf(zBrowserCmd/*works-like:"%d"*/,iPort); | |
| 3397 | + fossil_system(zCmd); | |
| 3398 | + fossil_free(zCmd); | |
| 3399 | + fossil_free(zBrowserCmd); | |
| 3400 | + zBrowserCmd = 0; | |
| 3401 | + } | |
| 3402 | + } | |
| 3403 | + } | |
| 3404 | + pclose(sshIn); | |
| 3405 | + } | |
| 3388 | 3406 | fossil_free(zBrowserCmd); |
| 3389 | 3407 | return; |
| 3390 | 3408 | } |
| 3391 | 3409 | if( g.repositoryOpen ) flags |= HTTP_SERVER_HAD_REPOSITORY; |
| 3392 | 3410 | if( g.localOpen ) flags |= HTTP_SERVER_HAD_CHECKOUT; |
| 3393 | 3411 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -3343,50 +3343,68 @@ | |
| 3343 | /* If a USER@HOST:REPO argument is supplied, then use SSH to run |
| 3344 | ** "fossil ui --nobrowser" on the remote system and to set up a |
| 3345 | ** tunnel from the local machine to the remote. */ |
| 3346 | FILE *sshIn; |
| 3347 | Blob ssh; |
| 3348 | char zLine[1000]; |
| 3349 | blob_init(&ssh, 0, 0); |
| 3350 | transport_ssh_command(&ssh); |
| 3351 | db_close_config(); |
| 3352 | blob_appendf(&ssh, |
| 3353 | " -t -L 127.0.0.1:%d:127.0.0.1:%d %!$", |
| 3354 | iPort, iPort, zRemote |
| 3355 | ); |
| 3356 | if( zFossilCmd==0 ){ |
| 3357 | ssh_add_path_argument(&ssh); |
| 3358 | blob_append_escaped_arg(&ssh, "fossil", 1); |
| 3359 | }else{ |
| 3360 | blob_appendf(&ssh, " %$", zFossilCmd); |
| 3361 | } |
| 3362 | blob_appendf(&ssh, " ui --nobrowser --localauth --port %d", iPort); |
| 3363 | if( zNotFound ) blob_appendf(&ssh, " --notfound %!$", zNotFound); |
| 3364 | if( zFileGlob ) blob_appendf(&ssh, " --files-urlenc %T", zFileGlob); |
| 3365 | if( g.zCkoutAlias ) blob_appendf(&ssh, " --ckout-alias %!$",g.zCkoutAlias); |
| 3366 | if( g.zExtRoot ) blob_appendf(&ssh, " --extroot %$", g.zExtRoot); |
| 3367 | if( skin_in_use() ) blob_appendf(&ssh, " --skin %s", skin_in_use()); |
| 3368 | if( zJsMode ) blob_appendf(&ssh, " --jsmode %s", zJsMode); |
| 3369 | if( fCreate ) blob_appendf(&ssh, " --create"); |
| 3370 | blob_appendf(&ssh, " %$", g.argv[2]); |
| 3371 | fossil_print("%s\n", blob_str(&ssh)); |
| 3372 | sshIn = popen(blob_str(&ssh), "r"); |
| 3373 | if( sshIn==0 ){ |
| 3374 | fossil_fatal("unable to %s", blob_str(&ssh)); |
| 3375 | } |
| 3376 | while( fgets(zLine, sizeof(zLine), sshIn) ){ |
| 3377 | fputs(zLine, stdout); |
| 3378 | fflush(stdout); |
| 3379 | if( zBrowserCmd && sqlite3_strglob("*Listening for HTTP*",zLine)==0 ){ |
| 3380 | char *zCmd = mprintf(zBrowserCmd/*works-like:"%d"*/,iPort); |
| 3381 | fossil_system(zCmd); |
| 3382 | fossil_free(zCmd); |
| 3383 | fossil_free(zBrowserCmd); |
| 3384 | zBrowserCmd = 0; |
| 3385 | } |
| 3386 | } |
| 3387 | pclose(sshIn); |
| 3388 | fossil_free(zBrowserCmd); |
| 3389 | return; |
| 3390 | } |
| 3391 | if( g.repositoryOpen ) flags |= HTTP_SERVER_HAD_REPOSITORY; |
| 3392 | if( g.localOpen ) flags |= HTTP_SERVER_HAD_CHECKOUT; |
| 3393 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -3343,50 +3343,68 @@ | |
| 3343 | /* If a USER@HOST:REPO argument is supplied, then use SSH to run |
| 3344 | ** "fossil ui --nobrowser" on the remote system and to set up a |
| 3345 | ** tunnel from the local machine to the remote. */ |
| 3346 | FILE *sshIn; |
| 3347 | Blob ssh; |
| 3348 | int bRunning = 0; /* True when fossil starts up on the remote */ |
| 3349 | int isRetry; /* True if on the second attempt */ |
| 3350 | char zLine[1000]; |
| 3351 | |
| 3352 | blob_init(&ssh, 0, 0); |
| 3353 | for(isRetry=0; isRetry<2 && !bRunning; isRetry++){ |
| 3354 | blob_reset(&ssh); |
| 3355 | transport_ssh_command(&ssh); |
| 3356 | blob_appendf(&ssh, |
| 3357 | " -t -L 127.0.0.1:%d:127.0.0.1:%d %!$", |
| 3358 | iPort, iPort, zRemote |
| 3359 | ); |
| 3360 | if( zFossilCmd==0 ){ |
| 3361 | if( ssh_needs_path_argument(zRemote,-1) ^ isRetry ){ |
| 3362 | ssh_add_path_argument(&ssh); |
| 3363 | } |
| 3364 | blob_append_escaped_arg(&ssh, "fossil", 1); |
| 3365 | }else{ |
| 3366 | blob_appendf(&ssh, " %$", zFossilCmd); |
| 3367 | } |
| 3368 | blob_appendf(&ssh, " ui --nobrowser --localauth --port %d", iPort); |
| 3369 | if( zNotFound ) blob_appendf(&ssh, " --notfound %!$", zNotFound); |
| 3370 | if( zFileGlob ) blob_appendf(&ssh, " --files-urlenc %T", zFileGlob); |
| 3371 | if( g.zCkoutAlias ) blob_appendf(&ssh," --ckout-alias %!$",g.zCkoutAlias); |
| 3372 | if( g.zExtRoot ) blob_appendf(&ssh, " --extroot %$", g.zExtRoot); |
| 3373 | if( skin_in_use() ) blob_appendf(&ssh, " --skin %s", skin_in_use()); |
| 3374 | if( zJsMode ) blob_appendf(&ssh, " --jsmode %s", zJsMode); |
| 3375 | if( fCreate ) blob_appendf(&ssh, " --create"); |
| 3376 | blob_appendf(&ssh, " %$", g.argv[2]); |
| 3377 | if( isRetry ){ |
| 3378 | fossil_print("First attempt to run \"fossil\" on %s failed\n" |
| 3379 | "Retry: ", zRemote); |
| 3380 | } |
| 3381 | fossil_print("%s\n", blob_str(&ssh)); |
| 3382 | sshIn = popen(blob_str(&ssh), "r"); |
| 3383 | if( sshIn==0 ){ |
| 3384 | fossil_fatal("unable to %s", blob_str(&ssh)); |
| 3385 | } |
| 3386 | while( fgets(zLine, sizeof(zLine), sshIn) ){ |
| 3387 | fputs(zLine, stdout); |
| 3388 | fflush(stdout); |
| 3389 | if( !bRunning && sqlite3_strglob("*Listening for HTTP*",zLine)==0 ){ |
| 3390 | bRunning = 1; |
| 3391 | if( isRetry ){ |
| 3392 | ssh_needs_path_argument(zRemote,99); |
| 3393 | } |
| 3394 | db_close_config(); |
| 3395 | if( zBrowserCmd ){ |
| 3396 | char *zCmd = mprintf(zBrowserCmd/*works-like:"%d"*/,iPort); |
| 3397 | fossil_system(zCmd); |
| 3398 | fossil_free(zCmd); |
| 3399 | fossil_free(zBrowserCmd); |
| 3400 | zBrowserCmd = 0; |
| 3401 | } |
| 3402 | } |
| 3403 | } |
| 3404 | pclose(sshIn); |
| 3405 | } |
| 3406 | fossil_free(zBrowserCmd); |
| 3407 | return; |
| 3408 | } |
| 3409 | if( g.repositoryOpen ) flags |= HTTP_SERVER_HAD_REPOSITORY; |
| 3410 | if( g.localOpen ) flags |= HTTP_SERVER_HAD_CHECKOUT; |
| 3411 |