Fossil SCM

Alternative approach to allow multiple SSH users to share the same SSH account while maintaining separate Fossil identities.

amb 2013-07-20 08:40 ssh-transport-changes
Commit e3510cef2310bbfc9e759f20cf0f5bea06e93ccc
--- src/checkin.c
+++ src/checkin.c
@@ -1352,10 +1352,11 @@
13521352
}
13531353
}
13541354
sCiInfo.zDateOvrd = find_option("date-override",0,1);
13551355
sCiInfo.zUserOvrd = find_option("user-override",0,1);
13561356
db_must_be_within_tree();
1357
+ clone_ssh_db_options();
13571358
noSign = db_get_boolean("omitsign", 0)|noSign;
13581359
if( db_get_boolean("clearsign", 0)==0 ){ noSign = 1; }
13591360
useCksum = db_get_boolean("repo-cksum", 1);
13601361
outputManifest = db_get_boolean("manifest", 0);
13611362
verify_all_options();
13621363
--- 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 @@
9595
** --admin-user|-A USERNAME Make USERNAME the administrator
9696
** --private Also clone private branches
9797
** --ssl-identity=filename Use the SSL identity if requested by the server
9898
** --ssh-fossil|-f /fossil Use this path as remote fossil command
9999
** --ssh-command|-c 'command' Use this SSH command
100
+** --ssh-fossil-user|-u user Fossil user to use for SSH if different.
100101
**
101102
** See also: init
102103
*/
103104
void clone_cmd(void){
104105
char *zPassword;
@@ -157,10 +158,11 @@
157158
"REPLACE INTO config(name,value,mtime)"
158159
" VALUES('server-code', lower(hex(randomblob(20))), now());"
159160
);
160161
url_enable_proxy(0);
161162
url_get_password_if_needed();
163
+ clone_ssh_db_options();
162164
g.xlinkClusterOnly = 1;
163165
nErr = client_sync(SYNC_CLONE | bPrivate,CONFIGSET_ALL,0);
164166
g.xlinkClusterOnly = 0;
165167
verify_cancel();
166168
db_end_transaction(0);
@@ -184,18 +186,23 @@
184186
** Look for SSH clone command line options and setup in globals.
185187
*/
186188
void clone_ssh_options(void){
187189
const char *zSshFossilCmd; /* Path to remote fossil command for SSH */
188190
const char *zSshCmd; /* SSH command string */
191
+ const char *zFossilUser; /* Fossil user if login specified for SSH */
189192
190193
zSshFossilCmd = find_option("ssh-fossil","f",1);
191194
if( zSshFossilCmd && zSshFossilCmd[0] ){
192195
g.zSshFossilCmd = mprintf("%s", zSshFossilCmd);
193196
}
194197
zSshCmd = find_option("ssh-command","c",1);
195198
if( zSshCmd && zSshCmd[0] ){
196199
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);
197204
}
198205
}
199206
200207
/*
201208
** Set SSH options discovered in global variables (set from command line
@@ -203,11 +210,16 @@
203210
*/
204211
void clone_ssh_db_options(void){
205212
if( g.zSshFossilCmd && g.zSshFossilCmd[0] ){
206213
db_set("ssh-fossil", g.zSshFossilCmd, 0);
207214
}else{
208
- g.zSshFossilCmd = db_get("ssh-fossil","fossil");
215
+ g.zSshFossilCmd = db_get("ssh-fossil", "fossil");
209216
}
210217
if( g.zSshCmd && g.zSshCmd[0] ){
211218
db_set("ssh-command", g.zSshCmd, 0);
212219
}
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
+ }
213225
}
214226
--- 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
+3
--- src/db.c
+++ src/db.c
@@ -2128,10 +2128,11 @@
21282128
{ "relative-paths",0, 0, 0, "on" },
21292129
{ "repo-cksum", 0, 0, 0, "on" },
21302130
{ "self-register", 0, 0, 0, "off" },
21312131
{ "ssh-command", 0, 40, 0, "" },
21322132
{ "ssh-fossil", 0, 40, 0, "" },
2133
+ { "ssh-fossil-user", 0, 40, 0, "" },
21332134
{ "ssl-ca-location",0, 40, 0, "" },
21342135
{ "ssl-identity", 0, 40, 0, "" },
21352136
#ifdef FOSSIL_ENABLE_TCL
21362137
{ "tcl", 0, 0, 0, "off" },
21372138
{ "tcl-setup", 0, 40, 0, "" },
@@ -2300,10 +2301,12 @@
23002301
**
23012302
** ssh-command Command used to talk to a remote machine with
23022303
** the "ssh://" protocol.
23032304
**
23042305
** 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.
23052308
**
23062309
** ssl-ca-location The full pathname to a file containing PEM encoded
23072310
** CA root certificates, or a directory of certificates
23082311
** with filenames formed from the certificate hashes as
23092312
** required by OpenSSL.
23102313
--- 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 @@
3939
const char *zPw; /* The user password */
4040
Blob pw; /* The nonce with user password appended */
4141
Blob sig; /* The signature field */
4242
4343
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" */
4647
}
4748
blob_zero(&nonce);
4849
blob_zero(&pw);
4950
sha1sum_blob(pPayload, &nonce);
5051
blob_copy(&pw, &nonce);
51
- zLogin = g.urlUser;
52
+ zLogin = url_or_fossil_user();
5253
if( g.urlPasswd ){
5354
zPw = g.urlPasswd;
5455
}else if( g.cgiOutput ){
5556
/* Password failure while doing a sync from the web interface */
5657
cgi_printf("*** incorrect or missing password for user %h\n", zLogin);
@@ -87,11 +88,13 @@
8788
** the complete payload (including the login card) already compressed.
8889
*/
8990
static void http_build_header(Blob *pPayload, Blob *pHdr){
9091
int i;
9192
const char *zSep;
93
+ const char *zLogin;
9294
95
+ zLogin = url_or_fossil_user();
9396
blob_zero(pHdr);
9497
i = strlen(g.urlPath);
9598
if( i>0 && g.urlPath[i-1]=='/' ){
9699
zSep = "";
97100
}else{
@@ -99,12 +102,12 @@
99102
}
100103
blob_appendf(pHdr, "POST %s%sxfer/xfer HTTP/1.0\r\n", g.urlPath, zSep);
101104
if( g.urlProxyAuth ){
102105
blob_appendf(pHdr, "Proxy-Authorization: %s\r\n", g.urlProxyAuth);
103106
}
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]);
106109
char *zEncoded = encode64(zCredentials, -1);
107110
blob_appendf(pHdr, "Authorization: Basic %s\r\n", zEncoded);
108111
fossil_free(zEncoded);
109112
fossil_free(zCredentials);
110113
}
111114
--- 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
--- src/http_transport.c
+++ src/http_transport.c
@@ -123,29 +123,10 @@
123123
}
124124
fossil_force_newline();
125125
fossil_print("%s", blob_str(&zCmd)); /* Show the base of the SSH command */
126126
if( g.urlUser && g.urlUser[0] ){
127127
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
147128
}else{
148129
zHost = mprintf("%s", g.urlName);
149130
}
150131
n = blob_size(&zCmd);
151132
blob_append(&zCmd, " ", 1);
152133
--- 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 @@
136136
int fHttpTrace; /* Trace outbound HTTP requests */
137137
int fSystemTrace; /* Trace calls to fossil_system(), --systemtrace */
138138
int fSshTrace; /* Trace the SSH setup traffic */
139139
char *zSshFossilCmd; /* Path to remoe fossil command for SSH */
140140
char *zSshCmd; /* SSH command string */
141
+ char *zFossilUser; /* Fossil user if different from URL user */
141142
int fNoSync; /* Do not do an autosync ever. --nosync */
142143
char *zPath; /* Name of webpage being served */
143144
char *zExtra; /* Extra path information past the webpage name */
144145
char *zBaseURL; /* Full text of the URL being served */
145146
char *zTop; /* Parent directory of zPath */
@@ -580,10 +581,11 @@
580581
g.fSqlStats = find_option("sqlstats", 0, 0)!=0;
581582
g.fSystemTrace = find_option("systemtrace", 0, 0)!=0;
582583
g.fSshTrace = find_option("sshtrace", 0, 0)!=0;
583584
g.zSshFossilCmd = 0;
584585
g.zSshCmd = 0;
586
+ g.zFossilUser = 0;
585587
if( g.fSqlTrace ) g.fSqlStats = 1;
586588
g.fSqlPrint = find_option("sqlprint", 0, 0)!=0;
587589
g.fHttpTrace = find_option("httptrace", 0, 0)!=0;
588590
g.zLogin = find_option("user", "U", 1);
589591
g.zSSLIdentity = find_option("ssl-identity", 0, 1);
590592
--- 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 @@
4949
}else{
5050
/* Autosync defaults on. To make it default off, "return" here. */
5151
}
5252
url_parse(0, URL_REMEMBER);
5353
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 ){
5555
g.urlPasswd = unobscure(db_get("last-sync-pw", 0));
5656
}
5757
#if 0 /* Disabled for now */
5858
if( (flags & AUTOSYNC_PULL)!=0 && db_get_boolean("auto-shun",1) ){
5959
/* When doing an automatic pull, also automatically pull shuns from
@@ -102,10 +102,11 @@
102102
if( g.argc==2 ){
103103
if( db_get_boolean("auto-shun",1) ) configSync = CONFIGSET_SHUN;
104104
}else if( g.argc==3 ){
105105
zUrl = g.argv[2];
106106
}
107
+ clone_ssh_db_options();
107108
url_parse(zUrl, urlFlags);
108109
if( g.urlProtocol==0 ){
109110
if( urlOptional ) fossil_exit(0);
110111
usage("URL");
111112
}
112113
--- 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 @@
197197
g.urlProtocol = "file";
198198
g.urlPath = "";
199199
g.urlName = mprintf("%b", &cfile);
200200
g.urlCanonical = mprintf("file://%T", g.urlName);
201201
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) ){
203204
url_prompt_for_password();
204205
bPrompted = 1;
205206
}
206207
if( urlFlags & URL_REMEMBER ){
207208
if( bSetUrl ){
208209
db_set("last-sync-url", g.urlCanonical, 0);
209210
}
210
- if( !bPrompted && g.urlPasswd && g.urlUser ){
211
+ if( !bPrompted && g.urlPasswd && ( g.urlUser || g.zFossilUser ) ){
211212
db_set("last-sync-pw", obscure(g.urlPasswd), 0);
212213
}
213214
}
214215
}
215216
@@ -412,35 +413,25 @@
412413
if( g.urlIsFile ) return;
413414
if( isatty(fileno(stdin))
414415
&& (g.urlFlags & URL_PROMPT_PW)!=0
415416
&& (g.urlFlags & URL_PROMPTED)==0
416417
){
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);
424418
g.urlFlags |= URL_PROMPTED;
419
+ g.urlPasswd = prompt_for_user_password(url_or_fossil_user());
425420
if( g.urlPasswd[0]
426421
&& (g.urlFlags & (URL_REMEMBER|URL_ASK_REMEMBER_PW))!=0
427422
){
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() ){
433424
g.urlFlags |= URL_REMEMBER_PW;
434425
if( g.urlFlags & URL_REMEMBER ){
435426
db_set("last-sync-pw", obscure(g.urlPasswd), 0);
436427
}
437428
}
438429
}
439430
}else{
440431
fossil_fatal("missing or incorrect password for user \"%s\"",
441
- g.urlUser);
432
+ url_or_fossil_user() );
442433
}
443434
}
444435
445436
/*
446437
** Remember the URL if requested.
447438
--- 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 @@
128128
break;
129129
}
130130
}
131131
blob_reset(&secondTry);
132132
}
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
+}
133167
134168
/*
135169
** Prompt the user to enter a single line of text.
136170
*/
137171
void prompt_user(const char *zPrompt, Blob *pIn){
@@ -319,10 +353,12 @@
319353
**
320354
** (7) Try the USERNAME environment variable.
321355
**
322356
** (8) Check if the user can be extracted from the remote URL.
323357
**
358
+** (9) Check if the user was supplied as SSH command-line option.
359
+**
324360
** The user name is stored in g.zLogin. The uid is in g.userUid.
325361
*/
326362
void user_select(void){
327363
if( g.userUid ) return;
328364
if( g.zLogin ){
@@ -345,10 +381,12 @@
345381
346382
if( attempt_user(fossil_getenv("USERNAME")) ) return;
347383
348384
url_parse(0, 0);
349385
if( g.urlUser && attempt_user(g.urlUser) ) return;
386
+
387
+ if( g.zFossilUser && attempt_user(g.zFossilUser) ) return;
350388
351389
fossil_print(
352390
"Cannot figure out who you are! Consider using the --user\n"
353391
"command line option, setting your USER environment variable,\n"
354392
"or setting a default user with \"fossil user default USER\".\n"
355393
--- 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 @@
13361336
13371337
if( db_get_boolean("dont-push", 0) ) syncFlags &= ~SYNC_PUSH;
13381338
if( (syncFlags & (SYNC_PUSH|SYNC_PULL|SYNC_CLONE))==0
13391339
&& configRcvMask==0 && configSendMask==0 ) return 0;
13401340
1341
- clone_ssh_db_options();
13421341
transport_stats(0, 0, 1);
13431342
socket_global_init();
13441343
memset(&xfer, 0, sizeof(xfer));
13451344
xfer.pIn = &recv;
13461345
xfer.pOut = &send;
13471346
--- 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

Keyboard Shortcuts

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