Fossil SCM
Alternative approach to allow multiple SSH users to share the same SSH account while maintaining separate Fossil identities.
Commit
e3510cef2310bbfc9e759f20cf0f5bea06e93ccc
Parent
087cae847dbf0c7…
10 files changed
+1
+13
-1
+3
+8
-5
-19
+2
+2
-1
+6
-15
+38
-1
+1
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -1352,10 +1352,11 @@ | ||
| 1352 | 1352 | } |
| 1353 | 1353 | } |
| 1354 | 1354 | sCiInfo.zDateOvrd = find_option("date-override",0,1); |
| 1355 | 1355 | sCiInfo.zUserOvrd = find_option("user-override",0,1); |
| 1356 | 1356 | db_must_be_within_tree(); |
| 1357 | + clone_ssh_db_options(); | |
| 1357 | 1358 | noSign = db_get_boolean("omitsign", 0)|noSign; |
| 1358 | 1359 | if( db_get_boolean("clearsign", 0)==0 ){ noSign = 1; } |
| 1359 | 1360 | useCksum = db_get_boolean("repo-cksum", 1); |
| 1360 | 1361 | outputManifest = db_get_boolean("manifest", 0); |
| 1361 | 1362 | verify_all_options(); |
| 1362 | 1363 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -1352,10 +1352,11 @@ | |
| 1352 | } |
| 1353 | } |
| 1354 | sCiInfo.zDateOvrd = find_option("date-override",0,1); |
| 1355 | sCiInfo.zUserOvrd = find_option("user-override",0,1); |
| 1356 | db_must_be_within_tree(); |
| 1357 | noSign = db_get_boolean("omitsign", 0)|noSign; |
| 1358 | if( db_get_boolean("clearsign", 0)==0 ){ noSign = 1; } |
| 1359 | useCksum = db_get_boolean("repo-cksum", 1); |
| 1360 | outputManifest = db_get_boolean("manifest", 0); |
| 1361 | verify_all_options(); |
| 1362 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -1352,10 +1352,11 @@ | |
| 1352 | } |
| 1353 | } |
| 1354 | sCiInfo.zDateOvrd = find_option("date-override",0,1); |
| 1355 | sCiInfo.zUserOvrd = find_option("user-override",0,1); |
| 1356 | db_must_be_within_tree(); |
| 1357 | clone_ssh_db_options(); |
| 1358 | noSign = db_get_boolean("omitsign", 0)|noSign; |
| 1359 | if( db_get_boolean("clearsign", 0)==0 ){ noSign = 1; } |
| 1360 | useCksum = db_get_boolean("repo-cksum", 1); |
| 1361 | outputManifest = db_get_boolean("manifest", 0); |
| 1362 | verify_all_options(); |
| 1363 |
+13
-1
| --- src/clone.c | ||
| +++ src/clone.c | ||
| @@ -95,10 +95,11 @@ | ||
| 95 | 95 | ** --admin-user|-A USERNAME Make USERNAME the administrator |
| 96 | 96 | ** --private Also clone private branches |
| 97 | 97 | ** --ssl-identity=filename Use the SSL identity if requested by the server |
| 98 | 98 | ** --ssh-fossil|-f /fossil Use this path as remote fossil command |
| 99 | 99 | ** --ssh-command|-c 'command' Use this SSH command |
| 100 | +** --ssh-fossil-user|-u user Fossil user to use for SSH if different. | |
| 100 | 101 | ** |
| 101 | 102 | ** See also: init |
| 102 | 103 | */ |
| 103 | 104 | void clone_cmd(void){ |
| 104 | 105 | char *zPassword; |
| @@ -157,10 +158,11 @@ | ||
| 157 | 158 | "REPLACE INTO config(name,value,mtime)" |
| 158 | 159 | " VALUES('server-code', lower(hex(randomblob(20))), now());" |
| 159 | 160 | ); |
| 160 | 161 | url_enable_proxy(0); |
| 161 | 162 | url_get_password_if_needed(); |
| 163 | + clone_ssh_db_options(); | |
| 162 | 164 | g.xlinkClusterOnly = 1; |
| 163 | 165 | nErr = client_sync(SYNC_CLONE | bPrivate,CONFIGSET_ALL,0); |
| 164 | 166 | g.xlinkClusterOnly = 0; |
| 165 | 167 | verify_cancel(); |
| 166 | 168 | db_end_transaction(0); |
| @@ -184,18 +186,23 @@ | ||
| 184 | 186 | ** Look for SSH clone command line options and setup in globals. |
| 185 | 187 | */ |
| 186 | 188 | void clone_ssh_options(void){ |
| 187 | 189 | const char *zSshFossilCmd; /* Path to remote fossil command for SSH */ |
| 188 | 190 | const char *zSshCmd; /* SSH command string */ |
| 191 | + const char *zFossilUser; /* Fossil user if login specified for SSH */ | |
| 189 | 192 | |
| 190 | 193 | zSshFossilCmd = find_option("ssh-fossil","f",1); |
| 191 | 194 | if( zSshFossilCmd && zSshFossilCmd[0] ){ |
| 192 | 195 | g.zSshFossilCmd = mprintf("%s", zSshFossilCmd); |
| 193 | 196 | } |
| 194 | 197 | zSshCmd = find_option("ssh-command","c",1); |
| 195 | 198 | if( zSshCmd && zSshCmd[0] ){ |
| 196 | 199 | g.zSshCmd = mprintf("%s", zSshCmd); |
| 200 | + } | |
| 201 | + zFossilUser = find_option("ssh-fossil-user","u",1); | |
| 202 | + if( zFossilUser && zFossilUser[0] ){ | |
| 203 | + g.zFossilUser = mprintf("%s", zFossilUser); | |
| 197 | 204 | } |
| 198 | 205 | } |
| 199 | 206 | |
| 200 | 207 | /* |
| 201 | 208 | ** Set SSH options discovered in global variables (set from command line |
| @@ -203,11 +210,16 @@ | ||
| 203 | 210 | */ |
| 204 | 211 | void clone_ssh_db_options(void){ |
| 205 | 212 | if( g.zSshFossilCmd && g.zSshFossilCmd[0] ){ |
| 206 | 213 | db_set("ssh-fossil", g.zSshFossilCmd, 0); |
| 207 | 214 | }else{ |
| 208 | - g.zSshFossilCmd = db_get("ssh-fossil","fossil"); | |
| 215 | + g.zSshFossilCmd = db_get("ssh-fossil", "fossil"); | |
| 209 | 216 | } |
| 210 | 217 | if( g.zSshCmd && g.zSshCmd[0] ){ |
| 211 | 218 | db_set("ssh-command", g.zSshCmd, 0); |
| 212 | 219 | } |
| 220 | + if( g.zFossilUser && g.zFossilUser[0] ){ | |
| 221 | + db_set("ssh-fossil-user", g.zFossilUser, 0); | |
| 222 | + }else{ | |
| 223 | + g.zFossilUser = db_get("ssh-fossil-user", 0); | |
| 224 | + } | |
| 213 | 225 | } |
| 214 | 226 |
| --- src/clone.c | |
| +++ src/clone.c | |
| @@ -95,10 +95,11 @@ | |
| 95 | ** --admin-user|-A USERNAME Make USERNAME the administrator |
| 96 | ** --private Also clone private branches |
| 97 | ** --ssl-identity=filename Use the SSL identity if requested by the server |
| 98 | ** --ssh-fossil|-f /fossil Use this path as remote fossil command |
| 99 | ** --ssh-command|-c 'command' Use this SSH command |
| 100 | ** |
| 101 | ** See also: init |
| 102 | */ |
| 103 | void clone_cmd(void){ |
| 104 | char *zPassword; |
| @@ -157,10 +158,11 @@ | |
| 157 | "REPLACE INTO config(name,value,mtime)" |
| 158 | " VALUES('server-code', lower(hex(randomblob(20))), now());" |
| 159 | ); |
| 160 | url_enable_proxy(0); |
| 161 | url_get_password_if_needed(); |
| 162 | g.xlinkClusterOnly = 1; |
| 163 | nErr = client_sync(SYNC_CLONE | bPrivate,CONFIGSET_ALL,0); |
| 164 | g.xlinkClusterOnly = 0; |
| 165 | verify_cancel(); |
| 166 | db_end_transaction(0); |
| @@ -184,18 +186,23 @@ | |
| 184 | ** Look for SSH clone command line options and setup in globals. |
| 185 | */ |
| 186 | void clone_ssh_options(void){ |
| 187 | const char *zSshFossilCmd; /* Path to remote fossil command for SSH */ |
| 188 | const char *zSshCmd; /* SSH command string */ |
| 189 | |
| 190 | zSshFossilCmd = find_option("ssh-fossil","f",1); |
| 191 | if( zSshFossilCmd && zSshFossilCmd[0] ){ |
| 192 | g.zSshFossilCmd = mprintf("%s", zSshFossilCmd); |
| 193 | } |
| 194 | zSshCmd = find_option("ssh-command","c",1); |
| 195 | if( zSshCmd && zSshCmd[0] ){ |
| 196 | g.zSshCmd = mprintf("%s", zSshCmd); |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | /* |
| 201 | ** Set SSH options discovered in global variables (set from command line |
| @@ -203,11 +210,16 @@ | |
| 203 | */ |
| 204 | void clone_ssh_db_options(void){ |
| 205 | if( g.zSshFossilCmd && g.zSshFossilCmd[0] ){ |
| 206 | db_set("ssh-fossil", g.zSshFossilCmd, 0); |
| 207 | }else{ |
| 208 | g.zSshFossilCmd = db_get("ssh-fossil","fossil"); |
| 209 | } |
| 210 | if( g.zSshCmd && g.zSshCmd[0] ){ |
| 211 | db_set("ssh-command", g.zSshCmd, 0); |
| 212 | } |
| 213 | } |
| 214 |
| --- src/clone.c | |
| +++ src/clone.c | |
| @@ -95,10 +95,11 @@ | |
| 95 | ** --admin-user|-A USERNAME Make USERNAME the administrator |
| 96 | ** --private Also clone private branches |
| 97 | ** --ssl-identity=filename Use the SSL identity if requested by the server |
| 98 | ** --ssh-fossil|-f /fossil Use this path as remote fossil command |
| 99 | ** --ssh-command|-c 'command' Use this SSH command |
| 100 | ** --ssh-fossil-user|-u user Fossil user to use for SSH if different. |
| 101 | ** |
| 102 | ** See also: init |
| 103 | */ |
| 104 | void clone_cmd(void){ |
| 105 | char *zPassword; |
| @@ -157,10 +158,11 @@ | |
| 158 | "REPLACE INTO config(name,value,mtime)" |
| 159 | " VALUES('server-code', lower(hex(randomblob(20))), now());" |
| 160 | ); |
| 161 | url_enable_proxy(0); |
| 162 | url_get_password_if_needed(); |
| 163 | clone_ssh_db_options(); |
| 164 | g.xlinkClusterOnly = 1; |
| 165 | nErr = client_sync(SYNC_CLONE | bPrivate,CONFIGSET_ALL,0); |
| 166 | g.xlinkClusterOnly = 0; |
| 167 | verify_cancel(); |
| 168 | db_end_transaction(0); |
| @@ -184,18 +186,23 @@ | |
| 186 | ** Look for SSH clone command line options and setup in globals. |
| 187 | */ |
| 188 | void clone_ssh_options(void){ |
| 189 | const char *zSshFossilCmd; /* Path to remote fossil command for SSH */ |
| 190 | const char *zSshCmd; /* SSH command string */ |
| 191 | const char *zFossilUser; /* Fossil user if login specified for SSH */ |
| 192 | |
| 193 | zSshFossilCmd = find_option("ssh-fossil","f",1); |
| 194 | if( zSshFossilCmd && zSshFossilCmd[0] ){ |
| 195 | g.zSshFossilCmd = mprintf("%s", zSshFossilCmd); |
| 196 | } |
| 197 | zSshCmd = find_option("ssh-command","c",1); |
| 198 | if( zSshCmd && zSshCmd[0] ){ |
| 199 | g.zSshCmd = mprintf("%s", zSshCmd); |
| 200 | } |
| 201 | zFossilUser = find_option("ssh-fossil-user","u",1); |
| 202 | if( zFossilUser && zFossilUser[0] ){ |
| 203 | g.zFossilUser = mprintf("%s", zFossilUser); |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | /* |
| 208 | ** Set SSH options discovered in global variables (set from command line |
| @@ -203,11 +210,16 @@ | |
| 210 | */ |
| 211 | void clone_ssh_db_options(void){ |
| 212 | if( g.zSshFossilCmd && g.zSshFossilCmd[0] ){ |
| 213 | db_set("ssh-fossil", g.zSshFossilCmd, 0); |
| 214 | }else{ |
| 215 | g.zSshFossilCmd = db_get("ssh-fossil", "fossil"); |
| 216 | } |
| 217 | if( g.zSshCmd && g.zSshCmd[0] ){ |
| 218 | db_set("ssh-command", g.zSshCmd, 0); |
| 219 | } |
| 220 | if( g.zFossilUser && g.zFossilUser[0] ){ |
| 221 | db_set("ssh-fossil-user", g.zFossilUser, 0); |
| 222 | }else{ |
| 223 | g.zFossilUser = db_get("ssh-fossil-user", 0); |
| 224 | } |
| 225 | } |
| 226 |
M
src/db.c
+3
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -2128,10 +2128,11 @@ | ||
| 2128 | 2128 | { "relative-paths",0, 0, 0, "on" }, |
| 2129 | 2129 | { "repo-cksum", 0, 0, 0, "on" }, |
| 2130 | 2130 | { "self-register", 0, 0, 0, "off" }, |
| 2131 | 2131 | { "ssh-command", 0, 40, 0, "" }, |
| 2132 | 2132 | { "ssh-fossil", 0, 40, 0, "" }, |
| 2133 | + { "ssh-fossil-user", 0, 40, 0, "" }, | |
| 2133 | 2134 | { "ssl-ca-location",0, 40, 0, "" }, |
| 2134 | 2135 | { "ssl-identity", 0, 40, 0, "" }, |
| 2135 | 2136 | #ifdef FOSSIL_ENABLE_TCL |
| 2136 | 2137 | { "tcl", 0, 0, 0, "off" }, |
| 2137 | 2138 | { "tcl-setup", 0, 40, 0, "" }, |
| @@ -2300,10 +2301,12 @@ | ||
| 2300 | 2301 | ** |
| 2301 | 2302 | ** ssh-command Command used to talk to a remote machine with |
| 2302 | 2303 | ** the "ssh://" protocol. |
| 2303 | 2304 | ** |
| 2304 | 2305 | ** ssh-fossil Remote fossil command to run with the "ssh://" protocol. |
| 2306 | +** | |
| 2307 | +** ssh-fossil-user Fossil user to use instead of the URL user. | |
| 2305 | 2308 | ** |
| 2306 | 2309 | ** ssl-ca-location The full pathname to a file containing PEM encoded |
| 2307 | 2310 | ** CA root certificates, or a directory of certificates |
| 2308 | 2311 | ** with filenames formed from the certificate hashes as |
| 2309 | 2312 | ** required by OpenSSL. |
| 2310 | 2313 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -2128,10 +2128,11 @@ | |
| 2128 | { "relative-paths",0, 0, 0, "on" }, |
| 2129 | { "repo-cksum", 0, 0, 0, "on" }, |
| 2130 | { "self-register", 0, 0, 0, "off" }, |
| 2131 | { "ssh-command", 0, 40, 0, "" }, |
| 2132 | { "ssh-fossil", 0, 40, 0, "" }, |
| 2133 | { "ssl-ca-location",0, 40, 0, "" }, |
| 2134 | { "ssl-identity", 0, 40, 0, "" }, |
| 2135 | #ifdef FOSSIL_ENABLE_TCL |
| 2136 | { "tcl", 0, 0, 0, "off" }, |
| 2137 | { "tcl-setup", 0, 40, 0, "" }, |
| @@ -2300,10 +2301,12 @@ | |
| 2300 | ** |
| 2301 | ** ssh-command Command used to talk to a remote machine with |
| 2302 | ** the "ssh://" protocol. |
| 2303 | ** |
| 2304 | ** ssh-fossil Remote fossil command to run with the "ssh://" protocol. |
| 2305 | ** |
| 2306 | ** ssl-ca-location The full pathname to a file containing PEM encoded |
| 2307 | ** CA root certificates, or a directory of certificates |
| 2308 | ** with filenames formed from the certificate hashes as |
| 2309 | ** required by OpenSSL. |
| 2310 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -2128,10 +2128,11 @@ | |
| 2128 | { "relative-paths",0, 0, 0, "on" }, |
| 2129 | { "repo-cksum", 0, 0, 0, "on" }, |
| 2130 | { "self-register", 0, 0, 0, "off" }, |
| 2131 | { "ssh-command", 0, 40, 0, "" }, |
| 2132 | { "ssh-fossil", 0, 40, 0, "" }, |
| 2133 | { "ssh-fossil-user", 0, 40, 0, "" }, |
| 2134 | { "ssl-ca-location",0, 40, 0, "" }, |
| 2135 | { "ssl-identity", 0, 40, 0, "" }, |
| 2136 | #ifdef FOSSIL_ENABLE_TCL |
| 2137 | { "tcl", 0, 0, 0, "off" }, |
| 2138 | { "tcl-setup", 0, 40, 0, "" }, |
| @@ -2300,10 +2301,12 @@ | |
| 2301 | ** |
| 2302 | ** ssh-command Command used to talk to a remote machine with |
| 2303 | ** the "ssh://" protocol. |
| 2304 | ** |
| 2305 | ** ssh-fossil Remote fossil command to run with the "ssh://" protocol. |
| 2306 | ** |
| 2307 | ** ssh-fossil-user Fossil user to use instead of the URL user. |
| 2308 | ** |
| 2309 | ** ssl-ca-location The full pathname to a file containing PEM encoded |
| 2310 | ** CA root certificates, or a directory of certificates |
| 2311 | ** with filenames formed from the certificate hashes as |
| 2312 | ** required by OpenSSL. |
| 2313 |
+8
-5
| --- src/http.c | ||
| +++ src/http.c | ||
| @@ -39,18 +39,19 @@ | ||
| 39 | 39 | const char *zPw; /* The user password */ |
| 40 | 40 | Blob pw; /* The nonce with user password appended */ |
| 41 | 41 | Blob sig; /* The signature field */ |
| 42 | 42 | |
| 43 | 43 | blob_zero(pLogin); |
| 44 | - if( g.urlUser==0 || fossil_strcmp(g.urlUser, "anonymous")==0 ){ | |
| 45 | - return; /* If no login card for users "nobody" and "anonymous" */ | |
| 44 | + if( g.urlUser==0 && g.zFossilUser==0 || | |
| 45 | + fossil_strcmp(g.urlUser, "anonymous")==0 ){ | |
| 46 | + return; /* If no login card for users "nobody" and "anonymous" */ | |
| 46 | 47 | } |
| 47 | 48 | blob_zero(&nonce); |
| 48 | 49 | blob_zero(&pw); |
| 49 | 50 | sha1sum_blob(pPayload, &nonce); |
| 50 | 51 | blob_copy(&pw, &nonce); |
| 51 | - zLogin = g.urlUser; | |
| 52 | + zLogin = url_or_fossil_user(); | |
| 52 | 53 | if( g.urlPasswd ){ |
| 53 | 54 | zPw = g.urlPasswd; |
| 54 | 55 | }else if( g.cgiOutput ){ |
| 55 | 56 | /* Password failure while doing a sync from the web interface */ |
| 56 | 57 | cgi_printf("*** incorrect or missing password for user %h\n", zLogin); |
| @@ -87,11 +88,13 @@ | ||
| 87 | 88 | ** the complete payload (including the login card) already compressed. |
| 88 | 89 | */ |
| 89 | 90 | static void http_build_header(Blob *pPayload, Blob *pHdr){ |
| 90 | 91 | int i; |
| 91 | 92 | const char *zSep; |
| 93 | + const char *zLogin; | |
| 92 | 94 | |
| 95 | + zLogin = url_or_fossil_user(); | |
| 93 | 96 | blob_zero(pHdr); |
| 94 | 97 | i = strlen(g.urlPath); |
| 95 | 98 | if( i>0 && g.urlPath[i-1]=='/' ){ |
| 96 | 99 | zSep = ""; |
| 97 | 100 | }else{ |
| @@ -99,12 +102,12 @@ | ||
| 99 | 102 | } |
| 100 | 103 | blob_appendf(pHdr, "POST %s%sxfer/xfer HTTP/1.0\r\n", g.urlPath, zSep); |
| 101 | 104 | if( g.urlProxyAuth ){ |
| 102 | 105 | blob_appendf(pHdr, "Proxy-Authorization: %s\r\n", g.urlProxyAuth); |
| 103 | 106 | } |
| 104 | - if( g.urlPasswd && g.urlUser && g.urlPasswd[0]=='#' ){ | |
| 105 | - char *zCredentials = mprintf("%s:%s", g.urlUser, &g.urlPasswd[1]); | |
| 107 | + if( g.urlPasswd && zLogin && g.urlPasswd[0]=='#' ){ | |
| 108 | + char *zCredentials = mprintf("%s:%s", zLogin, &g.urlPasswd[1]); | |
| 106 | 109 | char *zEncoded = encode64(zCredentials, -1); |
| 107 | 110 | blob_appendf(pHdr, "Authorization: Basic %s\r\n", zEncoded); |
| 108 | 111 | fossil_free(zEncoded); |
| 109 | 112 | fossil_free(zCredentials); |
| 110 | 113 | } |
| 111 | 114 |
| --- src/http.c | |
| +++ src/http.c | |
| @@ -39,18 +39,19 @@ | |
| 39 | const char *zPw; /* The user password */ |
| 40 | Blob pw; /* The nonce with user password appended */ |
| 41 | Blob sig; /* The signature field */ |
| 42 | |
| 43 | blob_zero(pLogin); |
| 44 | if( g.urlUser==0 || fossil_strcmp(g.urlUser, "anonymous")==0 ){ |
| 45 | return; /* If no login card for users "nobody" and "anonymous" */ |
| 46 | } |
| 47 | blob_zero(&nonce); |
| 48 | blob_zero(&pw); |
| 49 | sha1sum_blob(pPayload, &nonce); |
| 50 | blob_copy(&pw, &nonce); |
| 51 | zLogin = g.urlUser; |
| 52 | if( g.urlPasswd ){ |
| 53 | zPw = g.urlPasswd; |
| 54 | }else if( g.cgiOutput ){ |
| 55 | /* Password failure while doing a sync from the web interface */ |
| 56 | cgi_printf("*** incorrect or missing password for user %h\n", zLogin); |
| @@ -87,11 +88,13 @@ | |
| 87 | ** the complete payload (including the login card) already compressed. |
| 88 | */ |
| 89 | static void http_build_header(Blob *pPayload, Blob *pHdr){ |
| 90 | int i; |
| 91 | const char *zSep; |
| 92 | |
| 93 | blob_zero(pHdr); |
| 94 | i = strlen(g.urlPath); |
| 95 | if( i>0 && g.urlPath[i-1]=='/' ){ |
| 96 | zSep = ""; |
| 97 | }else{ |
| @@ -99,12 +102,12 @@ | |
| 99 | } |
| 100 | blob_appendf(pHdr, "POST %s%sxfer/xfer HTTP/1.0\r\n", g.urlPath, zSep); |
| 101 | if( g.urlProxyAuth ){ |
| 102 | blob_appendf(pHdr, "Proxy-Authorization: %s\r\n", g.urlProxyAuth); |
| 103 | } |
| 104 | if( g.urlPasswd && g.urlUser && g.urlPasswd[0]=='#' ){ |
| 105 | char *zCredentials = mprintf("%s:%s", g.urlUser, &g.urlPasswd[1]); |
| 106 | char *zEncoded = encode64(zCredentials, -1); |
| 107 | blob_appendf(pHdr, "Authorization: Basic %s\r\n", zEncoded); |
| 108 | fossil_free(zEncoded); |
| 109 | fossil_free(zCredentials); |
| 110 | } |
| 111 |
| --- src/http.c | |
| +++ src/http.c | |
| @@ -39,18 +39,19 @@ | |
| 39 | const char *zPw; /* The user password */ |
| 40 | Blob pw; /* The nonce with user password appended */ |
| 41 | Blob sig; /* The signature field */ |
| 42 | |
| 43 | blob_zero(pLogin); |
| 44 | if( g.urlUser==0 && g.zFossilUser==0 || |
| 45 | fossil_strcmp(g.urlUser, "anonymous")==0 ){ |
| 46 | return; /* If no login card for users "nobody" and "anonymous" */ |
| 47 | } |
| 48 | blob_zero(&nonce); |
| 49 | blob_zero(&pw); |
| 50 | sha1sum_blob(pPayload, &nonce); |
| 51 | blob_copy(&pw, &nonce); |
| 52 | zLogin = url_or_fossil_user(); |
| 53 | if( g.urlPasswd ){ |
| 54 | zPw = g.urlPasswd; |
| 55 | }else if( g.cgiOutput ){ |
| 56 | /* Password failure while doing a sync from the web interface */ |
| 57 | cgi_printf("*** incorrect or missing password for user %h\n", zLogin); |
| @@ -87,11 +88,13 @@ | |
| 88 | ** the complete payload (including the login card) already compressed. |
| 89 | */ |
| 90 | static void http_build_header(Blob *pPayload, Blob *pHdr){ |
| 91 | int i; |
| 92 | const char *zSep; |
| 93 | const char *zLogin; |
| 94 | |
| 95 | zLogin = url_or_fossil_user(); |
| 96 | blob_zero(pHdr); |
| 97 | i = strlen(g.urlPath); |
| 98 | if( i>0 && g.urlPath[i-1]=='/' ){ |
| 99 | zSep = ""; |
| 100 | }else{ |
| @@ -99,12 +102,12 @@ | |
| 102 | } |
| 103 | blob_appendf(pHdr, "POST %s%sxfer/xfer HTTP/1.0\r\n", g.urlPath, zSep); |
| 104 | if( g.urlProxyAuth ){ |
| 105 | blob_appendf(pHdr, "Proxy-Authorization: %s\r\n", g.urlProxyAuth); |
| 106 | } |
| 107 | if( g.urlPasswd && zLogin && g.urlPasswd[0]=='#' ){ |
| 108 | char *zCredentials = mprintf("%s:%s", zLogin, &g.urlPasswd[1]); |
| 109 | char *zEncoded = encode64(zCredentials, -1); |
| 110 | blob_appendf(pHdr, "Authorization: Basic %s\r\n", zEncoded); |
| 111 | fossil_free(zEncoded); |
| 112 | fossil_free(zCredentials); |
| 113 | } |
| 114 |
-19
| --- src/http_transport.c | ||
| +++ src/http_transport.c | ||
| @@ -123,29 +123,10 @@ | ||
| 123 | 123 | } |
| 124 | 124 | fossil_force_newline(); |
| 125 | 125 | fossil_print("%s", blob_str(&zCmd)); /* Show the base of the SSH command */ |
| 126 | 126 | if( g.urlUser && g.urlUser[0] ){ |
| 127 | 127 | zHost = mprintf("%s@%s", g.urlUser, g.urlName); |
| 128 | -#ifdef __MINGW32__ | |
| 129 | - /* Only win32 (and specifically PLINK.EXE) support the -pw option */ | |
| 130 | - if( g.urlPasswd && g.urlPasswd[0] ){ | |
| 131 | - Blob pw; | |
| 132 | - blob_zero(&pw); | |
| 133 | - if( g.urlPasswd[0]=='*' ){ | |
| 134 | - char *zPrompt; | |
| 135 | - zPrompt = mprintf("Password for [%s]: ", zHost); | |
| 136 | - prompt_for_password(zPrompt, &pw, 0); | |
| 137 | - free(zPrompt); | |
| 138 | - }else{ | |
| 139 | - blob_init(&pw, g.urlPasswd, -1); | |
| 140 | - } | |
| 141 | - blob_append(&zCmd, " -pw ", -1); | |
| 142 | - shell_escape(&zCmd, blob_str(&pw)); | |
| 143 | - blob_reset(&pw); | |
| 144 | - fossil_print(" -pw ********"); /* Do not show the password text */ | |
| 145 | - } | |
| 146 | -#endif | |
| 147 | 128 | }else{ |
| 148 | 129 | zHost = mprintf("%s", g.urlName); |
| 149 | 130 | } |
| 150 | 131 | n = blob_size(&zCmd); |
| 151 | 132 | blob_append(&zCmd, " ", 1); |
| 152 | 133 |
| --- src/http_transport.c | |
| +++ src/http_transport.c | |
| @@ -123,29 +123,10 @@ | |
| 123 | } |
| 124 | fossil_force_newline(); |
| 125 | fossil_print("%s", blob_str(&zCmd)); /* Show the base of the SSH command */ |
| 126 | if( g.urlUser && g.urlUser[0] ){ |
| 127 | zHost = mprintf("%s@%s", g.urlUser, g.urlName); |
| 128 | #ifdef __MINGW32__ |
| 129 | /* Only win32 (and specifically PLINK.EXE) support the -pw option */ |
| 130 | if( g.urlPasswd && g.urlPasswd[0] ){ |
| 131 | Blob pw; |
| 132 | blob_zero(&pw); |
| 133 | if( g.urlPasswd[0]=='*' ){ |
| 134 | char *zPrompt; |
| 135 | zPrompt = mprintf("Password for [%s]: ", zHost); |
| 136 | prompt_for_password(zPrompt, &pw, 0); |
| 137 | free(zPrompt); |
| 138 | }else{ |
| 139 | blob_init(&pw, g.urlPasswd, -1); |
| 140 | } |
| 141 | blob_append(&zCmd, " -pw ", -1); |
| 142 | shell_escape(&zCmd, blob_str(&pw)); |
| 143 | blob_reset(&pw); |
| 144 | fossil_print(" -pw ********"); /* Do not show the password text */ |
| 145 | } |
| 146 | #endif |
| 147 | }else{ |
| 148 | zHost = mprintf("%s", g.urlName); |
| 149 | } |
| 150 | n = blob_size(&zCmd); |
| 151 | blob_append(&zCmd, " ", 1); |
| 152 |
| --- src/http_transport.c | |
| +++ src/http_transport.c | |
| @@ -123,29 +123,10 @@ | |
| 123 | } |
| 124 | fossil_force_newline(); |
| 125 | fossil_print("%s", blob_str(&zCmd)); /* Show the base of the SSH command */ |
| 126 | if( g.urlUser && g.urlUser[0] ){ |
| 127 | zHost = mprintf("%s@%s", g.urlUser, g.urlName); |
| 128 | }else{ |
| 129 | zHost = mprintf("%s", g.urlName); |
| 130 | } |
| 131 | n = blob_size(&zCmd); |
| 132 | blob_append(&zCmd, " ", 1); |
| 133 |
+2
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -136,10 +136,11 @@ | ||
| 136 | 136 | int fHttpTrace; /* Trace outbound HTTP requests */ |
| 137 | 137 | int fSystemTrace; /* Trace calls to fossil_system(), --systemtrace */ |
| 138 | 138 | int fSshTrace; /* Trace the SSH setup traffic */ |
| 139 | 139 | char *zSshFossilCmd; /* Path to remoe fossil command for SSH */ |
| 140 | 140 | char *zSshCmd; /* SSH command string */ |
| 141 | + char *zFossilUser; /* Fossil user if different from URL user */ | |
| 141 | 142 | int fNoSync; /* Do not do an autosync ever. --nosync */ |
| 142 | 143 | char *zPath; /* Name of webpage being served */ |
| 143 | 144 | char *zExtra; /* Extra path information past the webpage name */ |
| 144 | 145 | char *zBaseURL; /* Full text of the URL being served */ |
| 145 | 146 | char *zTop; /* Parent directory of zPath */ |
| @@ -580,10 +581,11 @@ | ||
| 580 | 581 | g.fSqlStats = find_option("sqlstats", 0, 0)!=0; |
| 581 | 582 | g.fSystemTrace = find_option("systemtrace", 0, 0)!=0; |
| 582 | 583 | g.fSshTrace = find_option("sshtrace", 0, 0)!=0; |
| 583 | 584 | g.zSshFossilCmd = 0; |
| 584 | 585 | g.zSshCmd = 0; |
| 586 | + g.zFossilUser = 0; | |
| 585 | 587 | if( g.fSqlTrace ) g.fSqlStats = 1; |
| 586 | 588 | g.fSqlPrint = find_option("sqlprint", 0, 0)!=0; |
| 587 | 589 | g.fHttpTrace = find_option("httptrace", 0, 0)!=0; |
| 588 | 590 | g.zLogin = find_option("user", "U", 1); |
| 589 | 591 | g.zSSLIdentity = find_option("ssl-identity", 0, 1); |
| 590 | 592 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -136,10 +136,11 @@ | |
| 136 | int fHttpTrace; /* Trace outbound HTTP requests */ |
| 137 | int fSystemTrace; /* Trace calls to fossil_system(), --systemtrace */ |
| 138 | int fSshTrace; /* Trace the SSH setup traffic */ |
| 139 | char *zSshFossilCmd; /* Path to remoe fossil command for SSH */ |
| 140 | char *zSshCmd; /* SSH command string */ |
| 141 | int fNoSync; /* Do not do an autosync ever. --nosync */ |
| 142 | char *zPath; /* Name of webpage being served */ |
| 143 | char *zExtra; /* Extra path information past the webpage name */ |
| 144 | char *zBaseURL; /* Full text of the URL being served */ |
| 145 | char *zTop; /* Parent directory of zPath */ |
| @@ -580,10 +581,11 @@ | |
| 580 | g.fSqlStats = find_option("sqlstats", 0, 0)!=0; |
| 581 | g.fSystemTrace = find_option("systemtrace", 0, 0)!=0; |
| 582 | g.fSshTrace = find_option("sshtrace", 0, 0)!=0; |
| 583 | g.zSshFossilCmd = 0; |
| 584 | g.zSshCmd = 0; |
| 585 | if( g.fSqlTrace ) g.fSqlStats = 1; |
| 586 | g.fSqlPrint = find_option("sqlprint", 0, 0)!=0; |
| 587 | g.fHttpTrace = find_option("httptrace", 0, 0)!=0; |
| 588 | g.zLogin = find_option("user", "U", 1); |
| 589 | g.zSSLIdentity = find_option("ssl-identity", 0, 1); |
| 590 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -136,10 +136,11 @@ | |
| 136 | int fHttpTrace; /* Trace outbound HTTP requests */ |
| 137 | int fSystemTrace; /* Trace calls to fossil_system(), --systemtrace */ |
| 138 | int fSshTrace; /* Trace the SSH setup traffic */ |
| 139 | char *zSshFossilCmd; /* Path to remoe fossil command for SSH */ |
| 140 | char *zSshCmd; /* SSH command string */ |
| 141 | char *zFossilUser; /* Fossil user if different from URL user */ |
| 142 | int fNoSync; /* Do not do an autosync ever. --nosync */ |
| 143 | char *zPath; /* Name of webpage being served */ |
| 144 | char *zExtra; /* Extra path information past the webpage name */ |
| 145 | char *zBaseURL; /* Full text of the URL being served */ |
| 146 | char *zTop; /* Parent directory of zPath */ |
| @@ -580,10 +581,11 @@ | |
| 581 | g.fSqlStats = find_option("sqlstats", 0, 0)!=0; |
| 582 | g.fSystemTrace = find_option("systemtrace", 0, 0)!=0; |
| 583 | g.fSshTrace = find_option("sshtrace", 0, 0)!=0; |
| 584 | g.zSshFossilCmd = 0; |
| 585 | g.zSshCmd = 0; |
| 586 | g.zFossilUser = 0; |
| 587 | if( g.fSqlTrace ) g.fSqlStats = 1; |
| 588 | g.fSqlPrint = find_option("sqlprint", 0, 0)!=0; |
| 589 | g.fHttpTrace = find_option("httptrace", 0, 0)!=0; |
| 590 | g.zLogin = find_option("user", "U", 1); |
| 591 | g.zSSLIdentity = find_option("ssl-identity", 0, 1); |
| 592 |
+2
-1
| --- src/sync.c | ||
| +++ src/sync.c | ||
| @@ -49,11 +49,11 @@ | ||
| 49 | 49 | }else{ |
| 50 | 50 | /* Autosync defaults on. To make it default off, "return" here. */ |
| 51 | 51 | } |
| 52 | 52 | url_parse(0, URL_REMEMBER); |
| 53 | 53 | if( g.urlProtocol==0 ) return 0; |
| 54 | - if( g.urlUser!=0 && g.urlPasswd==0 ){ | |
| 54 | + if( ( g.urlUser!=0 || g.zFossilUser!=0 ) && g.urlPasswd==0 ){ | |
| 55 | 55 | g.urlPasswd = unobscure(db_get("last-sync-pw", 0)); |
| 56 | 56 | } |
| 57 | 57 | #if 0 /* Disabled for now */ |
| 58 | 58 | if( (flags & AUTOSYNC_PULL)!=0 && db_get_boolean("auto-shun",1) ){ |
| 59 | 59 | /* When doing an automatic pull, also automatically pull shuns from |
| @@ -102,10 +102,11 @@ | ||
| 102 | 102 | if( g.argc==2 ){ |
| 103 | 103 | if( db_get_boolean("auto-shun",1) ) configSync = CONFIGSET_SHUN; |
| 104 | 104 | }else if( g.argc==3 ){ |
| 105 | 105 | zUrl = g.argv[2]; |
| 106 | 106 | } |
| 107 | + clone_ssh_db_options(); | |
| 107 | 108 | url_parse(zUrl, urlFlags); |
| 108 | 109 | if( g.urlProtocol==0 ){ |
| 109 | 110 | if( urlOptional ) fossil_exit(0); |
| 110 | 111 | usage("URL"); |
| 111 | 112 | } |
| 112 | 113 |
| --- src/sync.c | |
| +++ src/sync.c | |
| @@ -49,11 +49,11 @@ | |
| 49 | }else{ |
| 50 | /* Autosync defaults on. To make it default off, "return" here. */ |
| 51 | } |
| 52 | url_parse(0, URL_REMEMBER); |
| 53 | if( g.urlProtocol==0 ) return 0; |
| 54 | if( g.urlUser!=0 && g.urlPasswd==0 ){ |
| 55 | g.urlPasswd = unobscure(db_get("last-sync-pw", 0)); |
| 56 | } |
| 57 | #if 0 /* Disabled for now */ |
| 58 | if( (flags & AUTOSYNC_PULL)!=0 && db_get_boolean("auto-shun",1) ){ |
| 59 | /* When doing an automatic pull, also automatically pull shuns from |
| @@ -102,10 +102,11 @@ | |
| 102 | if( g.argc==2 ){ |
| 103 | if( db_get_boolean("auto-shun",1) ) configSync = CONFIGSET_SHUN; |
| 104 | }else if( g.argc==3 ){ |
| 105 | zUrl = g.argv[2]; |
| 106 | } |
| 107 | url_parse(zUrl, urlFlags); |
| 108 | if( g.urlProtocol==0 ){ |
| 109 | if( urlOptional ) fossil_exit(0); |
| 110 | usage("URL"); |
| 111 | } |
| 112 |
| --- src/sync.c | |
| +++ src/sync.c | |
| @@ -49,11 +49,11 @@ | |
| 49 | }else{ |
| 50 | /* Autosync defaults on. To make it default off, "return" here. */ |
| 51 | } |
| 52 | url_parse(0, URL_REMEMBER); |
| 53 | if( g.urlProtocol==0 ) return 0; |
| 54 | if( ( g.urlUser!=0 || g.zFossilUser!=0 ) && g.urlPasswd==0 ){ |
| 55 | g.urlPasswd = unobscure(db_get("last-sync-pw", 0)); |
| 56 | } |
| 57 | #if 0 /* Disabled for now */ |
| 58 | if( (flags & AUTOSYNC_PULL)!=0 && db_get_boolean("auto-shun",1) ){ |
| 59 | /* When doing an automatic pull, also automatically pull shuns from |
| @@ -102,10 +102,11 @@ | |
| 102 | if( g.argc==2 ){ |
| 103 | if( db_get_boolean("auto-shun",1) ) configSync = CONFIGSET_SHUN; |
| 104 | }else if( g.argc==3 ){ |
| 105 | zUrl = g.argv[2]; |
| 106 | } |
| 107 | clone_ssh_db_options(); |
| 108 | url_parse(zUrl, urlFlags); |
| 109 | if( g.urlProtocol==0 ){ |
| 110 | if( urlOptional ) fossil_exit(0); |
| 111 | usage("URL"); |
| 112 | } |
| 113 |
+6
-15
| --- src/url.c | ||
| +++ src/url.c | ||
| @@ -197,19 +197,20 @@ | ||
| 197 | 197 | g.urlProtocol = "file"; |
| 198 | 198 | g.urlPath = ""; |
| 199 | 199 | g.urlName = mprintf("%b", &cfile); |
| 200 | 200 | g.urlCanonical = mprintf("file://%T", g.urlName); |
| 201 | 201 | blob_reset(&cfile); |
| 202 | - }else if( g.urlUser!=0 && g.urlPasswd==0 && (urlFlags & URL_PROMPT_PW) ){ | |
| 202 | + }else if( ( g.urlUser!=0 || g.zFossilUser!=0 ) | |
| 203 | + && g.urlPasswd==0 && (urlFlags & URL_PROMPT_PW) ){ | |
| 203 | 204 | url_prompt_for_password(); |
| 204 | 205 | bPrompted = 1; |
| 205 | 206 | } |
| 206 | 207 | if( urlFlags & URL_REMEMBER ){ |
| 207 | 208 | if( bSetUrl ){ |
| 208 | 209 | db_set("last-sync-url", g.urlCanonical, 0); |
| 209 | 210 | } |
| 210 | - if( !bPrompted && g.urlPasswd && g.urlUser ){ | |
| 211 | + if( !bPrompted && g.urlPasswd && ( g.urlUser || g.zFossilUser ) ){ | |
| 211 | 212 | db_set("last-sync-pw", obscure(g.urlPasswd), 0); |
| 212 | 213 | } |
| 213 | 214 | } |
| 214 | 215 | } |
| 215 | 216 | |
| @@ -412,35 +413,25 @@ | ||
| 412 | 413 | if( g.urlIsFile ) return; |
| 413 | 414 | if( isatty(fileno(stdin)) |
| 414 | 415 | && (g.urlFlags & URL_PROMPT_PW)!=0 |
| 415 | 416 | && (g.urlFlags & URL_PROMPTED)==0 |
| 416 | 417 | ){ |
| 417 | - char *zPrompt = mprintf("\rpassword for %s: ", g.urlUser); | |
| 418 | - Blob x; | |
| 419 | - fossil_force_newline(); | |
| 420 | - prompt_for_password(zPrompt, &x, 0); | |
| 421 | - free(zPrompt); | |
| 422 | - g.urlPasswd = mprintf("%b", &x); | |
| 423 | - blob_reset(&x); | |
| 424 | 418 | g.urlFlags |= URL_PROMPTED; |
| 419 | + g.urlPasswd = prompt_for_user_password(url_or_fossil_user()); | |
| 425 | 420 | if( g.urlPasswd[0] |
| 426 | 421 | && (g.urlFlags & (URL_REMEMBER|URL_ASK_REMEMBER_PW))!=0 |
| 427 | 422 | ){ |
| 428 | - char c; | |
| 429 | - prompt_user("remember password (Y/n)? ", &x); | |
| 430 | - c = blob_str(&x)[0]; | |
| 431 | - blob_reset(&x); | |
| 432 | - if( c!='n' && c!='N' ){ | |
| 423 | + if( save_password_prompt() ){ | |
| 433 | 424 | g.urlFlags |= URL_REMEMBER_PW; |
| 434 | 425 | if( g.urlFlags & URL_REMEMBER ){ |
| 435 | 426 | db_set("last-sync-pw", obscure(g.urlPasswd), 0); |
| 436 | 427 | } |
| 437 | 428 | } |
| 438 | 429 | } |
| 439 | 430 | }else{ |
| 440 | 431 | fossil_fatal("missing or incorrect password for user \"%s\"", |
| 441 | - g.urlUser); | |
| 432 | + url_or_fossil_user() ); | |
| 442 | 433 | } |
| 443 | 434 | } |
| 444 | 435 | |
| 445 | 436 | /* |
| 446 | 437 | ** Remember the URL if requested. |
| 447 | 438 |
| --- src/url.c | |
| +++ src/url.c | |
| @@ -197,19 +197,20 @@ | |
| 197 | g.urlProtocol = "file"; |
| 198 | g.urlPath = ""; |
| 199 | g.urlName = mprintf("%b", &cfile); |
| 200 | g.urlCanonical = mprintf("file://%T", g.urlName); |
| 201 | blob_reset(&cfile); |
| 202 | }else if( g.urlUser!=0 && g.urlPasswd==0 && (urlFlags & URL_PROMPT_PW) ){ |
| 203 | url_prompt_for_password(); |
| 204 | bPrompted = 1; |
| 205 | } |
| 206 | if( urlFlags & URL_REMEMBER ){ |
| 207 | if( bSetUrl ){ |
| 208 | db_set("last-sync-url", g.urlCanonical, 0); |
| 209 | } |
| 210 | if( !bPrompted && g.urlPasswd && g.urlUser ){ |
| 211 | db_set("last-sync-pw", obscure(g.urlPasswd), 0); |
| 212 | } |
| 213 | } |
| 214 | } |
| 215 | |
| @@ -412,35 +413,25 @@ | |
| 412 | if( g.urlIsFile ) return; |
| 413 | if( isatty(fileno(stdin)) |
| 414 | && (g.urlFlags & URL_PROMPT_PW)!=0 |
| 415 | && (g.urlFlags & URL_PROMPTED)==0 |
| 416 | ){ |
| 417 | char *zPrompt = mprintf("\rpassword for %s: ", g.urlUser); |
| 418 | Blob x; |
| 419 | fossil_force_newline(); |
| 420 | prompt_for_password(zPrompt, &x, 0); |
| 421 | free(zPrompt); |
| 422 | g.urlPasswd = mprintf("%b", &x); |
| 423 | blob_reset(&x); |
| 424 | g.urlFlags |= URL_PROMPTED; |
| 425 | if( g.urlPasswd[0] |
| 426 | && (g.urlFlags & (URL_REMEMBER|URL_ASK_REMEMBER_PW))!=0 |
| 427 | ){ |
| 428 | char c; |
| 429 | prompt_user("remember password (Y/n)? ", &x); |
| 430 | c = blob_str(&x)[0]; |
| 431 | blob_reset(&x); |
| 432 | if( c!='n' && c!='N' ){ |
| 433 | g.urlFlags |= URL_REMEMBER_PW; |
| 434 | if( g.urlFlags & URL_REMEMBER ){ |
| 435 | db_set("last-sync-pw", obscure(g.urlPasswd), 0); |
| 436 | } |
| 437 | } |
| 438 | } |
| 439 | }else{ |
| 440 | fossil_fatal("missing or incorrect password for user \"%s\"", |
| 441 | g.urlUser); |
| 442 | } |
| 443 | } |
| 444 | |
| 445 | /* |
| 446 | ** Remember the URL if requested. |
| 447 |
| --- src/url.c | |
| +++ src/url.c | |
| @@ -197,19 +197,20 @@ | |
| 197 | g.urlProtocol = "file"; |
| 198 | g.urlPath = ""; |
| 199 | g.urlName = mprintf("%b", &cfile); |
| 200 | g.urlCanonical = mprintf("file://%T", g.urlName); |
| 201 | blob_reset(&cfile); |
| 202 | }else if( ( g.urlUser!=0 || g.zFossilUser!=0 ) |
| 203 | && g.urlPasswd==0 && (urlFlags & URL_PROMPT_PW) ){ |
| 204 | url_prompt_for_password(); |
| 205 | bPrompted = 1; |
| 206 | } |
| 207 | if( urlFlags & URL_REMEMBER ){ |
| 208 | if( bSetUrl ){ |
| 209 | db_set("last-sync-url", g.urlCanonical, 0); |
| 210 | } |
| 211 | if( !bPrompted && g.urlPasswd && ( g.urlUser || g.zFossilUser ) ){ |
| 212 | db_set("last-sync-pw", obscure(g.urlPasswd), 0); |
| 213 | } |
| 214 | } |
| 215 | } |
| 216 | |
| @@ -412,35 +413,25 @@ | |
| 413 | if( g.urlIsFile ) return; |
| 414 | if( isatty(fileno(stdin)) |
| 415 | && (g.urlFlags & URL_PROMPT_PW)!=0 |
| 416 | && (g.urlFlags & URL_PROMPTED)==0 |
| 417 | ){ |
| 418 | g.urlFlags |= URL_PROMPTED; |
| 419 | g.urlPasswd = prompt_for_user_password(url_or_fossil_user()); |
| 420 | if( g.urlPasswd[0] |
| 421 | && (g.urlFlags & (URL_REMEMBER|URL_ASK_REMEMBER_PW))!=0 |
| 422 | ){ |
| 423 | if( save_password_prompt() ){ |
| 424 | g.urlFlags |= URL_REMEMBER_PW; |
| 425 | if( g.urlFlags & URL_REMEMBER ){ |
| 426 | db_set("last-sync-pw", obscure(g.urlPasswd), 0); |
| 427 | } |
| 428 | } |
| 429 | } |
| 430 | }else{ |
| 431 | fossil_fatal("missing or incorrect password for user \"%s\"", |
| 432 | url_or_fossil_user() ); |
| 433 | } |
| 434 | } |
| 435 | |
| 436 | /* |
| 437 | ** Remember the URL if requested. |
| 438 |
+38
| --- src/user.c | ||
| +++ src/user.c | ||
| @@ -128,10 +128,44 @@ | ||
| 128 | 128 | break; |
| 129 | 129 | } |
| 130 | 130 | } |
| 131 | 131 | blob_reset(&secondTry); |
| 132 | 132 | } |
| 133 | + | |
| 134 | +/* | |
| 135 | +** Prompt to save Fossil user password | |
| 136 | +*/ | |
| 137 | +int save_password_prompt(){ | |
| 138 | + Blob x; | |
| 139 | + char c; | |
| 140 | + prompt_user("remember password (Y/n)? ", &x); | |
| 141 | + c = blob_str(&x)[0]; | |
| 142 | + blob_reset(&x); | |
| 143 | + return ( c!='n' && c!='N' ); | |
| 144 | +} | |
| 145 | + | |
| 146 | +/* | |
| 147 | +** Prompt for Fossil user password | |
| 148 | +*/ | |
| 149 | +char *prompt_for_user_password(const char *zUser){ | |
| 150 | + char *zPrompt = mprintf("\rpassword for %s: ", zUser); | |
| 151 | + char *zPw; | |
| 152 | + Blob x; | |
| 153 | + fossil_force_newline(); | |
| 154 | + prompt_for_password(zPrompt, &x, 0); | |
| 155 | + free(zPrompt); | |
| 156 | + zPw = mprintf("%b", &x); | |
| 157 | + blob_reset(&x); | |
| 158 | + return zPw; | |
| 159 | +} | |
| 160 | + | |
| 161 | +/* | |
| 162 | +** Return Fossil user if defined or URL user | |
| 163 | +*/ | |
| 164 | +const char *url_or_fossil_user(void){ | |
| 165 | + return ( g.zFossilUser && g.zFossilUser[0] ) ? g.zFossilUser : g.urlUser; | |
| 166 | +} | |
| 133 | 167 | |
| 134 | 168 | /* |
| 135 | 169 | ** Prompt the user to enter a single line of text. |
| 136 | 170 | */ |
| 137 | 171 | void prompt_user(const char *zPrompt, Blob *pIn){ |
| @@ -319,10 +353,12 @@ | ||
| 319 | 353 | ** |
| 320 | 354 | ** (7) Try the USERNAME environment variable. |
| 321 | 355 | ** |
| 322 | 356 | ** (8) Check if the user can be extracted from the remote URL. |
| 323 | 357 | ** |
| 358 | +** (9) Check if the user was supplied as SSH command-line option. | |
| 359 | +** | |
| 324 | 360 | ** The user name is stored in g.zLogin. The uid is in g.userUid. |
| 325 | 361 | */ |
| 326 | 362 | void user_select(void){ |
| 327 | 363 | if( g.userUid ) return; |
| 328 | 364 | if( g.zLogin ){ |
| @@ -345,10 +381,12 @@ | ||
| 345 | 381 | |
| 346 | 382 | if( attempt_user(fossil_getenv("USERNAME")) ) return; |
| 347 | 383 | |
| 348 | 384 | url_parse(0, 0); |
| 349 | 385 | if( g.urlUser && attempt_user(g.urlUser) ) return; |
| 386 | + | |
| 387 | + if( g.zFossilUser && attempt_user(g.zFossilUser) ) return; | |
| 350 | 388 | |
| 351 | 389 | fossil_print( |
| 352 | 390 | "Cannot figure out who you are! Consider using the --user\n" |
| 353 | 391 | "command line option, setting your USER environment variable,\n" |
| 354 | 392 | "or setting a default user with \"fossil user default USER\".\n" |
| 355 | 393 |
| --- src/user.c | |
| +++ src/user.c | |
| @@ -128,10 +128,44 @@ | |
| 128 | break; |
| 129 | } |
| 130 | } |
| 131 | blob_reset(&secondTry); |
| 132 | } |
| 133 | |
| 134 | /* |
| 135 | ** Prompt the user to enter a single line of text. |
| 136 | */ |
| 137 | void prompt_user(const char *zPrompt, Blob *pIn){ |
| @@ -319,10 +353,12 @@ | |
| 319 | ** |
| 320 | ** (7) Try the USERNAME environment variable. |
| 321 | ** |
| 322 | ** (8) Check if the user can be extracted from the remote URL. |
| 323 | ** |
| 324 | ** The user name is stored in g.zLogin. The uid is in g.userUid. |
| 325 | */ |
| 326 | void user_select(void){ |
| 327 | if( g.userUid ) return; |
| 328 | if( g.zLogin ){ |
| @@ -345,10 +381,12 @@ | |
| 345 | |
| 346 | if( attempt_user(fossil_getenv("USERNAME")) ) return; |
| 347 | |
| 348 | url_parse(0, 0); |
| 349 | if( g.urlUser && attempt_user(g.urlUser) ) return; |
| 350 | |
| 351 | fossil_print( |
| 352 | "Cannot figure out who you are! Consider using the --user\n" |
| 353 | "command line option, setting your USER environment variable,\n" |
| 354 | "or setting a default user with \"fossil user default USER\".\n" |
| 355 |
| --- src/user.c | |
| +++ src/user.c | |
| @@ -128,10 +128,44 @@ | |
| 128 | break; |
| 129 | } |
| 130 | } |
| 131 | blob_reset(&secondTry); |
| 132 | } |
| 133 | |
| 134 | /* |
| 135 | ** Prompt to save Fossil user password |
| 136 | */ |
| 137 | int save_password_prompt(){ |
| 138 | Blob x; |
| 139 | char c; |
| 140 | prompt_user("remember password (Y/n)? ", &x); |
| 141 | c = blob_str(&x)[0]; |
| 142 | blob_reset(&x); |
| 143 | return ( c!='n' && c!='N' ); |
| 144 | } |
| 145 | |
| 146 | /* |
| 147 | ** Prompt for Fossil user password |
| 148 | */ |
| 149 | char *prompt_for_user_password(const char *zUser){ |
| 150 | char *zPrompt = mprintf("\rpassword for %s: ", zUser); |
| 151 | char *zPw; |
| 152 | Blob x; |
| 153 | fossil_force_newline(); |
| 154 | prompt_for_password(zPrompt, &x, 0); |
| 155 | free(zPrompt); |
| 156 | zPw = mprintf("%b", &x); |
| 157 | blob_reset(&x); |
| 158 | return zPw; |
| 159 | } |
| 160 | |
| 161 | /* |
| 162 | ** Return Fossil user if defined or URL user |
| 163 | */ |
| 164 | const char *url_or_fossil_user(void){ |
| 165 | return ( g.zFossilUser && g.zFossilUser[0] ) ? g.zFossilUser : g.urlUser; |
| 166 | } |
| 167 | |
| 168 | /* |
| 169 | ** Prompt the user to enter a single line of text. |
| 170 | */ |
| 171 | void prompt_user(const char *zPrompt, Blob *pIn){ |
| @@ -319,10 +353,12 @@ | |
| 353 | ** |
| 354 | ** (7) Try the USERNAME environment variable. |
| 355 | ** |
| 356 | ** (8) Check if the user can be extracted from the remote URL. |
| 357 | ** |
| 358 | ** (9) Check if the user was supplied as SSH command-line option. |
| 359 | ** |
| 360 | ** The user name is stored in g.zLogin. The uid is in g.userUid. |
| 361 | */ |
| 362 | void user_select(void){ |
| 363 | if( g.userUid ) return; |
| 364 | if( g.zLogin ){ |
| @@ -345,10 +381,12 @@ | |
| 381 | |
| 382 | if( attempt_user(fossil_getenv("USERNAME")) ) return; |
| 383 | |
| 384 | url_parse(0, 0); |
| 385 | if( g.urlUser && attempt_user(g.urlUser) ) return; |
| 386 | |
| 387 | if( g.zFossilUser && attempt_user(g.zFossilUser) ) return; |
| 388 | |
| 389 | fossil_print( |
| 390 | "Cannot figure out who you are! Consider using the --user\n" |
| 391 | "command line option, setting your USER environment variable,\n" |
| 392 | "or setting a default user with \"fossil user default USER\".\n" |
| 393 |
-1
| --- src/xfer.c | ||
| +++ src/xfer.c | ||
| @@ -1336,11 +1336,10 @@ | ||
| 1336 | 1336 | |
| 1337 | 1337 | if( db_get_boolean("dont-push", 0) ) syncFlags &= ~SYNC_PUSH; |
| 1338 | 1338 | if( (syncFlags & (SYNC_PUSH|SYNC_PULL|SYNC_CLONE))==0 |
| 1339 | 1339 | && configRcvMask==0 && configSendMask==0 ) return 0; |
| 1340 | 1340 | |
| 1341 | - clone_ssh_db_options(); | |
| 1342 | 1341 | transport_stats(0, 0, 1); |
| 1343 | 1342 | socket_global_init(); |
| 1344 | 1343 | memset(&xfer, 0, sizeof(xfer)); |
| 1345 | 1344 | xfer.pIn = &recv; |
| 1346 | 1345 | xfer.pOut = &send; |
| 1347 | 1346 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -1336,11 +1336,10 @@ | |
| 1336 | |
| 1337 | if( db_get_boolean("dont-push", 0) ) syncFlags &= ~SYNC_PUSH; |
| 1338 | if( (syncFlags & (SYNC_PUSH|SYNC_PULL|SYNC_CLONE))==0 |
| 1339 | && configRcvMask==0 && configSendMask==0 ) return 0; |
| 1340 | |
| 1341 | clone_ssh_db_options(); |
| 1342 | transport_stats(0, 0, 1); |
| 1343 | socket_global_init(); |
| 1344 | memset(&xfer, 0, sizeof(xfer)); |
| 1345 | xfer.pIn = &recv; |
| 1346 | xfer.pOut = &send; |
| 1347 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -1336,11 +1336,10 @@ | |
| 1336 | |
| 1337 | if( db_get_boolean("dont-push", 0) ) syncFlags &= ~SYNC_PUSH; |
| 1338 | if( (syncFlags & (SYNC_PUSH|SYNC_PULL|SYNC_CLONE))==0 |
| 1339 | && configRcvMask==0 && configSendMask==0 ) return 0; |
| 1340 | |
| 1341 | transport_stats(0, 0, 1); |
| 1342 | socket_global_init(); |
| 1343 | memset(&xfer, 0, sizeof(xfer)); |
| 1344 | xfer.pIn = &recv; |
| 1345 | xfer.pOut = &send; |
| 1346 |