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.

wyoung 2019-06-28 07:23 trunk
Commit 2600b7719f444b8ccfe660687c1840390a2aab85f4fa79e3cd418a4ed78ac4e3
2 files changed +5 +1 -1
--- src/clone.c
+++ src/clone.c
@@ -109,10 +109,11 @@
109109
** admin user. This can be overridden using the -A|--admin-user
110110
** parameter.
111111
**
112112
** Options:
113113
** --admin-user|-A USERNAME Make USERNAME the administrator
114
+** --save-http-url-password Save password without asking if given via HTTP[S] URL
114115
** --nocompress Omit extra delta compression
115116
** --once Don't remember the URI.
116117
** --private Also clone private branches
117118
** --ssl-identity FILENAME Use the SSL identity if requested by the server
118119
** --ssh-command|-c SSH Use SSH as the "ssh" command
@@ -132,10 +133,14 @@
132133
int noCompress = find_option("nocompress",0,0)!=0;
133134
134135
/* Also clone private branches */
135136
if( find_option("private",0,0)!=0 ) syncFlags |= SYNC_PRIVATE;
136137
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
+ }
137142
if( find_option("verbose","v",0)!=0) syncFlags |= SYNC_VERBOSE;
138143
if( find_option("unversioned","u",0)!=0 ) syncFlags |= SYNC_UNVERSIONED;
139144
zHttpAuth = find_option("httpauth","B",1);
140145
zDefaultUser = find_option("admin-user","A",1);
141146
clone_ssh_find_options();
142147
--- 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 @@
274274
pUrlData->canonical = mprintf("file://%T", pUrlData->name);
275275
blob_reset(&cfile);
276276
}else if( pUrlData->user!=0 && pUrlData->passwd==0 && (urlFlags & URL_PROMPT_PW) ){
277277
url_prompt_for_password_local(pUrlData);
278278
}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 ){
280280
if( save_password_prompt(pUrlData->passwd) ){
281281
pUrlData->flags = urlFlags |= URL_REMEMBER_PW;
282282
}else{
283283
pUrlData->flags = urlFlags &= ~URL_REMEMBER_PW;
284284
}
285285
--- 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

Keyboard Shortcuts

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