Fossil SCM

Much needed cleanup of command-line option handling. Improve sync handling of SSH user. Bring in change for less verbose SSH output.

amb 2013-07-24 06:25 ssh-shared-account merge
Commit 955b39ee9f36f4a7212dc00c5656da8946717473
--- src/checkin.c
+++ src/checkin.c
@@ -1352,11 +1352,10 @@
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();
13581357
noSign = db_get_boolean("omitsign", 0)|noSign;
13591358
if( db_get_boolean("clearsign", 0)==0 ){ noSign = 1; }
13601359
useCksum = db_get_boolean("repo-cksum", 1);
13611360
outputManifest = db_get_boolean("manifest", 0);
13621361
verify_all_options();
13631362
--- src/checkin.c
+++ src/checkin.c
@@ -1352,11 +1352,10 @@
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
--- src/checkin.c
+++ src/checkin.c
@@ -1352,11 +1352,10 @@
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
+4 -8
--- src/clone.c
+++ src/clone.c
@@ -106,11 +106,11 @@
106106
const char *zDefaultUser; /* Optional name of the default user */
107107
int nErr = 0;
108108
int bPrivate = 0; /* Also clone private branches */
109109
110110
if( find_option("private",0,0)!=0 ) bPrivate = SYNC_PRIVATE;
111
- clone_ssh_options();
111
+ clone_ssh_find_options();
112112
url_proxy_options();
113113
if( g.argc < 4 ){
114114
usage("?OPTIONS? FILE-OR-URL NEW-REPOSITORY");
115115
}
116116
db_open_config(0);
@@ -158,11 +158,11 @@
158158
"REPLACE INTO config(name,value,mtime)"
159159
" VALUES('server-code', lower(hex(randomblob(20))), now());"
160160
);
161161
url_enable_proxy(0);
162162
url_get_password_if_needed();
163
- clone_ssh_db_options();
163
+ clone_ssh_db_set_options();
164164
g.xlinkClusterOnly = 1;
165165
nErr = client_sync(SYNC_CLONE | bPrivate,CONFIGSET_ALL,0);
166166
g.xlinkClusterOnly = 0;
167167
verify_cancel();
168168
db_end_transaction(0);
@@ -183,11 +183,11 @@
183183
}
184184
185185
/*
186186
** Look for SSH clone command line options and setup in globals.
187187
*/
188
-void clone_ssh_options(void){
188
+void clone_ssh_find_options(void){
189189
const char *zSshFossilCmd; /* Path to remote fossil command for SSH */
190190
const char *zSshCmd; /* SSH command string */
191191
const char *zFossilUser; /* Fossil user if login specified for SSH */
192192
193193
zSshFossilCmd = find_option("ssh-fossil","f",1);
@@ -206,20 +206,16 @@
206206
207207
/*
208208
** Set SSH options discovered in global variables (set from command line
209209
** options). If not found, attempt to retrieve from database if present.
210210
*/
211
-void clone_ssh_db_options(void){
211
+void clone_ssh_db_set_options(void){
212212
if( g.zSshFossilCmd && g.zSshFossilCmd[0] ){
213213
db_set("ssh-fossil", g.zSshFossilCmd, 0);
214
- }else{
215
- g.zSshFossilCmd = db_get("ssh-fossil", "fossil");
216214
}
217215
if( g.zSshCmd && g.zSshCmd[0] ){
218216
db_set("ssh-command", g.zSshCmd, 0);
219217
}
220218
if( g.zFossilUser && g.zFossilUser[0] ){
221219
db_set("ssh-fossil-user", g.zFossilUser, 0);
222
- }else{
223
- g.zFossilUser = db_get("ssh-fossil-user", 0);
224220
}
225221
}
226222
--- src/clone.c
+++ src/clone.c
@@ -106,11 +106,11 @@
106 const char *zDefaultUser; /* Optional name of the default user */
107 int nErr = 0;
108 int bPrivate = 0; /* Also clone private branches */
109
110 if( find_option("private",0,0)!=0 ) bPrivate = SYNC_PRIVATE;
111 clone_ssh_options();
112 url_proxy_options();
113 if( g.argc < 4 ){
114 usage("?OPTIONS? FILE-OR-URL NEW-REPOSITORY");
115 }
116 db_open_config(0);
@@ -158,11 +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);
@@ -183,11 +183,11 @@
183 }
184
185 /*
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);
@@ -206,20 +206,16 @@
206
207 /*
208 ** Set SSH options discovered in global variables (set from command line
209 ** options). If not found, attempt to retrieve from database if present.
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
--- src/clone.c
+++ src/clone.c
@@ -106,11 +106,11 @@
106 const char *zDefaultUser; /* Optional name of the default user */
107 int nErr = 0;
108 int bPrivate = 0; /* Also clone private branches */
109
110 if( find_option("private",0,0)!=0 ) bPrivate = SYNC_PRIVATE;
111 clone_ssh_find_options();
112 url_proxy_options();
113 if( g.argc < 4 ){
114 usage("?OPTIONS? FILE-OR-URL NEW-REPOSITORY");
115 }
116 db_open_config(0);
@@ -158,11 +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_set_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);
@@ -183,11 +183,11 @@
183 }
184
185 /*
186 ** Look for SSH clone command line options and setup in globals.
187 */
188 void clone_ssh_find_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);
@@ -206,20 +206,16 @@
206
207 /*
208 ** Set SSH options discovered in global variables (set from command line
209 ** options). If not found, attempt to retrieve from database if present.
210 */
211 void clone_ssh_db_set_options(void){
212 if( g.zSshFossilCmd && g.zSshFossilCmd[0] ){
213 db_set("ssh-fossil", g.zSshFossilCmd, 0);
 
 
214 }
215 if( g.zSshCmd && g.zSshCmd[0] ){
216 db_set("ssh-command", g.zSshCmd, 0);
217 }
218 if( g.zFossilUser && g.zFossilUser[0] ){
219 db_set("ssh-fossil-user", g.zFossilUser, 0);
 
 
220 }
221 }
222
+4 -8
--- src/clone.c
+++ src/clone.c
@@ -106,11 +106,11 @@
106106
const char *zDefaultUser; /* Optional name of the default user */
107107
int nErr = 0;
108108
int bPrivate = 0; /* Also clone private branches */
109109
110110
if( find_option("private",0,0)!=0 ) bPrivate = SYNC_PRIVATE;
111
- clone_ssh_options();
111
+ clone_ssh_find_options();
112112
url_proxy_options();
113113
if( g.argc < 4 ){
114114
usage("?OPTIONS? FILE-OR-URL NEW-REPOSITORY");
115115
}
116116
db_open_config(0);
@@ -158,11 +158,11 @@
158158
"REPLACE INTO config(name,value,mtime)"
159159
" VALUES('server-code', lower(hex(randomblob(20))), now());"
160160
);
161161
url_enable_proxy(0);
162162
url_get_password_if_needed();
163
- clone_ssh_db_options();
163
+ clone_ssh_db_set_options();
164164
g.xlinkClusterOnly = 1;
165165
nErr = client_sync(SYNC_CLONE | bPrivate,CONFIGSET_ALL,0);
166166
g.xlinkClusterOnly = 0;
167167
verify_cancel();
168168
db_end_transaction(0);
@@ -183,11 +183,11 @@
183183
}
184184
185185
/*
186186
** Look for SSH clone command line options and setup in globals.
187187
*/
188
-void clone_ssh_options(void){
188
+void clone_ssh_find_options(void){
189189
const char *zSshFossilCmd; /* Path to remote fossil command for SSH */
190190
const char *zSshCmd; /* SSH command string */
191191
const char *zFossilUser; /* Fossil user if login specified for SSH */
192192
193193
zSshFossilCmd = find_option("ssh-fossil","f",1);
@@ -206,20 +206,16 @@
206206
207207
/*
208208
** Set SSH options discovered in global variables (set from command line
209209
** options). If not found, attempt to retrieve from database if present.
210210
*/
211
-void clone_ssh_db_options(void){
211
+void clone_ssh_db_set_options(void){
212212
if( g.zSshFossilCmd && g.zSshFossilCmd[0] ){
213213
db_set("ssh-fossil", g.zSshFossilCmd, 0);
214
- }else{
215
- g.zSshFossilCmd = db_get("ssh-fossil", "fossil");
216214
}
217215
if( g.zSshCmd && g.zSshCmd[0] ){
218216
db_set("ssh-command", g.zSshCmd, 0);
219217
}
220218
if( g.zFossilUser && g.zFossilUser[0] ){
221219
db_set("ssh-fossil-user", g.zFossilUser, 0);
222
- }else{
223
- g.zFossilUser = db_get("ssh-fossil-user", 0);
224220
}
225221
}
226222
--- src/clone.c
+++ src/clone.c
@@ -106,11 +106,11 @@
106 const char *zDefaultUser; /* Optional name of the default user */
107 int nErr = 0;
108 int bPrivate = 0; /* Also clone private branches */
109
110 if( find_option("private",0,0)!=0 ) bPrivate = SYNC_PRIVATE;
111 clone_ssh_options();
112 url_proxy_options();
113 if( g.argc < 4 ){
114 usage("?OPTIONS? FILE-OR-URL NEW-REPOSITORY");
115 }
116 db_open_config(0);
@@ -158,11 +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);
@@ -183,11 +183,11 @@
183 }
184
185 /*
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);
@@ -206,20 +206,16 @@
206
207 /*
208 ** Set SSH options discovered in global variables (set from command line
209 ** options). If not found, attempt to retrieve from database if present.
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
--- src/clone.c
+++ src/clone.c
@@ -106,11 +106,11 @@
106 const char *zDefaultUser; /* Optional name of the default user */
107 int nErr = 0;
108 int bPrivate = 0; /* Also clone private branches */
109
110 if( find_option("private",0,0)!=0 ) bPrivate = SYNC_PRIVATE;
111 clone_ssh_find_options();
112 url_proxy_options();
113 if( g.argc < 4 ){
114 usage("?OPTIONS? FILE-OR-URL NEW-REPOSITORY");
115 }
116 db_open_config(0);
@@ -158,11 +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_set_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);
@@ -183,11 +183,11 @@
183 }
184
185 /*
186 ** Look for SSH clone command line options and setup in globals.
187 */
188 void clone_ssh_find_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);
@@ -206,20 +206,16 @@
206
207 /*
208 ** Set SSH options discovered in global variables (set from command line
209 ** options). If not found, attempt to retrieve from database if present.
210 */
211 void clone_ssh_db_set_options(void){
212 if( g.zSshFossilCmd && g.zSshFossilCmd[0] ){
213 db_set("ssh-fossil", g.zSshFossilCmd, 0);
 
 
214 }
215 if( g.zSshCmd && g.zSshCmd[0] ){
216 db_set("ssh-command", g.zSshCmd, 0);
217 }
218 if( g.zFossilUser && g.zFossilUser[0] ){
219 db_set("ssh-fossil-user", g.zFossilUser, 0);
 
 
220 }
221 }
222
--- src/http_transport.c
+++ src/http_transport.c
@@ -105,46 +105,50 @@
105105
*/
106106
int transport_ssh_open(void){
107107
/* For SSH we need to create and run SSH fossil http
108108
** to talk to the remote machine.
109109
*/
110
+ static int fPrintSshCmd = 1; /* Print SSH command only once */
111
+ const char *zSshFossilCmd; /* Path to fossil on remote host */
110112
const char *zSsh; /* The base SSH command */
111113
Blob zCmd; /* The SSH command */
112114
char *zHost; /* The host name to contact */
113115
int n; /* Size of prefix string */
114116
115117
zSsh = db_get("ssh-command", zDefaultSshCmd);
118
+ zSshFossilCmd = db_get("ssh-fossil", "fossil");
116119
blob_init(&zCmd, zSsh, -1);
117120
if( g.urlPort!=g.urlDfltPort && g.urlPort ){
118121
#ifdef __MINGW32__
119122
blob_appendf(&zCmd, " -P %d", g.urlPort);
120123
#else
121124
blob_appendf(&zCmd, " -p %d", g.urlPort);
122125
#endif
123126
}
124
- fossil_force_newline();
125
- fossil_print("%s", blob_str(&zCmd)); /* Show the base of the SSH command */
127
+ if( fPrintSshCmd ){
128
+ fossil_force_newline();
129
+ fossil_print("%s", blob_str(&zCmd)); /* Show the base of the SSH command */
130
+ }
126131
if( g.urlUser && g.urlUser[0] ){
127132
zHost = mprintf("%s@%s", g.urlUser, g.urlName);
128133
}else{
129134
zHost = mprintf("%s", g.urlName);
130135
}
131136
n = blob_size(&zCmd);
132137
blob_append(&zCmd, " ", 1);
133138
shell_escape(&zCmd, zHost);
134
- if( g.zSshFossilCmd && g.zSshFossilCmd[0] ){
135
- blob_append(&zCmd, " ", 1);
136
- shell_escape(&zCmd, mprintf("%s", g.zSshFossilCmd));
137
- }else{
138
- blob_append(&zCmd, " fossil", 7);
139
- }
139
+ blob_append(&zCmd, " ", 1);
140
+ shell_escape(&zCmd, mprintf("%s", zSshFossilCmd));
140141
blob_append(&zCmd, " http", 5);
141142
if( g.urlPath && g.urlPath[0] ){
142143
blob_append(&zCmd, " ", 1);
143144
shell_escape(&zCmd, mprintf("%s", g.urlPath));
144145
}
145
- fossil_print("%s\n", blob_str(&zCmd)+n); /* Show tail of SSH command */
146
+ if( fPrintSshCmd ){
147
+ fossil_print("%s\n", blob_str(&zCmd)+n); /* Show tail of SSH command */
148
+ fPrintSshCmd = 0;
149
+ }
146150
free(zHost);
147151
popen2(blob_str(&zCmd), &sshIn, &sshOut, &sshPid);
148152
if( sshPid==0 ){
149153
socket_set_errmsg("cannot start ssh tunnel using [%b]", &zCmd);
150154
}
151155
--- src/http_transport.c
+++ src/http_transport.c
@@ -105,46 +105,50 @@
105 */
106 int transport_ssh_open(void){
107 /* For SSH we need to create and run SSH fossil http
108 ** to talk to the remote machine.
109 */
 
 
110 const char *zSsh; /* The base SSH command */
111 Blob zCmd; /* The SSH command */
112 char *zHost; /* The host name to contact */
113 int n; /* Size of prefix string */
114
115 zSsh = db_get("ssh-command", zDefaultSshCmd);
 
116 blob_init(&zCmd, zSsh, -1);
117 if( g.urlPort!=g.urlDfltPort && g.urlPort ){
118 #ifdef __MINGW32__
119 blob_appendf(&zCmd, " -P %d", g.urlPort);
120 #else
121 blob_appendf(&zCmd, " -p %d", g.urlPort);
122 #endif
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 shell_escape(&zCmd, zHost);
134 if( g.zSshFossilCmd && g.zSshFossilCmd[0] ){
135 blob_append(&zCmd, " ", 1);
136 shell_escape(&zCmd, mprintf("%s", g.zSshFossilCmd));
137 }else{
138 blob_append(&zCmd, " fossil", 7);
139 }
140 blob_append(&zCmd, " http", 5);
141 if( g.urlPath && g.urlPath[0] ){
142 blob_append(&zCmd, " ", 1);
143 shell_escape(&zCmd, mprintf("%s", g.urlPath));
144 }
145 fossil_print("%s\n", blob_str(&zCmd)+n); /* Show tail of SSH command */
 
 
 
146 free(zHost);
147 popen2(blob_str(&zCmd), &sshIn, &sshOut, &sshPid);
148 if( sshPid==0 ){
149 socket_set_errmsg("cannot start ssh tunnel using [%b]", &zCmd);
150 }
151
--- src/http_transport.c
+++ src/http_transport.c
@@ -105,46 +105,50 @@
105 */
106 int transport_ssh_open(void){
107 /* For SSH we need to create and run SSH fossil http
108 ** to talk to the remote machine.
109 */
110 static int fPrintSshCmd = 1; /* Print SSH command only once */
111 const char *zSshFossilCmd; /* Path to fossil on remote host */
112 const char *zSsh; /* The base SSH command */
113 Blob zCmd; /* The SSH command */
114 char *zHost; /* The host name to contact */
115 int n; /* Size of prefix string */
116
117 zSsh = db_get("ssh-command", zDefaultSshCmd);
118 zSshFossilCmd = db_get("ssh-fossil", "fossil");
119 blob_init(&zCmd, zSsh, -1);
120 if( g.urlPort!=g.urlDfltPort && g.urlPort ){
121 #ifdef __MINGW32__
122 blob_appendf(&zCmd, " -P %d", g.urlPort);
123 #else
124 blob_appendf(&zCmd, " -p %d", g.urlPort);
125 #endif
126 }
127 if( fPrintSshCmd ){
128 fossil_force_newline();
129 fossil_print("%s", blob_str(&zCmd)); /* Show the base of the SSH command */
130 }
131 if( g.urlUser && g.urlUser[0] ){
132 zHost = mprintf("%s@%s", g.urlUser, g.urlName);
133 }else{
134 zHost = mprintf("%s", g.urlName);
135 }
136 n = blob_size(&zCmd);
137 blob_append(&zCmd, " ", 1);
138 shell_escape(&zCmd, zHost);
139 blob_append(&zCmd, " ", 1);
140 shell_escape(&zCmd, mprintf("%s", zSshFossilCmd));
 
 
 
 
141 blob_append(&zCmd, " http", 5);
142 if( g.urlPath && g.urlPath[0] ){
143 blob_append(&zCmd, " ", 1);
144 shell_escape(&zCmd, mprintf("%s", g.urlPath));
145 }
146 if( fPrintSshCmd ){
147 fossil_print("%s\n", blob_str(&zCmd)+n); /* Show tail of SSH command */
148 fPrintSshCmd = 0;
149 }
150 free(zHost);
151 popen2(blob_str(&zCmd), &sshIn, &sshOut, &sshPid);
152 if( sshPid==0 ){
153 socket_set_errmsg("cannot start ssh tunnel using [%b]", &zCmd);
154 }
155
--- src/http_transport.c
+++ src/http_transport.c
@@ -105,46 +105,50 @@
105105
*/
106106
int transport_ssh_open(void){
107107
/* For SSH we need to create and run SSH fossil http
108108
** to talk to the remote machine.
109109
*/
110
+ static int fPrintSshCmd = 1; /* Print SSH command only once */
111
+ const char *zSshFossilCmd; /* Path to fossil on remote host */
110112
const char *zSsh; /* The base SSH command */
111113
Blob zCmd; /* The SSH command */
112114
char *zHost; /* The host name to contact */
113115
int n; /* Size of prefix string */
114116
115117
zSsh = db_get("ssh-command", zDefaultSshCmd);
118
+ zSshFossilCmd = db_get("ssh-fossil", "fossil");
116119
blob_init(&zCmd, zSsh, -1);
117120
if( g.urlPort!=g.urlDfltPort && g.urlPort ){
118121
#ifdef __MINGW32__
119122
blob_appendf(&zCmd, " -P %d", g.urlPort);
120123
#else
121124
blob_appendf(&zCmd, " -p %d", g.urlPort);
122125
#endif
123126
}
124
- fossil_force_newline();
125
- fossil_print("%s", blob_str(&zCmd)); /* Show the base of the SSH command */
127
+ if( fPrintSshCmd ){
128
+ fossil_force_newline();
129
+ fossil_print("%s", blob_str(&zCmd)); /* Show the base of the SSH command */
130
+ }
126131
if( g.urlUser && g.urlUser[0] ){
127132
zHost = mprintf("%s@%s", g.urlUser, g.urlName);
128133
}else{
129134
zHost = mprintf("%s", g.urlName);
130135
}
131136
n = blob_size(&zCmd);
132137
blob_append(&zCmd, " ", 1);
133138
shell_escape(&zCmd, zHost);
134
- if( g.zSshFossilCmd && g.zSshFossilCmd[0] ){
135
- blob_append(&zCmd, " ", 1);
136
- shell_escape(&zCmd, mprintf("%s", g.zSshFossilCmd));
137
- }else{
138
- blob_append(&zCmd, " fossil", 7);
139
- }
139
+ blob_append(&zCmd, " ", 1);
140
+ shell_escape(&zCmd, mprintf("%s", zSshFossilCmd));
140141
blob_append(&zCmd, " http", 5);
141142
if( g.urlPath && g.urlPath[0] ){
142143
blob_append(&zCmd, " ", 1);
143144
shell_escape(&zCmd, mprintf("%s", g.urlPath));
144145
}
145
- fossil_print("%s\n", blob_str(&zCmd)+n); /* Show tail of SSH command */
146
+ if( fPrintSshCmd ){
147
+ fossil_print("%s\n", blob_str(&zCmd)+n); /* Show tail of SSH command */
148
+ fPrintSshCmd = 0;
149
+ }
146150
free(zHost);
147151
popen2(blob_str(&zCmd), &sshIn, &sshOut, &sshPid);
148152
if( sshPid==0 ){
149153
socket_set_errmsg("cannot start ssh tunnel using [%b]", &zCmd);
150154
}
151155
--- src/http_transport.c
+++ src/http_transport.c
@@ -105,46 +105,50 @@
105 */
106 int transport_ssh_open(void){
107 /* For SSH we need to create and run SSH fossil http
108 ** to talk to the remote machine.
109 */
 
 
110 const char *zSsh; /* The base SSH command */
111 Blob zCmd; /* The SSH command */
112 char *zHost; /* The host name to contact */
113 int n; /* Size of prefix string */
114
115 zSsh = db_get("ssh-command", zDefaultSshCmd);
 
116 blob_init(&zCmd, zSsh, -1);
117 if( g.urlPort!=g.urlDfltPort && g.urlPort ){
118 #ifdef __MINGW32__
119 blob_appendf(&zCmd, " -P %d", g.urlPort);
120 #else
121 blob_appendf(&zCmd, " -p %d", g.urlPort);
122 #endif
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 shell_escape(&zCmd, zHost);
134 if( g.zSshFossilCmd && g.zSshFossilCmd[0] ){
135 blob_append(&zCmd, " ", 1);
136 shell_escape(&zCmd, mprintf("%s", g.zSshFossilCmd));
137 }else{
138 blob_append(&zCmd, " fossil", 7);
139 }
140 blob_append(&zCmd, " http", 5);
141 if( g.urlPath && g.urlPath[0] ){
142 blob_append(&zCmd, " ", 1);
143 shell_escape(&zCmd, mprintf("%s", g.urlPath));
144 }
145 fossil_print("%s\n", blob_str(&zCmd)+n); /* Show tail of SSH command */
 
 
 
146 free(zHost);
147 popen2(blob_str(&zCmd), &sshIn, &sshOut, &sshPid);
148 if( sshPid==0 ){
149 socket_set_errmsg("cannot start ssh tunnel using [%b]", &zCmd);
150 }
151
--- src/http_transport.c
+++ src/http_transport.c
@@ -105,46 +105,50 @@
105 */
106 int transport_ssh_open(void){
107 /* For SSH we need to create and run SSH fossil http
108 ** to talk to the remote machine.
109 */
110 static int fPrintSshCmd = 1; /* Print SSH command only once */
111 const char *zSshFossilCmd; /* Path to fossil on remote host */
112 const char *zSsh; /* The base SSH command */
113 Blob zCmd; /* The SSH command */
114 char *zHost; /* The host name to contact */
115 int n; /* Size of prefix string */
116
117 zSsh = db_get("ssh-command", zDefaultSshCmd);
118 zSshFossilCmd = db_get("ssh-fossil", "fossil");
119 blob_init(&zCmd, zSsh, -1);
120 if( g.urlPort!=g.urlDfltPort && g.urlPort ){
121 #ifdef __MINGW32__
122 blob_appendf(&zCmd, " -P %d", g.urlPort);
123 #else
124 blob_appendf(&zCmd, " -p %d", g.urlPort);
125 #endif
126 }
127 if( fPrintSshCmd ){
128 fossil_force_newline();
129 fossil_print("%s", blob_str(&zCmd)); /* Show the base of the SSH command */
130 }
131 if( g.urlUser && g.urlUser[0] ){
132 zHost = mprintf("%s@%s", g.urlUser, g.urlName);
133 }else{
134 zHost = mprintf("%s", g.urlName);
135 }
136 n = blob_size(&zCmd);
137 blob_append(&zCmd, " ", 1);
138 shell_escape(&zCmd, zHost);
139 blob_append(&zCmd, " ", 1);
140 shell_escape(&zCmd, mprintf("%s", zSshFossilCmd));
 
 
 
 
141 blob_append(&zCmd, " http", 5);
142 if( g.urlPath && g.urlPath[0] ){
143 blob_append(&zCmd, " ", 1);
144 shell_escape(&zCmd, mprintf("%s", g.urlPath));
145 }
146 if( fPrintSshCmd ){
147 fossil_print("%s\n", blob_str(&zCmd)+n); /* Show tail of SSH command */
148 fPrintSshCmd = 0;
149 }
150 free(zHost);
151 popen2(blob_str(&zCmd), &sshIn, &sshOut, &sshPid);
152 if( sshPid==0 ){
153 socket_set_errmsg("cannot start ssh tunnel using [%b]", &zCmd);
154 }
155
+2 -4
--- src/sync.c
+++ src/sync.c
@@ -48,13 +48,10 @@
4848
}
4949
}else{
5050
/* Autosync defaults on. To make it default off, "return" here. */
5151
}
5252
url_parse(0, URL_REMEMBER);
53
- if( g.urlIsSsh ){
54
- clone_ssh_db_options();
55
- }
5653
if( g.urlProtocol==0 ) return 0;
5754
if( ( g.urlUser!=0 || g.zFossilUser!=0 ) && g.urlPasswd==0 ){
5855
g.urlPasswd = unobscure(db_get("last-sync-pw", 0));
5956
}
6057
if( g.urlIsSsh && g.urlPasswd==0 ){
@@ -104,18 +101,19 @@
104101
}
105102
if( find_option("verbose","v",0)!=0 ){
106103
*pSyncFlags |= SYNC_VERBOSE;
107104
}
108105
url_proxy_options();
106
+ clone_ssh_find_options();
109107
db_find_and_open_repository(0, 0);
110108
db_open_config(0);
111109
if( g.argc==2 ){
112110
if( db_get_boolean("auto-shun",1) ) configSync = CONFIGSET_SHUN;
113111
}else if( g.argc==3 ){
114112
zUrl = g.argv[2];
115113
}
116
- clone_ssh_db_options();
114
+ clone_ssh_db_set_options();
117115
url_parse(zUrl, urlFlags);
118116
if( g.urlProtocol==0 ){
119117
if( urlOptional ) fossil_exit(0);
120118
usage("URL");
121119
}
122120
--- src/sync.c
+++ src/sync.c
@@ -48,13 +48,10 @@
48 }
49 }else{
50 /* Autosync defaults on. To make it default off, "return" here. */
51 }
52 url_parse(0, URL_REMEMBER);
53 if( g.urlIsSsh ){
54 clone_ssh_db_options();
55 }
56 if( g.urlProtocol==0 ) return 0;
57 if( ( g.urlUser!=0 || g.zFossilUser!=0 ) && g.urlPasswd==0 ){
58 g.urlPasswd = unobscure(db_get("last-sync-pw", 0));
59 }
60 if( g.urlIsSsh && g.urlPasswd==0 ){
@@ -104,18 +101,19 @@
104 }
105 if( find_option("verbose","v",0)!=0 ){
106 *pSyncFlags |= SYNC_VERBOSE;
107 }
108 url_proxy_options();
 
109 db_find_and_open_repository(0, 0);
110 db_open_config(0);
111 if( g.argc==2 ){
112 if( db_get_boolean("auto-shun",1) ) configSync = CONFIGSET_SHUN;
113 }else if( g.argc==3 ){
114 zUrl = g.argv[2];
115 }
116 clone_ssh_db_options();
117 url_parse(zUrl, urlFlags);
118 if( g.urlProtocol==0 ){
119 if( urlOptional ) fossil_exit(0);
120 usage("URL");
121 }
122
--- src/sync.c
+++ src/sync.c
@@ -48,13 +48,10 @@
48 }
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( g.urlIsSsh && g.urlPasswd==0 ){
@@ -104,18 +101,19 @@
101 }
102 if( find_option("verbose","v",0)!=0 ){
103 *pSyncFlags |= SYNC_VERBOSE;
104 }
105 url_proxy_options();
106 clone_ssh_find_options();
107 db_find_and_open_repository(0, 0);
108 db_open_config(0);
109 if( g.argc==2 ){
110 if( db_get_boolean("auto-shun",1) ) configSync = CONFIGSET_SHUN;
111 }else if( g.argc==3 ){
112 zUrl = g.argv[2];
113 }
114 clone_ssh_db_set_options();
115 url_parse(zUrl, urlFlags);
116 if( g.urlProtocol==0 ){
117 if( urlOptional ) fossil_exit(0);
118 usage("URL");
119 }
120
+2 -4
--- src/sync.c
+++ src/sync.c
@@ -48,13 +48,10 @@
4848
}
4949
}else{
5050
/* Autosync defaults on. To make it default off, "return" here. */
5151
}
5252
url_parse(0, URL_REMEMBER);
53
- if( g.urlIsSsh ){
54
- clone_ssh_db_options();
55
- }
5653
if( g.urlProtocol==0 ) return 0;
5754
if( ( g.urlUser!=0 || g.zFossilUser!=0 ) && g.urlPasswd==0 ){
5855
g.urlPasswd = unobscure(db_get("last-sync-pw", 0));
5956
}
6057
if( g.urlIsSsh && g.urlPasswd==0 ){
@@ -104,18 +101,19 @@
104101
}
105102
if( find_option("verbose","v",0)!=0 ){
106103
*pSyncFlags |= SYNC_VERBOSE;
107104
}
108105
url_proxy_options();
106
+ clone_ssh_find_options();
109107
db_find_and_open_repository(0, 0);
110108
db_open_config(0);
111109
if( g.argc==2 ){
112110
if( db_get_boolean("auto-shun",1) ) configSync = CONFIGSET_SHUN;
113111
}else if( g.argc==3 ){
114112
zUrl = g.argv[2];
115113
}
116
- clone_ssh_db_options();
114
+ clone_ssh_db_set_options();
117115
url_parse(zUrl, urlFlags);
118116
if( g.urlProtocol==0 ){
119117
if( urlOptional ) fossil_exit(0);
120118
usage("URL");
121119
}
122120
--- src/sync.c
+++ src/sync.c
@@ -48,13 +48,10 @@
48 }
49 }else{
50 /* Autosync defaults on. To make it default off, "return" here. */
51 }
52 url_parse(0, URL_REMEMBER);
53 if( g.urlIsSsh ){
54 clone_ssh_db_options();
55 }
56 if( g.urlProtocol==0 ) return 0;
57 if( ( g.urlUser!=0 || g.zFossilUser!=0 ) && g.urlPasswd==0 ){
58 g.urlPasswd = unobscure(db_get("last-sync-pw", 0));
59 }
60 if( g.urlIsSsh && g.urlPasswd==0 ){
@@ -104,18 +101,19 @@
104 }
105 if( find_option("verbose","v",0)!=0 ){
106 *pSyncFlags |= SYNC_VERBOSE;
107 }
108 url_proxy_options();
 
