Fossil SCM

Seems to fix it.. will try on the real conditions..

mgagnon 2012-09-12 12:59 mg_sshfix
Commit e8fac25a20c840f62f672cf205c11546255cc475
1 file changed +12 -32
--- src/http_transport.c
+++ src/http_transport.c
@@ -92,15 +92,11 @@
9292
}
9393
9494
/*
9595
** Default SSH command
9696
*/
97
-#ifdef __MINGW32__
98
-static char zDefaultSshCmd[] = "ssh -T";
99
-#else
100
-static char zDefaultSshCmd[] = "ssh -e none -T";
101
-#endif
97
+static char zDefaultSshCmd[] = "ssh";
10298
10399
/*
104100
** Global initialization of the transport layer
105101
*/
106102
void transport_global_startup(void){
@@ -149,33 +145,25 @@
149145
}
150146
blob_append(&zCmd, " ", 1);
151147
shell_escape(&zCmd, zHost);
152148
fossil_print(" %s\n", zHost); /* Show the conclusion of the SSH command */
153149
free(zHost);
150
+
151
+ /* Append fossil test-http command directly during the invocation of ssh,
152
+ ** to make sure no output from shell or login will pollute the sshIn pipe.
153
+ */
154
+ blob_append(&zCmd, " \"", 2);
155
+ shell_escape(&zCmd, g.urlFossil);
156
+ blob_append(&zCmd, " test-http ", -1);
157
+ shell_escape(&zCmd, g.urlPath);
158
+ blob_append(&zCmd, "\"", 1);
159
+
154160
popen2(blob_str(&zCmd), &sshIn, &sshOut, &sshPid);
155161
if( sshPid==0 ){
156162
fossil_fatal("cannot start ssh tunnel using [%b]", &zCmd);
157163
}
158164
blob_reset(&zCmd);
159
-
160
- /* Send an "echo" command to the other side to make sure that the
161
- ** connection is up and working.
162
- */
163
- zIn = fossil_malloc(16000);
164
- fprintf(sshOut, "echo toto\n");
165
- fflush(sshOut);
166
- usleep(2000000);
167
- sshin_read(zIn, 16000);
168
- fossil_print("Second Read: [%s]\n", zIn);
169
- fprintf(sshOut, "echo test\n");
170
- fflush(sshOut);
171
- sshin_read(zIn, 16000);
172
- if( memcmp(zIn, "test", 4)!=0 ){
173
- pclose2(sshIn, sshOut, sshPid);
174
- fossil_fatal("ssh connection failed: [%s]", zIn);
175
- }
176
- fossil_free(zIn);
177165
}
178166
}
179167
180168
/*
181169
** Open a connection to the server. The server is defined by the following
@@ -189,19 +177,11 @@
189177
*/
190178
int transport_open(void){
191179
int rc = 0;
192180
if( transport.isOpen==0 ){
193181
if( g.urlIsSsh ){
194
- Blob cmd;
195
- blob_zero(&cmd);
196
- shell_escape(&cmd, g.urlFossil);
197
- blob_append(&cmd, " test-http ", -1);
198
- shell_escape(&cmd, g.urlPath);
199
- /* printf("%s\n", blob_str(&cmd)); fflush(stdout); */
200
- fprintf(sshOut, "%s\n", blob_str(&cmd));
201
- fflush(sshOut);
202
- blob_reset(&cmd);
182
+ transport.isOpen = 1;
203183
}else if( g.urlIsHttps ){
204184
#ifdef FOSSIL_ENABLE_SSL
205185
rc = ssl_open();
206186
if( rc==0 ) transport.isOpen = 1;
207187
#else
208188
--- src/http_transport.c
+++ src/http_transport.c
@@ -92,15 +92,11 @@
92 }
93
94 /*
95 ** Default SSH command
96 */
97 #ifdef __MINGW32__
98 static char zDefaultSshCmd[] = "ssh -T";
99 #else
100 static char zDefaultSshCmd[] = "ssh -e none -T";
101 #endif
102
103 /*
104 ** Global initialization of the transport layer
105 */
106 void transport_global_startup(void){
@@ -149,33 +145,25 @@
149 }
150 blob_append(&zCmd, " ", 1);
151 shell_escape(&zCmd, zHost);
152 fossil_print(" %s\n", zHost); /* Show the conclusion of the SSH command */
153 free(zHost);
 
 
 
 
 
 
 
 
 
 
154 popen2(blob_str(&zCmd), &sshIn, &sshOut, &sshPid);
155 if( sshPid==0 ){
156 fossil_fatal("cannot start ssh tunnel using [%b]", &zCmd);
157 }
158 blob_reset(&zCmd);
159
160 /* Send an "echo" command to the other side to make sure that the
161 ** connection is up and working.
162 */
163 zIn = fossil_malloc(16000);
164 fprintf(sshOut, "echo toto\n");
165 fflush(sshOut);
166 usleep(2000000);
167 sshin_read(zIn, 16000);
168 fossil_print("Second Read: [%s]\n", zIn);
169 fprintf(sshOut, "echo test\n");
170 fflush(sshOut);
171 sshin_read(zIn, 16000);
172 if( memcmp(zIn, "test", 4)!=0 ){
173 pclose2(sshIn, sshOut, sshPid);
174 fossil_fatal("ssh connection failed: [%s]", zIn);
175 }
176 fossil_free(zIn);
177 }
178 }
179
180 /*
181 ** Open a connection to the server. The server is defined by the following
@@ -189,19 +177,11 @@
189 */
190 int transport_open(void){
191 int rc = 0;
192 if( transport.isOpen==0 ){
193 if( g.urlIsSsh ){
194 Blob cmd;
195 blob_zero(&cmd);
196 shell_escape(&cmd, g.urlFossil);
197 blob_append(&cmd, " test-http ", -1);
198 shell_escape(&cmd, g.urlPath);
199 /* printf("%s\n", blob_str(&cmd)); fflush(stdout); */
200 fprintf(sshOut, "%s\n", blob_str(&cmd));
201 fflush(sshOut);
202 blob_reset(&cmd);
203 }else if( g.urlIsHttps ){
204 #ifdef FOSSIL_ENABLE_SSL
205 rc = ssl_open();
206 if( rc==0 ) transport.isOpen = 1;
207 #else
208
--- src/http_transport.c
+++ src/http_transport.c
@@ -92,15 +92,11 @@
92 }
93
94 /*
95 ** Default SSH command
96 */
97 static char zDefaultSshCmd[] = "ssh";
 
 
 
 
98
99 /*
100 ** Global initialization of the transport layer
101 */
102 void transport_global_startup(void){
@@ -149,33 +145,25 @@
145 }
146 blob_append(&zCmd, " ", 1);
147 shell_escape(&zCmd, zHost);
148 fossil_print(" %s\n", zHost); /* Show the conclusion of the SSH command */
149 free(zHost);
150
151 /* Append fossil test-http command directly during the invocation of ssh,
152 ** to make sure no output from shell or login will pollute the sshIn pipe.
153 */
154 blob_append(&zCmd, " \"", 2);
155 shell_escape(&zCmd, g.urlFossil);
156 blob_append(&zCmd, " test-http ", -1);
157 shell_escape(&zCmd, g.urlPath);
158 blob_append(&zCmd, "\"", 1);
159
160 popen2(blob_str(&zCmd), &sshIn, &sshOut, &sshPid);
161 if( sshPid==0 ){
162 fossil_fatal("cannot start ssh tunnel using [%b]", &zCmd);
163 }
164 blob_reset(&zCmd);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
165 }
166 }
167
168 /*
169 ** Open a connection to the server. The server is defined by the following
@@ -189,19 +177,11 @@
177 */
178 int transport_open(void){
179 int rc = 0;
180 if( transport.isOpen==0 ){
181 if( g.urlIsSsh ){
182 transport.isOpen = 1;
 
 
 
 
 
 
 
 
183 }else if( g.urlIsHttps ){
184 #ifdef FOSSIL_ENABLE_SSL
185 rc = ssl_open();
186 if( rc==0 ) transport.isOpen = 1;
187 #else
188

Keyboard Shortcuts

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