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.

drh 2011-03-03 01:10 trunk
Commit cc31b463490e99c00a96f2d8c13b33190023080b
2 files changed +1 +13 -1
--- src/clone.c
+++ src/clone.c
@@ -96,10 +96,11 @@
9696
db_multi_exec(
9797
"REPLACE INTO config(name,value)"
9898
" VALUES('server-code', lower(hex(randomblob(20))));"
9999
);
100100
url_enable_proxy(0);
101
+ url_get_password_if_needed();
101102
g.xlinkClusterOnly = 1;
102103
nErr = client_sync(0,0,1,bPrivate,CONFIGSET_ALL,0);
103104
g.xlinkClusterOnly = 0;
104105
verify_cancel();
105106
db_end_transaction(0);
106107
--- 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 @@
369369
** Prompt the user for the password for g.urlUser. Store the result
370370
** in g.urlPasswd.
371371
*/
372372
void url_prompt_for_password(void){
373373
if( isatty(fileno(stdin)) ){
374
- char *zPrompt = mprintf("password for %s: ", g.urlUser);
374
+ char *zPrompt = mprintf("\rpassword for %s: ", g.urlUser);
375375
Blob x;
376376
prompt_for_password(zPrompt, &x, 0);
377377
free(zPrompt);
378378
g.urlPasswd = mprintf("%b", &x);
379379
blob_reset(&x);
@@ -380,5 +380,17 @@
380380
}else{
381381
fossil_fatal("missing or incorrect password for user \"%s\"",
382382
g.urlUser);
383383
}
384384
}
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
+}
385397
--- 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

Keyboard Shortcuts

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