Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Improved handling for remote repository passwords: When prompting for the password, also ask the user whether or not to remember the password, as browsers typically do for their password cache. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
6d6740dcca7d1b4cb6897e57f7a3a6fd |
| User & Date: | drh 2013-02-21 03:51:10.979 |
Context
|
2013-02-21
| ||
| 08:15 | unused variables ... (check-in: 75e483899e user: jan.nijtmans tags: trunk) | |
| 03:51 | Improved handling for remote repository passwords: When prompting for the password, also ask the user whether or not to remember the password, as browsers typically do for their password cache. ... (check-in: 6d6740dcca user: drh tags: trunk) | |
|
2013-02-20
| ||
| 22:18 | Avoid intermingling error message with status output during a sync. Error messages should appear on a line by themselves. ... (check-in: 2981ac51ff user: drh tags: trunk) | |
Changes
Changes to src/clone.c.
| ︙ | ︙ | |||
113 114 115 116 117 118 119 |
db_open_config(0);
if( file_size(g.argv[3])>0 ){
fossil_panic("file already exists: %s", g.argv[3]);
}
zDefaultUser = find_option("admin-user","A",1);
| | < < < < < < | | | 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
db_open_config(0);
if( file_size(g.argv[3])>0 ){
fossil_panic("file already exists: %s", g.argv[3]);
}
zDefaultUser = find_option("admin-user","A",1);
url_parse(g.argv[2], URL_PROMPT_PW|URL_ASK_REMEMBER_PW);
if( g.urlIsFile ){
file_copy(g.urlName, g.argv[3]);
db_close(1);
db_open_repository(g.argv[3]);
db_record_repository_filename(g.argv[3]);
url_remember();
if( !bPrivate ) delete_private_content();
shun_artifacts();
db_create_default_users(1, zDefaultUser);
if( zDefaultUser ){
g.zLogin = zDefaultUser;
}else{
g.zLogin = db_text(0, "SELECT login FROM user WHERE cap LIKE '%%s%%'");
}
fossil_print("Repository cloned into %s\n", g.argv[3]);
}else{
db_create_repository(g.argv[3]);
db_open_repository(g.argv[3]);
db_begin_transaction();
db_record_repository_filename(g.argv[3]);
db_initial_setup(0, 0, zDefaultUser, 0);
user_select();
db_set("content-schema", CONTENT_SCHEMA, 0);
db_set("aux-schema", AUX_SCHEMA, 0);
url_remember();
if( g.zSSLIdentity!=0 ){
/* If the --ssl-identity option was specified, store it as a setting */
Blob fn;
blob_zero(&fn);
file_canonical_name(g.zSSLIdentity, &fn, 0);
db_set("ssl-identity", blob_str(&fn), 0);
blob_reset(&fn);
|
| ︙ | ︙ | |||
175 176 177 178 179 180 181 |
}
db_open_repository(g.argv[3]);
}
db_begin_transaction();
fossil_print("Rebuilding repository meta-data...\n");
rebuild_db(0, 1, 0);
fossil_print("project-id: %s\n", db_get("project-code", 0));
| < < < | 169 170 171 172 173 174 175 176 177 178 179 |
}
db_open_repository(g.argv[3]);
}
db_begin_transaction();
fossil_print("Rebuilding repository meta-data...\n");
rebuild_db(0, 1, 0);
fossil_print("project-id: %s\n", db_get("project-code", 0));
zPassword = db_text(0, "SELECT pw FROM user WHERE login=%Q", g.zLogin);
fossil_print("admin-user: %s (password is \"%s\")\n", g.zLogin, zPassword);
db_end_transaction(0);
}
|
Changes to src/configure.c.
| ︙ | ︙ | |||
876 877 878 879 880 881 882 |
db_end_transaction(0);
}else
if( strncmp(zMethod, "pull", n)==0
|| strncmp(zMethod, "push", n)==0
|| strncmp(zMethod, "sync", n)==0
){
int mask;
| | > < < < < < < | < < | | | 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 |
db_end_transaction(0);
}else
if( strncmp(zMethod, "pull", n)==0
|| strncmp(zMethod, "push", n)==0
|| strncmp(zMethod, "sync", n)==0
){
int mask;
const char *zServer = 0;
const char *zPw;
int legacyFlag = 0;
int overwriteFlag = 0;
if( zMethod[0]!='s' ) legacyFlag = find_option("legacy",0,0)!=0;
if( strncmp(zMethod,"pull",n)==0 ){
overwriteFlag = find_option("overwrite",0,0)!=0;
}
url_proxy_options();
if( g.argc!=4 && g.argc!=5 ){
usage("pull AREA ?URL?");
}
mask = configure_name_to_mask(g.argv[3], 1);
if( g.argc==5 ){
zServer = g.argv[4];
}
url_parse(zServer, URL_PROMPT_PW);
if( g.urlProtocol==0 ) fossil_fatal("no server URL specified");
user_select();
url_enable_proxy("via proxy: ");
if( legacyFlag ) mask |= CONFIGSET_OLDFORMAT;
if( overwriteFlag ) mask |= CONFIGSET_OVERWRITE;
if( strncmp(zMethod, "push", n)==0 ){
client_sync(0,0,(unsigned)mask);
}else if( strncmp(zMethod, "pull", n)==0 ){
|
| ︙ | ︙ |
Changes to src/http.c.
| ︙ | ︙ | |||
58 59 60 61 62 63 64 |
/* Password failure while doing a sync from the web interface */
cgi_printf("*** incorrect or missing password for user %h\n", zLogin);
zPw = 0;
}else{
/* Password failure while doing a sync from the command-line interface */
url_prompt_for_password();
zPw = g.urlPasswd;
| < > | 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
/* Password failure while doing a sync from the web interface */
cgi_printf("*** incorrect or missing password for user %h\n", zLogin);
zPw = 0;
}else{
/* Password failure while doing a sync from the command-line interface */
url_prompt_for_password();
zPw = g.urlPasswd;
}
/* If the first character of the password is "#", then that character is
** not really part of the password - it is an indicator that we should
** use Basic Authentication. So skip that character.
*/
if( zPw && zPw[0]=='#' ) zPw++;
/* The login card wants the SHA1 hash of the password, so convert the
** password to its SHA1 hash it it isn't already a SHA1 hash.
*/
/* fossil_print("\nzPw=[%s]\n", zPw); // TESTING ONLY */
if( zPw && zPw[0] ) zPw = sha1_shared_secret(zPw, zLogin, 0);
blob_append(&pw, zPw, -1);
sha1sum_blob(&pw, &sig);
blob_appendf(pLogin, "login %F %b %b\n", zLogin, &nonce, &sig);
blob_reset(&pw);
blob_reset(&sig);
|
| ︙ | ︙ | |||
241 242 243 244 245 246 247 |
if( zLine[i]==0 ) fossil_fatal("malformed redirect: %s", zLine);
j = strlen(zLine) - 1;
while( j>4 && fossil_strcmp(&zLine[j-4],"/xfer")==0 ){
j -= 4;
zLine[j] = 0;
}
fossil_print("redirect to %s\n", &zLine[i]);
| | | 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 |
if( zLine[i]==0 ) fossil_fatal("malformed redirect: %s", zLine);
j = strlen(zLine) - 1;
while( j>4 && fossil_strcmp(&zLine[j-4],"/xfer")==0 ){
j -= 4;
zLine[j] = 0;
}
fossil_print("redirect to %s\n", &zLine[i]);
url_parse(&zLine[i], 0);
transport_close();
return http_exchange(pSend, pReply, useLogin, maxRedirect);
}else if( fossil_strnicmp(zLine, "content-type: ", 14)==0 ){
if( fossil_strnicmp(&zLine[14], "application/x-fossil-debug", -1)==0 ){
isCompressed = 0;
}else if( fossil_strnicmp(&zLine[14],
"application/x-fossil-uncompressed", -1)==0 ){
|
| ︙ | ︙ |
Changes to src/main.c.
| ︙ | ︙ | |||
170 171 172 173 174 175 176 | char *urlPath; /* Pathname for http: */ char *urlUser; /* User id for http: */ char *urlPasswd; /* Password for http: */ char *urlCanonical; /* Canonical representation of the URL */ char *urlProxyAuth; /* Proxy-Authorizer: string */ char *urlFossil; /* The fossil query parameter on ssh: */ char *urlShell; /* The shell query parameter on ssh: */ | | | 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
char *urlPath; /* Pathname for http: */
char *urlUser; /* User id for http: */
char *urlPasswd; /* Password for http: */
char *urlCanonical; /* Canonical representation of the URL */
char *urlProxyAuth; /* Proxy-Authorizer: string */
char *urlFossil; /* The fossil query parameter on ssh: */
char *urlShell; /* The shell query parameter on ssh: */
unsigned urlFlags; /* Boolean flags controlling URL processing */
const char *zLogin; /* Login name. "" if not logged in. */
const char *zSSLIdentity; /* Value of --ssl-identity option, filename of
** SSL client identity */
int useLocalauth; /* No login required if from 127.0.0.1 */
int noPswd; /* Logged in without password (on 127.0.0.1) */
int userUid; /* Integer user id */
|
| ︙ | ︙ |
Changes to src/sync.c.
| ︙ | ︙ | |||
25 26 27 28 29 30 31 |
** If the repository is configured for autosyncing, then do an
** autosync. This will be a pull if the argument is true or a push
** if the argument is false.
**
** Return the number of errors.
*/
int autosync(int flags){
| < | 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
** If the repository is configured for autosyncing, then do an
** autosync. This will be a pull if the argument is true or a push
** if the argument is false.
**
** Return the number of errors.
*/
int autosync(int flags){
const char *zAutosync;
const char *zPw;
int rc;
int configSync = 0; /* configuration changes transferred */
if( g.fNoSync ){
return 0;
}
|
| ︙ | ︙ | |||
47 48 49 50 51 52 53 |
}
if( is_false(zAutosync) ){
return 0; /* Autosync is completely off */
}
}else{
/* Autosync defaults on. To make it default off, "return" here. */
}
| < < < < < | > | | 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
}
if( is_false(zAutosync) ){
return 0; /* Autosync is completely off */
}
}else{
/* Autosync defaults on. To make it default off, "return" here. */
}
url_parse(0, URL_REMEMBER);
if( g.urlProtocol==0 ) return 0;
if( g.urlUser!=0 && g.urlPasswd==0 ){
g.urlPasswd = unobscure(db_get("last-sync-pw", 0));
}
#if 0 /* Disabled for now */
if( (flags & AUTOSYNC_PULL)!=0 && db_get_boolean("auto-shun",1) ){
/* When doing an automatic pull, also automatically pull shuns from
** the server if pull_shuns is enabled.
**
** TODO: What happens if the shun list gets really big?
|
| ︙ | ︙ | |||
86 87 88 89 90 91 92 93 |
** of a server to sync against. If no argument is given, use the
** most recently synced URL. Remember the current URL for next time.
*/
static void process_sync_args(unsigned *pConfigFlags, unsigned *pSyncFlags){
const char *zUrl = 0;
const char *zPw = 0;
unsigned configSync = 0;
int urlOptional = find_option("autourl",0,0)!=0;
| > | < < > | < < < < < < < < < < < < | 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
** of a server to sync against. If no argument is given, use the
** most recently synced URL. Remember the current URL for next time.
*/
static void process_sync_args(unsigned *pConfigFlags, unsigned *pSyncFlags){
const char *zUrl = 0;
const char *zPw = 0;
unsigned configSync = 0;
unsigned urlFlags = URL_REMEMBER | URL_PROMPT_PW;
int urlOptional = find_option("autourl",0,0)!=0;
if( find_option("once",0,0)!=0 ) urlFlags &= ~URL_REMEMBER;
if( find_option("private",0,0)!=0 ){
*pSyncFlags |= SYNC_PRIVATE;
}
if( find_option("verbose","v",0)!=0 ){
*pSyncFlags |= SYNC_VERBOSE;
}
url_proxy_options();
db_find_and_open_repository(0, 0);
db_open_config(0);
if( g.argc==2 ){
if( db_get_boolean("auto-shun",1) ) configSync = CONFIGSET_SHUN;
}else if( g.argc==3 ){
zUrl = g.argv[2];
}
url_parse(zUrl, urlFlags);
if( g.urlProtocol==0 ){
if( urlOptional ) fossil_exit(0);
usage("URL");
}
user_select();
if( g.argc==2 ){
if( ((*pSyncFlags) & (SYNC_PUSH|SYNC_PULL))==(SYNC_PUSH|SYNC_PULL) ){
fossil_print("Sync with %s\n", g.urlCanonical);
}else if( (*pSyncFlags) & SYNC_PUSH ){
fossil_print("Push to %s\n", g.urlCanonical);
}else if( (*pSyncFlags) & SYNC_PULL ){
|
| ︙ | ︙ | |||
256 257 258 259 260 261 262 |
void remote_url_cmd(void){
char *zUrl;
db_find_and_open_repository(0, 0);
if( g.argc!=2 && g.argc!=3 ){
usage("remote-url ?URL|off?");
}
if( g.argc==3 ){
| < | | < | < < < < < < < < < < | | 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 |
void remote_url_cmd(void){
char *zUrl;
db_find_and_open_repository(0, 0);
if( g.argc!=2 && g.argc!=3 ){
usage("remote-url ?URL|off?");
}
if( g.argc==3 ){
db_unset("last-sync-url", 0);
db_unset("last-sync-pw", 0);
url_parse(g.argv[2], URL_REMEMBER|URL_PROMPT_PW);
}
zUrl = db_get("last-sync-url", 0);
if( zUrl==0 ){
fossil_print("off\n");
return;
}else{
url_parse(zUrl, 0);
fossil_print("%s\n", g.urlCanonical);
}
}
|
Changes to src/url.c.
| ︙ | ︙ | |||
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
**
*******************************************************************************
**
** This file contains code for parsing URLs that appear on the command-line
*/
#include "config.h"
#include "url.h"
/*
** Convert a string to lower-case.
*/
static void url_tolower(char *z){
while( *z ){
*z = fossil_tolower(*z);
z++;
}
}
/*
| > > > > > > > > > > > > > | | | > > > > > > > > > > | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
**
*******************************************************************************
**
** This file contains code for parsing URLs that appear on the command-line
*/
#include "config.h"
#include "url.h"
#if INTERFACE
/*
** Flags for url_parse()
*/
#define URL_PROMPT_PW 0x001 /* Prompt for password if needed */
#define URL_REMEMBER 0x002 /* Remember the url for later reuse */
#define URL_ASK_REMEMBER_PW 0x004 /* Ask whether to remember prompted pw */
#define URL_REMEMBER_PW 0x008 /* Should remember pw */
#endif /* INTERFACE */
/*
** Convert a string to lower-case.
*/
static void url_tolower(char *z){
while( *z ){
*z = fossil_tolower(*z);
z++;
}
}
/*
** Parse the given URL, which describes a sync server. Populate variables
** in the global "g" structure as follows:
**
** g.urlIsFile True if FILE:
** g.urlIsHttps True if HTTPS:
** g.urlIsSsh True if SSH:
** g.urlProtocol "http" or "https" or "file"
** g.urlName Hostname for HTTP:, HTTPS:, SSH:. Filename for FILE:
** g.urlPort TCP port number for HTTP or HTTPS.
** g.urlDfltPort Default TCP port number (80 or 443).
** g.urlPath Path name for HTTP or HTTPS.
** g.urlUser Userid.
** g.urlPasswd Password.
** g.urlHostname HOST:PORT or just HOST if port is the default.
** g.urlCanonical The URL in canonical form, omitting the password
**
** HTTP url format as follows (HTTPS is the same with a different scheme):
**
** http://userid:password@host:port/path
**
** SSH url format is:
**
** ssh://userid:password@host:port/path?fossil=path/to/fossil.exe
**
*/
void url_parse(const char *zUrl, unsigned int urlFlags){
int i, j, c;
char *zFile = 0;
int bPrompted = 0;
int bSetUrl = 1;
if( zUrl==0 ){
zUrl = db_get("last-sync-url", 0);
if( zUrl==0 ) return;
g.urlPasswd = unobscure(db_get("last-sync-pw", 0));
bSetUrl = 0;
}
if( strncmp(zUrl, "http://", 7)==0
|| strncmp(zUrl, "https://", 8)==0
|| strncmp(zUrl, "ssh://", 6)==0
){
int iStart;
char *zLogin;
char *zExe;
|
| ︙ | ︙ | |||
186 187 188 189 190 191 192 |
zFile = mprintf("%s", zUrl);
}else if( file_isdir(zUrl)==1 ){
zFile = mprintf("%s/FOSSIL", zUrl);
if( file_isfile(zFile) ){
g.urlIsFile = 1;
}else{
free(zFile);
| | | > > > > > > > > > > > > > > > > > > > > > > > | > | 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 |
zFile = mprintf("%s", zUrl);
}else if( file_isdir(zUrl)==1 ){
zFile = mprintf("%s/FOSSIL", zUrl);
if( file_isfile(zFile) ){
g.urlIsFile = 1;
}else{
free(zFile);
fossil_fatal("unknown repository: %s", zUrl);
}
}else{
fossil_fatal("unknown repository: %s", zUrl);
}
g.urlFlags = urlFlags;
if( g.urlIsFile ){
Blob cfile;
dehttpize(zFile);
file_canonical_name(zFile, &cfile, 0);
free(zFile);
g.urlProtocol = "file";
g.urlPath = "";
g.urlName = mprintf("%b", &cfile);
g.urlCanonical = mprintf("file://%T", g.urlName);
blob_reset(&cfile);
}else if( g.urlUser!=0 && g.urlPasswd==0 && (urlFlags & URL_PROMPT_PW) ){
url_prompt_for_password();
bPrompted = 1;
}
if( urlFlags & URL_REMEMBER ){
if( bSetUrl ){
db_set("last-sync-url", g.urlCanonical, 0);
}
if( !bPrompted && g.urlPasswd && g.urlUser ){
db_set("last-sync-pw", obscure(g.urlPasswd), 0);
}
}
}
/*
** COMMAND: test-urlparser
**
** Usage: %fossil test-urlparser URL ?options?
**
** --remember Store results in last-sync-url
** --prompt-pw Prompt for password if missing
*/
void cmd_test_urlparser(void){
int i;
unsigned fg = 0;
url_proxy_options();
if( find_option("remember",0,0) ){
db_must_be_within_tree();
fg |= URL_REMEMBER;
}
if( find_option("prompt-pw",0,0) ) fg |= URL_PROMPT_PW;
if( g.argc!=3 && g.argc!=4 ){
usage("URL");
}
url_parse(g.argv[2], fg);
for(i=0; i<2; i++){
fossil_print("g.urlIsFile = %d\n", g.urlIsFile);
fossil_print("g.urlIsHttps = %d\n", g.urlIsHttps);
fossil_print("g.urlIsSsh = %d\n", g.urlIsSsh);
fossil_print("g.urlProtocol = %s\n", g.urlProtocol);
fossil_print("g.urlName = %s\n", g.urlName);
fossil_print("g.urlPort = %d\n", g.urlPort);
fossil_print("g.urlDfltPort = %d\n", g.urlDfltPort);
fossil_print("g.urlHostname = %s\n", g.urlHostname);
fossil_print("g.urlPath = %s\n", g.urlPath);
fossil_print("g.urlUser = %s\n", g.urlUser);
fossil_print("g.urlPasswd = %s\n", g.urlPasswd);
fossil_print("g.urlCanonical = %s\n", g.urlCanonical);
fossil_print("g.urlFossil = %s\n", g.urlFossil);
fossil_print("g.urlFlags = 0x%02x\n", g.urlFlags);
if( g.urlIsFile || g.urlIsSsh ) break;
if( i==0 ){
fossil_print("********\n");
url_enable_proxy("Using proxy: ");
}
}
}
|
| ︙ | ︙ | |||
280 281 282 283 284 285 286 287 288 |
}
}
if( zProxy && zProxy[0] && !is_false(zProxy) ){
char *zOriginalUrl = g.urlCanonical;
char *zOriginalHost = g.urlHostname;
char *zOriginalUser = g.urlUser;
char *zOriginalPasswd = g.urlPasswd;
g.urlUser = 0;
g.urlPasswd = "";
| > | > | 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 |
}
}
if( zProxy && zProxy[0] && !is_false(zProxy) ){
char *zOriginalUrl = g.urlCanonical;
char *zOriginalHost = g.urlHostname;
char *zOriginalUser = g.urlUser;
char *zOriginalPasswd = g.urlPasswd;
unsigned uOriginalFlags = g.urlFlags;
g.urlUser = 0;
g.urlPasswd = "";
url_parse(zProxy, 0);
if( zMsg ) fossil_print("%s%s\n", zMsg, g.urlCanonical);
g.urlPath = zOriginalUrl;
g.urlHostname = zOriginalHost;
if( g.urlUser ){
char *zCredentials1 = mprintf("%s:%s", g.urlUser, g.urlPasswd);
char *zCredentials2 = encode64(zCredentials1, -1);
g.urlProxyAuth = mprintf("Basic %z", zCredentials2);
free(zCredentials1);
}
g.urlUser = zOriginalUser;
g.urlPasswd = zOriginalPasswd;
g.urlFlags = uOriginalFlags;
}
}
#if INTERFACE
/*
** An instance of this object is used to build a URL with query parameters.
*/
|
| ︙ | ︙ | |||
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 |
** Prompt the user for the password for g.urlUser. Store the result
** in g.urlPasswd.
*/
void url_prompt_for_password(void){
if( isatty(fileno(stdin)) ){
char *zPrompt = mprintf("\rpassword for %s: ", g.urlUser);
Blob x;
prompt_for_password(zPrompt, &x, 0);
free(zPrompt);
g.urlPasswd = mprintf("%b", &x);
blob_reset(&x);
}else{
fossil_fatal("missing or incorrect password for user \"%s\"",
g.urlUser);
}
}
/* Preemptively prompt for a password if a username is given in the
** URL but no password.
*/
void url_get_password_if_needed(void){
if( (g.urlUser && g.urlUser[0])
&& (g.urlPasswd==0 || g.urlPasswd[0]==0)
&& isatty(fileno(stdin))
&& g.urlIsSsh==0
){
url_prompt_for_password();
}
}
| > > > > > > > > > > > > > > > > > > > > > > > > > > | 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 |
** Prompt the user for the password for g.urlUser. Store the result
** in g.urlPasswd.
*/
void url_prompt_for_password(void){
if( isatty(fileno(stdin)) ){
char *zPrompt = mprintf("\rpassword for %s: ", g.urlUser);
Blob x;
fossil_force_newline();
prompt_for_password(zPrompt, &x, 0);
free(zPrompt);
g.urlPasswd = mprintf("%b", &x);
blob_reset(&x);
if( g.urlPasswd[0]
&& (g.urlFlags & (URL_REMEMBER|URL_ASK_REMEMBER_PW))!=0
){
char c;
prompt_user("remember password (Y/n)? ", &x);
c = blob_str(&x)[0];
blob_reset(&x);
if( c!='n' && c!='N' ){
g.urlFlags |= URL_REMEMBER_PW;
if( g.urlFlags & URL_REMEMBER ){
db_set("last-sync-pw", obscure(g.urlPasswd), 0);
}
}
}
}else{
fossil_fatal("missing or incorrect password for user \"%s\"",
g.urlUser);
}
}
/*
** Remember the URL if requested.
*/
void url_remember(void){
db_set("last-sync-url", g.urlCanonical, 0);
if( g.urlFlags & URL_REMEMBER_PW ){
db_set("last-sync-pw", obscure(g.urlPasswd), 0);
}
g.urlFlags = URL_REMEMBER;
}
/* Preemptively prompt for a password if a username is given in the
** URL but no password.
*/
void url_get_password_if_needed(void){
if( (g.urlUser && g.urlUser[0])
&& (g.urlPasswd==0 || g.urlPasswd[0]==0)
&& isatty(fileno(stdin))
&& g.urlIsSsh==0
){
url_prompt_for_password();
}
}
|
Changes to src/user.c.
| ︙ | ︙ | |||
333 334 335 336 337 338 339 |
if( attempt_user(fossil_getenv("FOSSIL_USER")) ) return;
if( attempt_user(fossil_getenv("USER")) ) return;
if( attempt_user(fossil_getenv("USERNAME")) ) return;
| < < | | < | 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 |
if( attempt_user(fossil_getenv("FOSSIL_USER")) ) return;
if( attempt_user(fossil_getenv("USER")) ) return;
if( attempt_user(fossil_getenv("USERNAME")) ) return;
url_parse(0, 0);
if( g.urlUser && attempt_user(g.urlUser) ) return;
fossil_print(
"Cannot figure out who you are! Consider using the --user\n"
"command line option, setting your USER environment variable,\n"
"or setting a default user with \"fossil user default USER\".\n"
);
fossil_fatal("cannot determine user");
|
| ︙ | ︙ |
Changes to src/xfer.c.
| ︙ | ︙ | |||
1736 1737 1738 1739 1740 1741 1742 1743 1744 |
** subsequent messages should be OK. Nevertheless, we need to ignore
** the error card on the first message of a clone.
*/
if( blob_eq(&xfer.aToken[0],"error") && xfer.nToken==2 ){
if( (syncFlags & SYNC_CLONE)==0 || nCycle>0 ){
char *zMsg = blob_terminate(&xfer.aToken[1]);
defossilize(zMsg);
if( fossil_strcmp(zMsg, "login failed")==0 ){
if( nCycle<2 ){
| > > < > > < < < | > | 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 |
** subsequent messages should be OK. Nevertheless, we need to ignore
** the error card on the first message of a clone.
*/
if( blob_eq(&xfer.aToken[0],"error") && xfer.nToken==2 ){
if( (syncFlags & SYNC_CLONE)==0 || nCycle>0 ){
char *zMsg = blob_terminate(&xfer.aToken[1]);
defossilize(zMsg);
fossil_force_newline();
fossil_print("Error: %s\n", zMsg);
if( fossil_strcmp(zMsg, "login failed")==0 ){
if( nCycle<2 ){
g.urlPasswd = 0;
go = 1;
if( g.cgiOutput==0 ) url_prompt_for_password();
}
}else{
blob_appendf(&xfer.err, "server says: %s\n", zMsg);
nErr++;
}
break;
}
}else
/* Unknown message */
if( xfer.nToken>0 ){
if( blob_str(&xfer.aToken[0])[0]=='<' ){
|
| ︙ | ︙ |