Fossil SCM

Further attempts to help the "ssh" sync protocol move past noisy motd comments and other extraneous login text, synchronize with the remote end, and start exchanging messages successfully.

drh 2012-11-11 22:42 trunk
Commit 4473a27f3b6e049e3c162e440e0e4c87daf9570c
1 file changed +12 -5
--- src/http_transport.c
+++ src/http_transport.c
@@ -110,10 +110,12 @@
110110
*/
111111
const char *zSsh; /* The base SSH command */
112112
Blob zCmd; /* The SSH command */
113113
char *zHost; /* The host name to contact */
114114
char *zIn; /* An input line received back from remote */
115
+ unsigned iRandom;
116
+ char zProbe[30];
115117
116118
zSsh = db_get("ssh-command", zDefaultSshCmd);
117119
blob_init(&zCmd, zSsh, -1);
118120
if( g.urlPort!=g.urlDfltPort ){
119121
#ifdef __MINGW32__
@@ -155,18 +157,23 @@
155157
if( sshPid==0 ){
156158
fossil_fatal("cannot start ssh tunnel using [%b]", &zCmd);
157159
}
158160
blob_reset(&zCmd);
159161
160
- /* Send an "echo" command to the other side to make sure that the
162
+ /* Send a couple of "echo" command to the other side to make sure that the
161163
** connection is up and working.
162164
*/
163
- fprintf(sshOut, "echo test\n");
165
+ fprintf(sshOut, "echo test1\n");
166
+ fflush(sshOut);
167
+ zIn = fossil_malloc(50000);
168
+ sshin_read(zIn, 50000);
169
+ sqlite3_randomness(sizeof(iRandom), &iRandom);
170
+ sqlite3_snprintf(sizeof(zProbe), zProbe, "probe-%08x", iRandom);
171
+ fprintf(sshOut, "echo %s\n", zProbe);
164172
fflush(sshOut);
165
- zIn = fossil_malloc(16000);
166
- sshin_read(zIn, 16000);
167
- if( memcmp(zIn, "test", 4)!=0 ){
173
+ sshin_read(zIn, 500);
174
+ if( memcmp(zIn, zProbe, 14)!=0 ){
168175
pclose2(sshIn, sshOut, sshPid);
169176
fossil_fatal("ssh connection failed: [%s]", zIn);
170177
}
171178
fossil_free(zIn);
172179
}
173180
--- src/http_transport.c
+++ src/http_transport.c
@@ -110,10 +110,12 @@
110 */
111 const char *zSsh; /* The base SSH command */
112 Blob zCmd; /* The SSH command */
113 char *zHost; /* The host name to contact */
114 char *zIn; /* An input line received back from remote */
 
 
115
116 zSsh = db_get("ssh-command", zDefaultSshCmd);
117 blob_init(&zCmd, zSsh, -1);
118 if( g.urlPort!=g.urlDfltPort ){
119 #ifdef __MINGW32__
@@ -155,18 +157,23 @@
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 fprintf(sshOut, "echo test\n");
 
 
 
 
 
 
164 fflush(sshOut);
165 zIn = fossil_malloc(16000);
166 sshin_read(zIn, 16000);
167 if( memcmp(zIn, "test", 4)!=0 ){
168 pclose2(sshIn, sshOut, sshPid);
169 fossil_fatal("ssh connection failed: [%s]", zIn);
170 }
171 fossil_free(zIn);
172 }
173
--- src/http_transport.c
+++ src/http_transport.c
@@ -110,10 +110,12 @@
110 */
111 const char *zSsh; /* The base SSH command */
112 Blob zCmd; /* The SSH command */
113 char *zHost; /* The host name to contact */
114 char *zIn; /* An input line received back from remote */
115 unsigned iRandom;
116 char zProbe[30];
117
118 zSsh = db_get("ssh-command", zDefaultSshCmd);
119 blob_init(&zCmd, zSsh, -1);
120 if( g.urlPort!=g.urlDfltPort ){
121 #ifdef __MINGW32__
@@ -155,18 +157,23 @@
157 if( sshPid==0 ){
158 fossil_fatal("cannot start ssh tunnel using [%b]", &zCmd);
159 }
160 blob_reset(&zCmd);
161
162 /* Send a couple of "echo" command to the other side to make sure that the
163 ** connection is up and working.
164 */
165 fprintf(sshOut, "echo test1\n");
166 fflush(sshOut);
167 zIn = fossil_malloc(50000);
168 sshin_read(zIn, 50000);
169 sqlite3_randomness(sizeof(iRandom), &iRandom);
170 sqlite3_snprintf(sizeof(zProbe), zProbe, "probe-%08x", iRandom);
171 fprintf(sshOut, "echo %s\n", zProbe);
172 fflush(sshOut);
173 sshin_read(zIn, 500);
174 if( memcmp(zIn, zProbe, 14)!=0 ){
 
175 pclose2(sshIn, sshOut, sshPid);
176 fossil_fatal("ssh connection failed: [%s]", zIn);
177 }
178 fossil_free(zIn);
179 }
180

Keyboard Shortcuts

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