109 db_find_and_open_repository(0, 0);
110 db_open_config(0);
111 if( g.argc==2 ){
112 if( db_get_boolean("auto-shun",1) ) configSync = CONFIGSET_SHUN;
113 }else if( g.argc==3 ){
114 zUrl = g.argv[2];
115 }
116 clone_ssh_db_options();
117 url_parse(zUrl, urlFlags);
118 if( g.urlProtocol==0 ){
119 if( urlOptional ) fossil_exit(0);
120 usage("URL");
121 }
122
--- src/sync.c
+++ src/sync.c
@@ -48,13 +48,10 @@
48 }
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( g.urlIsSsh && g.urlPasswd==0 ){
@@ -104,18 +101,19 @@
101 }
102 if( find_option("verbose","v",0)!=0 ){
103 *pSyncFlags |= SYNC_VERBOSE;
104 }
105 url_proxy_options();
106 clone_ssh_find_options();
107 db_find_and_open_repository(0, 0);
108 db_open_config(0);
109 if( g.argc==2 ){
110 if( db_get_boolean("auto-shun",1) ) configSync = CONFIGSET_SHUN;
111 }else if( g.argc==3 ){
112 zUrl = g.argv[2];
113 }
114 clone_ssh_db_set_options();
115 url_parse(zUrl, urlFlags);
116 if( g.urlProtocol==0 ){
117 if( urlOptional ) fossil_exit(0);
118 usage("URL");
119 }
120
+4
--- src/url.c
+++ src/url.c
@@ -77,10 +77,11 @@
7777
7878
if( zUrl==0 ){
7979
zUrl = db_get("last-sync-url", 0);
8080
if( zUrl==0 ) return;
8181
g.urlPasswd = unobscure(db_get("last-sync-pw", 0));
82
+ g.zFossilUser = db_get("ssh-fossil-user", 0);
8283
bSetUrl = 0;
8384
}
8485
8586
if( strncmp(zUrl, "http://", 7)==0
8687
|| strncmp(zUrl, "https://", 8)==0
@@ -187,10 +188,13 @@
187188
}
188189
}else{
189190
fossil_fatal("unknown repository: %s", zUrl);
190191
}
191192
g.urlFlags = urlFlags;
193
+ if( g.urlIsSsh ){
194
+ g.zFossilUser = db_get("ssh-fossil-user", 0);
195
+ }
192196
if( g.urlIsFile ){
193197
Blob cfile;
194198
dehttpize(zFile);
195199
file_canonical_name(zFile, &cfile, 0);
196200
free(zFile);
197201
--- src/url.c
+++ src/url.c
@@ -77,10 +77,11 @@
77
78 if( zUrl==0 ){
79 zUrl = db_get("last-sync-url", 0);
80 if( zUrl==0 ) return;
81 g.urlPasswd = unobscure(db_get("last-sync-pw", 0));
 
82 bSetUrl = 0;
83 }
84
85 if( strncmp(zUrl, "http://", 7)==0
86 || strncmp(zUrl, "https://", 8)==0
@@ -187,10 +188,13 @@
187 }
188 }else{
189 fossil_fatal("unknown repository: %s", zUrl);
190 }
191 g.urlFlags = urlFlags;
 
 
 
