Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Make it possible to override global setting from command line. Improve sync output when test-http is in use. |
|---|---|
| Timelines: | family | ancestors | descendants | both | ssh-test-http |
| Files: | files | file ages | folders |
| SHA1: |
3c479fb95bc006a77c5eb62b4c8b04cd |
| User & Date: | andybradford 2013-08-10 21:31:40.884 |
Context
|
2013-08-10
| ||
| 23:02 | Clean up handling of global variable to avoid accidental setting of database. Only alter database options if URL is SSH. check-in: 0c19424325 user: andybradford tags: ssh-test-http | |
| 21:31 | Make it possible to override global setting from command line. Improve sync output when test-http is in use. check-in: 3c479fb95b user: andybradford tags: ssh-test-http | |
|
2013-08-09
| ||
| 07:56 | Correct typo that resulted in space being on the wrong side of the word. check-in: 738b505362 user: andybradford tags: ssh-test-http | |
Changes
Changes to src/clone.c.
| ︙ | ︙ | |||
94 95 96 97 98 99 100 | ** Options: ** --admin-user|-A USERNAME Make USERNAME the administrator ** --private Also clone private branches ** --ssl-identity=filename Use the SSL identity if requested by the server ** --ssh-fossil|-f /fossil Use this path as remote fossil command ** --ssh-command|-c 'command' Use this SSH command ** --ssh-fossil-user|-l user Fossil user to use for SSH if different. | | | 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
** Options:
** --admin-user|-A USERNAME Make USERNAME the administrator
** --private Also clone private branches
** --ssl-identity=filename Use the SSL identity if requested by the server
** --ssh-fossil|-f /fossil Use this path as remote fossil command
** --ssh-command|-c 'command' Use this SSH command
** --ssh-fossil-user|-l user Fossil user to use for SSH if different.
** --ssh-use-http|-h on/off Enable http instead of test-http. Default: off
**
** See also: init
*/
void clone_cmd(void){
char *zPassword;
const char *zDefaultUser; /* Optional name of the default user */
int nErr = 0;
|
| ︙ | ︙ | |||
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 |
/*
** Look for SSH clone command line options and setup in globals.
*/
void clone_ssh_find_options(void){
const char *zSshFossilCmd; /* Path to remote fossil command for SSH */
const char *zSshCmd; /* SSH command string */
const char *zFossilUser; /* Fossil user if login specified for SSH */
zSshFossilCmd = find_option("ssh-fossil","f",1);
if( zSshFossilCmd && zSshFossilCmd[0] ){
g.zSshFossilCmd = mprintf("%s", zSshFossilCmd);
}
zSshCmd = find_option("ssh-command","c",1);
if( zSshCmd && zSshCmd[0] ){
g.zSshCmd = mprintf("%s", zSshCmd);
}
zFossilUser = find_option("ssh-fossil-user","l",1);
if( zFossilUser && zFossilUser[0] ){
g.zFossilUser = mprintf("%s", zFossilUser);
}
| > | > > > | | | 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
/*
** Look for SSH clone command line options and setup in globals.
*/
void clone_ssh_find_options(void){
const char *zSshFossilCmd; /* Path to remote fossil command for SSH */
const char *zSshCmd; /* SSH command string */
const char *zFossilUser; /* Fossil user if login specified for SSH */
const char *zSshUseHttp; /* Use http or test-http mode for SSH */
zSshFossilCmd = find_option("ssh-fossil","f",1);
if( zSshFossilCmd && zSshFossilCmd[0] ){
g.zSshFossilCmd = mprintf("%s", zSshFossilCmd);
}
zSshCmd = find_option("ssh-command","c",1);
if( zSshCmd && zSshCmd[0] ){
g.zSshCmd = mprintf("%s", zSshCmd);
}
zFossilUser = find_option("ssh-fossil-user","l",1);
if( zFossilUser && zFossilUser[0] ){
g.zFossilUser = mprintf("%s", zFossilUser);
}
zSshUseHttp = find_option("ssh-use-http","h",1);
if( zSshUseHttp && zSshUseHttp[0] ){
g.zSshUseHttp = mprintf("%s", zSshUseHttp);
}
}
/*
** Set SSH options discovered in global variables (set from command line
** options).
*/
void clone_ssh_db_set_options(void){
if( g.zSshFossilCmd && g.zSshFossilCmd[0] ){
db_set("ssh-fossil", g.zSshFossilCmd, 0);
}
if( g.zSshCmd && g.zSshCmd[0] ){
db_set("ssh-command", g.zSshCmd, 0);
}
if( g.zFossilUser && g.zFossilUser[0] ){
db_set("ssh-fossil-user", g.zFossilUser, 0);
}
if( g.zSshUseHttp && g.zSshUseHttp[0] ){
db_set_int("ssh-use-http", is_truth(g.zSshUseHttp), 0);
}
}
|
Changes to src/http.c.
| ︙ | ︙ | |||
39 40 41 42 43 44 45 | const char *zPw; /* The user password */ Blob pw; /* The nonce with user password appended */ Blob sig; /* The signature field */ zLogin = url_or_fossil_user(); blob_zero(pLogin); if( zLogin==0 || fossil_strcmp(g.urlUser, "anonymous")==0 || | | | 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
const char *zPw; /* The user password */
Blob pw; /* The nonce with user password appended */
Blob sig; /* The signature field */
zLogin = url_or_fossil_user();
blob_zero(pLogin);
if( zLogin==0 || fossil_strcmp(g.urlUser, "anonymous")==0 ||
( g.urlIsSsh && ! url_ssh_use_http() ) ){
return; /* If no login card for users "nobody" and "anonymous" */
}
blob_zero(&nonce);
blob_zero(&pw);
sha1sum_blob(pPayload, &nonce);
blob_copy(&pw, &nonce);
if( g.urlPasswd ){
|
| ︙ | ︙ |
Changes to src/main.c.
| ︙ | ︙ | |||
132 133 134 135 136 137 138 | int fSqlTrace; /* True if --sqltrace flag is present */ int fSqlStats; /* True if --sqltrace or --sqlstats are present */ int fSqlPrint; /* True if -sqlprint flag is present */ int fQuiet; /* True if -quiet flag is present */ int fHttpTrace; /* Trace outbound HTTP requests */ int fSystemTrace; /* Trace calls to fossil_system(), --systemtrace */ int fSshTrace; /* Trace the SSH setup traffic */ | | | 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | int fSqlTrace; /* True if --sqltrace flag is present */ int fSqlStats; /* True if --sqltrace or --sqlstats are present */ int fSqlPrint; /* True if -sqlprint flag is present */ int fQuiet; /* True if -quiet flag is present */ int fHttpTrace; /* Trace outbound HTTP requests */ int fSystemTrace; /* Trace calls to fossil_system(), --systemtrace */ int fSshTrace; /* Trace the SSH setup traffic */ char *zSshUseHttp; /* Use http or test-http mode for SSH */ char *zSshFossilCmd; /* Path to remoe fossil command for SSH */ char *zSshCmd; /* SSH command string */ char *zFossilUser; /* Fossil user if different from URL user */ int fNoSync; /* Do not do an autosync ever. --nosync */ char *zPath; /* Name of webpage being served */ char *zExtra; /* Extra path information past the webpage name */ char *zBaseURL; /* Full text of the URL being served */ |
| ︙ | ︙ | |||
580 581 582 583 584 585 586 |
const char *zChdir = find_option("chdir",0,1);
g.isHTTP = 0;
g.fQuiet = find_option("quiet", 0, 0)!=0;
g.fSqlTrace = find_option("sqltrace", 0, 0)!=0;
g.fSqlStats = find_option("sqlstats", 0, 0)!=0;
g.fSystemTrace = find_option("systemtrace", 0, 0)!=0;
g.fSshTrace = find_option("sshtrace", 0, 0)!=0;
| | | 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 |
const char *zChdir = find_option("chdir",0,1);
g.isHTTP = 0;
g.fQuiet = find_option("quiet", 0, 0)!=0;
g.fSqlTrace = find_option("sqltrace", 0, 0)!=0;
g.fSqlStats = find_option("sqlstats", 0, 0)!=0;
g.fSystemTrace = find_option("systemtrace", 0, 0)!=0;
g.fSshTrace = find_option("sshtrace", 0, 0)!=0;
g.zSshUseHttp = 0;
g.zSshFossilCmd = 0;
g.zSshCmd = 0;
g.zFossilUser = 0;
if( g.fSqlTrace ) g.fSqlStats = 1;
g.fSqlPrint = find_option("sqlprint", 0, 0)!=0;
g.fHttpTrace = find_option("httptrace", 0, 0)!=0;
g.zLogin = find_option("user", "U", 1);
|
| ︙ | ︙ |
Changes to src/sync.c.
| ︙ | ︙ | |||
67 68 69 70 71 72 73 |
** Maybe the shunning list should only be pulled on every 10th
** autosync, or something?
*/
configSync = CONFIGSET_SHUN;
}
#endif
if( find_option("verbose","v",0)!=0 ) flags |= SYNC_VERBOSE;
| | | 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
** Maybe the shunning list should only be pulled on every 10th
** autosync, or something?
*/
configSync = CONFIGSET_SHUN;
}
#endif
if( find_option("verbose","v",0)!=0 ) flags |= SYNC_VERBOSE;
is_fossil_user() && url_ssh_use_http() ?
fossil_print("Autosync: (%s) %s\n", g.zFossilUser, g.urlCanonical) :
fossil_print("Autosync: %s\n", g.urlCanonical);
url_enable_proxy("via proxy: ");
rc = client_sync(flags, configSync, 0);
if( rc ) fossil_warning("Autosync failed");
return rc;
}
|
| ︙ | ︙ | |||
124 125 126 127 128 129 130 |
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) ){
| | | | | 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
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) ){
is_fossil_user() && url_ssh_use_http() ?
fossil_print("Sync with (%s) %s\n", g.zFossilUser, g.urlCanonical) :
fossil_print("Sync with %s\n", g.urlCanonical);
}else if( (*pSyncFlags) & SYNC_PUSH ){
is_fossil_user() && url_ssh_use_http() ?
fossil_print("Push to (%s) %s\n", g.zFossilUser, g.urlCanonical) :
fossil_print("Push to %s\n", g.urlCanonical);
}else if( (*pSyncFlags) & SYNC_PULL ){
is_fossil_user() && url_ssh_use_http() ?
fossil_print("Pull from (%s) %s\n", g.zFossilUser, g.urlCanonical) :
fossil_print("Pull from %s\n", g.urlCanonical);
}
}
url_enable_proxy("via proxy: ");
*pConfigFlags |= configSync;
}
|
| ︙ | ︙ |
Changes to src/url.c.
| ︙ | ︙ | |||
410 411 412 413 414 415 416 |
}
/*
** Prompt the user for the password for g.urlUser. Store the result
** in g.urlPasswd.
*/
void url_prompt_for_password(void){
| | | 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 |
}
/*
** Prompt the user for the password for g.urlUser. Store the result
** in g.urlPasswd.
*/
void url_prompt_for_password(void){
if( g.urlIsFile || ( g.urlIsSsh && ! url_ssh_use_http() ) ) return;
if( isatty(fileno(stdin))
&& (g.urlFlags & URL_PROMPT_PW)!=0
&& (g.urlFlags & URL_PROMPTED)==0
){
g.urlFlags |= URL_PROMPTED;
g.urlPasswd = prompt_for_user_password(url_or_fossil_user());
if( g.urlPasswd[0]
|
| ︙ | ︙ | |||
437 438 439 440 441 442 443 |
}
}
/*
** Return true if http mode is in use for "ssh://" URL.
*/
int url_ssh_use_http(void){
| > | > | | 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 |
}
}
/*
** Return true if http mode is in use for "ssh://" URL.
*/
int url_ssh_use_http(void){
return ( g.zSshUseHttp && g.zSshUseHttp[0] ) ? is_truth(g.zSshUseHttp) :
db_get_boolean("ssh-use-http", 0);
}
/*
** 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){
const char *zFossilUser = url_or_fossil_user();
if( ( zFossilUser && zFossilUser[0] )
&& (g.urlPasswd==0 || g.urlPasswd[0]==0)
&& isatty(fileno(stdin))
){
url_prompt_for_password();
}
}
|