Fossil SCM
Added the --save-http-url-password option to the clone command to make it skip the "remember password (Y/n)?" prompt if the password was given in an HTTP URL. We avoid this for ssh:// URLs since you have pre-shared keys, SSH agents, and such to avoid the need in that case. Without this feature, you can't script around it by piping "echo y" through the command because the "remember password" feature as of trunk only works when isatty(0), which will be false when Fossil is downstream from a pipe like that.
Commit
2600b7719f444b8ccfe660687c1840390a2aab85f4fa79e3cd418a4ed78ac4e3
Parent
cdd5e576dddb052…
2 files changed
+5
+1
-1
+5
| --- src/clone.c | ||
| +++ src/clone.c | ||
| @@ -109,10 +109,11 @@ | ||
| 109 | 109 | ** admin user. This can be overridden using the -A|--admin-user |
| 110 | 110 | ** parameter. |
| 111 | 111 | ** |
| 112 | 112 | ** Options: |
| 113 | 113 | ** --admin-user|-A USERNAME Make USERNAME the administrator |
| 114 | +** --save-http-url-password Save password without asking if given via HTTP[S] URL | |
| 114 | 115 | ** --nocompress Omit extra delta compression |
| 115 | 116 | ** --once Don't remember the URI. |
| 116 | 117 | ** --private Also clone private branches |
| 117 | 118 | ** --ssl-identity FILENAME Use the SSL identity if requested by the server |
| 118 | 119 | ** --ssh-command|-c SSH Use SSH as the "ssh" command |
| @@ -132,10 +133,14 @@ | ||
| 132 | 133 | int noCompress = find_option("nocompress",0,0)!=0; |
| 133 | 134 | |
| 134 | 135 | /* Also clone private branches */ |
| 135 | 136 | if( find_option("private",0,0)!=0 ) syncFlags |= SYNC_PRIVATE; |
| 136 | 137 | if( find_option("once",0,0)!=0) urlFlags &= ~URL_REMEMBER; |
| 138 | + if( find_option("save-http-url-password",0,0)!=0 ){ | |
| 139 | + urlFlags &= ~URL_PROMPT_PW; | |
| 140 | + urlFlags |= URL_REMEMBER_PW; | |
| 141 | + } | |
| 137 | 142 | if( find_option("verbose","v",0)!=0) syncFlags |= SYNC_VERBOSE; |
| 138 | 143 | if( find_option("unversioned","u",0)!=0 ) syncFlags |= SYNC_UNVERSIONED; |
| 139 | 144 | zHttpAuth = find_option("httpauth","B",1); |
| 140 | 145 | zDefaultUser = find_option("admin-user","A",1); |
| 141 | 146 | clone_ssh_find_options(); |
| 142 | 147 |
| --- src/clone.c | |
| +++ src/clone.c | |
| @@ -109,10 +109,11 @@ | |
| 109 | ** admin user. This can be overridden using the -A|--admin-user |
| 110 | ** parameter. |
| 111 | ** |
| 112 | ** Options: |
| 113 | ** --admin-user|-A USERNAME Make USERNAME the administrator |
| 114 | ** --nocompress Omit extra delta compression |
| 115 | ** --once Don't remember the URI. |
| 116 | ** --private Also clone private branches |
| 117 | ** --ssl-identity FILENAME Use the SSL identity if requested by the server |
| 118 | ** --ssh-command|-c SSH Use SSH as the "ssh" command |
| @@ -132,10 +133,14 @@ | |
| 132 | int noCompress = find_option("nocompress",0,0)!=0; |
| 133 | |
| 134 | /* Also clone private branches */ |
| 135 | if( find_option("private",0,0)!=0 ) syncFlags |= SYNC_PRIVATE; |
| 136 | if( find_option("once",0,0)!=0) urlFlags &= ~URL_REMEMBER; |
| 137 | if( find_option("verbose","v",0)!=0) syncFlags |= SYNC_VERBOSE; |
| 138 | if( find_option("unversioned","u",0)!=0 ) syncFlags |= SYNC_UNVERSIONED; |
| 139 | zHttpAuth = find_option("httpauth","B",1); |
| 140 | zDefaultUser = find_option("admin-user","A",1); |
| 141 | clone_ssh_find_options(); |
| 142 |
| --- src/clone.c | |
| +++ src/clone.c | |
| @@ -109,10 +109,11 @@ | |
| 109 | ** admin user. This can be overridden using the -A|--admin-user |
| 110 | ** parameter. |
| 111 | ** |
| 112 | ** Options: |
| 113 | ** --admin-user|-A USERNAME Make USERNAME the administrator |
| 114 | ** --save-http-url-password Save password without asking if given via HTTP[S] URL |
| 115 | ** --nocompress Omit extra delta compression |
| 116 | ** --once Don't remember the URI. |
| 117 | ** --private Also clone private branches |
| 118 | ** --ssl-identity FILENAME Use the SSL identity if requested by the server |
| 119 | ** --ssh-command|-c SSH Use SSH as the "ssh" command |
| @@ -132,10 +133,14 @@ | |
| 133 | int noCompress = find_option("nocompress",0,0)!=0; |
| 134 | |
| 135 | /* Also clone private branches */ |
| 136 | if( find_option("private",0,0)!=0 ) syncFlags |= SYNC_PRIVATE; |
| 137 | if( find_option("once",0,0)!=0) urlFlags &= ~URL_REMEMBER; |
| 138 | if( find_option("save-http-url-password",0,0)!=0 ){ |
| 139 | urlFlags &= ~URL_PROMPT_PW; |
| 140 | urlFlags |= URL_REMEMBER_PW; |
| 141 | } |
| 142 | if( find_option("verbose","v",0)!=0) syncFlags |= SYNC_VERBOSE; |
| 143 | if( find_option("unversioned","u",0)!=0 ) syncFlags |= SYNC_UNVERSIONED; |
| 144 | zHttpAuth = find_option("httpauth","B",1); |
| 145 | zDefaultUser = find_option("admin-user","A",1); |
| 146 | clone_ssh_find_options(); |
| 147 |
+1
-1
| --- src/url.c | ||
| +++ src/url.c | ||
| @@ -274,11 +274,11 @@ | ||
| 274 | 274 | pUrlData->canonical = mprintf("file://%T", pUrlData->name); |
| 275 | 275 | blob_reset(&cfile); |
| 276 | 276 | }else if( pUrlData->user!=0 && pUrlData->passwd==0 && (urlFlags & URL_PROMPT_PW) ){ |
| 277 | 277 | url_prompt_for_password_local(pUrlData); |
| 278 | 278 | }else if( pUrlData->user!=0 && ( urlFlags & URL_ASK_REMEMBER_PW ) ){ |
| 279 | - if( isatty(fileno(stdin)) ){ | |
| 279 | + if( isatty(fileno(stdin)) && ( urlFlags & URL_REMEMBER_PW )==0 ){ | |
| 280 | 280 | if( save_password_prompt(pUrlData->passwd) ){ |
| 281 | 281 | pUrlData->flags = urlFlags |= URL_REMEMBER_PW; |
| 282 | 282 | }else{ |
| 283 | 283 | pUrlData->flags = urlFlags &= ~URL_REMEMBER_PW; |
| 284 | 284 | } |
| 285 | 285 |
| --- src/url.c | |
| +++ src/url.c | |
| @@ -274,11 +274,11 @@ | |
| 274 | pUrlData->canonical = mprintf("file://%T", pUrlData->name); |
| 275 | blob_reset(&cfile); |
| 276 | }else if( pUrlData->user!=0 && pUrlData->passwd==0 && (urlFlags & URL_PROMPT_PW) ){ |
| 277 | url_prompt_for_password_local(pUrlData); |
| 278 | }else if( pUrlData->user!=0 && ( urlFlags & URL_ASK_REMEMBER_PW ) ){ |
| 279 | if( isatty(fileno(stdin)) ){ |
| 280 | if( save_password_prompt(pUrlData->passwd) ){ |
| 281 | pUrlData->flags = urlFlags |= URL_REMEMBER_PW; |
| 282 | }else{ |
| 283 | pUrlData->flags = urlFlags &= ~URL_REMEMBER_PW; |
| 284 | } |
| 285 |
| --- src/url.c | |
| +++ src/url.c | |
| @@ -274,11 +274,11 @@ | |
| 274 | pUrlData->canonical = mprintf("file://%T", pUrlData->name); |
| 275 | blob_reset(&cfile); |
| 276 | }else if( pUrlData->user!=0 && pUrlData->passwd==0 && (urlFlags & URL_PROMPT_PW) ){ |
| 277 | url_prompt_for_password_local(pUrlData); |
| 278 | }else if( pUrlData->user!=0 && ( urlFlags & URL_ASK_REMEMBER_PW ) ){ |
| 279 | if( isatty(fileno(stdin)) && ( urlFlags & URL_REMEMBER_PW )==0 ){ |
| 280 | if( save_password_prompt(pUrlData->passwd) ){ |
| 281 | pUrlData->flags = urlFlags |= URL_REMEMBER_PW; |
| 282 | }else{ |
| 283 | pUrlData->flags = urlFlags &= ~URL_REMEMBER_PW; |
| 284 | } |
| 285 |