192 if( g.urlIsFile ){
193 Blob cfile;
194 dehttpize(zFile);
195 file_canonical_name(zFile, &cfile, 0);
196 free(zFile);
197
--- src/url.c
+++ src/url.c
@@ -77,10 +77,11 @@
77
78 if( zUrl==0 ){
79 zUrl = db_get("last-sync-url", 0);
80 if( zUrl==0 ) return;
81 g.urlPasswd = unobscure(db_get("last-sync-pw", 0));
82 g.zFossilUser = db_get("ssh-fossil-user", 0);
83 bSetUrl = 0;
84 }
85
86 if( strncmp(zUrl, "http://", 7)==0
87 || strncmp(zUrl, "https://", 8)==0
@@ -187,10 +188,13 @@
188 }
189 }else{
190 fossil_fatal("unknown repository: %s", zUrl);
191 }
192 g.urlFlags = urlFlags;
193 if( g.urlIsSsh ){
194 g.zFossilUser = db_get("ssh-fossil-user", 0);
195 }
196 if( g.urlIsFile ){
197 Blob cfile;
198 dehttpize(zFile);
199 file_canonical_name(zFile, &cfile, 0);
200 free(zFile);
201
+4
--- src/url.c
+++ src/url.c
@@ -77,10 +77,11 @@
7777
7878
if( zUrl==0 ){
7979
zUrl = db_get("last-sync-url", 0);
8080
if( zUrl==0 ) return;
8181
g.urlPasswd = unobscure(db_get("last-sync-pw", 0));
82
+ g.zFossilUser = db_get("ssh-fossil-user", 0);
8283
bSetUrl = 0;
8384
}
8485
8586
if( strncmp(zUrl, "http://", 7)==0
8687
|| strncmp(zUrl, "https://", 8)==0
@@ -187,10 +188,13 @@
187188
}
188189
}else{
189190
fossil_fatal("unknown repository: %s", zUrl);
190191
}
191192
g.urlFlags = urlFlags;
193
+ if( g.urlIsSsh ){
194
+ g.zFossilUser = db_get("ssh-fossil-user", 0);
195
+ }
192196
if( g.urlIsFile ){
193197
Blob cfile;
194198
dehttpize(zFile);
195199
file_canonical_name(zFile, &cfile, 0);
196200
free(zFile);
197201
--- src/url.c
+++ src/url.c
@@ -77,10 +77,11 @@
77
78 if( zUrl==0 ){
79 zUrl = db_get("last-sync-url", 0);
80 if( zUrl==0 ) return;
81 g.urlPasswd = unobscure(db_get("last-sync-pw", 0));
 
82 bSetUrl = 0;
83 }
84
85 if( strncmp(zUrl, "http://", 7)==0
86 || strncmp(zUrl, "https://", 8)==0
@@ -187,10 +188,13 @@
187 }
188 }else{
189 fossil_fatal("unknown repository: %s", zUrl);
190 }
191 g.urlFlags = urlFlags;
 
 
 
192 if( g.urlIsFile ){
193 Blob cfile;
194 dehttpize(zFile);
195 file_canonical_name(zFile, &cfile, 0);
196 free(zFile);
197
--- src/url.c
+++ src/url.c
@@ -77,10 +77,11 @@
77
78 if( zUrl==0 ){
79 zUrl = db_get("last-sync-url", 0);
80 if( zUrl==0 ) return;
81 g.urlPasswd = unobscure(db_get("last-sync-pw", 0));
82 g.zFossilUser = db_get("ssh-fossil-user", 0);
83 bSetUrl = 0;
84 }
85
86 if( strncmp(zUrl, "http://", 7)==0
87 || strncmp(zUrl, "https://", 8)==0
@@ -187,10 +188,13 @@
188 }
189 }else{
190 fossil_fatal("unknown repository: %s", zUrl);
191 }
192 g.urlFlags = urlFlags;
193 if( g.urlIsSsh ){
194 g.zFossilUser = db_get("ssh-fossil-user", 0);
195 }
196 if( g.urlIsFile ){
197 Blob cfile;
198 dehttpize(zFile);
199 file_canonical_name(zFile, &cfile, 0);
200 free(zFile);
201

Keyboard Shortcuts

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