Fossil SCM
When doing a clone with a username, ask for the password early. Do not wait for the first round-trip since that round-trip might take a long time on a slow connection.
Commit
cc31b463490e99c00a96f2d8c13b33190023080b
Parent
139c7e52e2cd812…
2 files changed
+1
+13
-1
+1
| --- src/clone.c | ||
| +++ src/clone.c | ||
| @@ -96,10 +96,11 @@ | ||
| 96 | 96 | db_multi_exec( |
| 97 | 97 | "REPLACE INTO config(name,value)" |
| 98 | 98 | " VALUES('server-code', lower(hex(randomblob(20))));" |
| 99 | 99 | ); |
| 100 | 100 | url_enable_proxy(0); |
| 101 | + url_get_password_if_needed(); | |
| 101 | 102 | g.xlinkClusterOnly = 1; |
| 102 | 103 | nErr = client_sync(0,0,1,bPrivate,CONFIGSET_ALL,0); |
| 103 | 104 | g.xlinkClusterOnly = 0; |
| 104 | 105 | verify_cancel(); |
| 105 | 106 | db_end_transaction(0); |
| 106 | 107 |
| --- src/clone.c | |
| +++ src/clone.c | |
| @@ -96,10 +96,11 @@ | |
| 96 | db_multi_exec( |
| 97 | "REPLACE INTO config(name,value)" |
| 98 | " VALUES('server-code', lower(hex(randomblob(20))));" |
| 99 | ); |
| 100 | url_enable_proxy(0); |
| 101 | g.xlinkClusterOnly = 1; |
| 102 | nErr = client_sync(0,0,1,bPrivate,CONFIGSET_ALL,0); |
| 103 | g.xlinkClusterOnly = 0; |
| 104 | verify_cancel(); |
| 105 | db_end_transaction(0); |
| 106 |
| --- src/clone.c | |
| +++ src/clone.c | |
| @@ -96,10 +96,11 @@ | |
| 96 | db_multi_exec( |
| 97 | "REPLACE INTO config(name,value)" |
| 98 | " VALUES('server-code', lower(hex(randomblob(20))));" |
| 99 | ); |
| 100 | url_enable_proxy(0); |
| 101 | url_get_password_if_needed(); |
| 102 | g.xlinkClusterOnly = 1; |
| 103 | nErr = client_sync(0,0,1,bPrivate,CONFIGSET_ALL,0); |
| 104 | g.xlinkClusterOnly = 0; |
| 105 | verify_cancel(); |
| 106 | db_end_transaction(0); |
| 107 |
+13
-1
| --- src/url.c | ||
| +++ src/url.c | ||
| @@ -369,11 +369,11 @@ | ||
| 369 | 369 | ** Prompt the user for the password for g.urlUser. Store the result |
| 370 | 370 | ** in g.urlPasswd. |
| 371 | 371 | */ |
| 372 | 372 | void url_prompt_for_password(void){ |
| 373 | 373 | if( isatty(fileno(stdin)) ){ |
| 374 | - char *zPrompt = mprintf("password for %s: ", g.urlUser); | |
| 374 | + char *zPrompt = mprintf("\rpassword for %s: ", g.urlUser); | |
| 375 | 375 | Blob x; |
| 376 | 376 | prompt_for_password(zPrompt, &x, 0); |
| 377 | 377 | free(zPrompt); |
| 378 | 378 | g.urlPasswd = mprintf("%b", &x); |
| 379 | 379 | blob_reset(&x); |
| @@ -380,5 +380,17 @@ | ||
| 380 | 380 | }else{ |
| 381 | 381 | fossil_fatal("missing or incorrect password for user \"%s\"", |
| 382 | 382 | g.urlUser); |
| 383 | 383 | } |
| 384 | 384 | } |
| 385 | + | |
| 386 | +/* Preemptively prompt for a password if a username is given in the | |
| 387 | +** URL but no password. | |
| 388 | +*/ | |
| 389 | +void url_get_password_if_needed(void){ | |
| 390 | + if( (g.urlUser && g.urlUser[0]) | |
| 391 | + && (g.urlPasswd==0 || g.urlPasswd[0]==0) | |
| 392 | + && isatty(fileno(stdin)) | |
| 393 | + ){ | |
| 394 | + url_prompt_for_password(); | |
| 395 | + } | |
| 396 | +} | |
| 385 | 397 |
| --- src/url.c | |
| +++ src/url.c | |
| @@ -369,11 +369,11 @@ | |
| 369 | ** Prompt the user for the password for g.urlUser. Store the result |
| 370 | ** in g.urlPasswd. |
| 371 | */ |
| 372 | void url_prompt_for_password(void){ |
| 373 | if( isatty(fileno(stdin)) ){ |
| 374 | char *zPrompt = mprintf("password for %s: ", g.urlUser); |
| 375 | Blob x; |
| 376 | prompt_for_password(zPrompt, &x, 0); |
| 377 | free(zPrompt); |
| 378 | g.urlPasswd = mprintf("%b", &x); |
| 379 | blob_reset(&x); |
| @@ -380,5 +380,17 @@ | |
| 380 | }else{ |
| 381 | fossil_fatal("missing or incorrect password for user \"%s\"", |
| 382 | g.urlUser); |
| 383 | } |
| 384 | } |
| 385 |
| --- src/url.c | |
| +++ src/url.c | |
| @@ -369,11 +369,11 @@ | |
| 369 | ** Prompt the user for the password for g.urlUser. Store the result |
| 370 | ** in g.urlPasswd. |
| 371 | */ |
| 372 | void url_prompt_for_password(void){ |
| 373 | if( isatty(fileno(stdin)) ){ |
| 374 | char *zPrompt = mprintf("\rpassword for %s: ", g.urlUser); |
| 375 | Blob x; |
| 376 | prompt_for_password(zPrompt, &x, 0); |
| 377 | free(zPrompt); |
| 378 | g.urlPasswd = mprintf("%b", &x); |
| 379 | blob_reset(&x); |
| @@ -380,5 +380,17 @@ | |
| 380 | }else{ |
| 381 | fossil_fatal("missing or incorrect password for user \"%s\"", |
| 382 | g.urlUser); |
| 383 | } |
| 384 | } |
| 385 | |
| 386 | /* Preemptively prompt for a password if a username is given in the |
| 387 | ** URL but no password. |
| 388 | */ |
| 389 | void url_get_password_if_needed(void){ |
| 390 | if( (g.urlUser && g.urlUser[0]) |
| 391 | && (g.urlPasswd==0 || g.urlPasswd[0]==0) |
| 392 | && isatty(fileno(stdin)) |
| 393 | ){ |
| 394 | url_prompt_for_password(); |
| 395 | } |
| 396 | } |
| 397 |