Fossil SCM

For the ssh: transport method, use the -T option to disable pseudottys. Increase the size of the buffer for holding the MOTD.

drh 2011-02-16 19:13 trunk
Commit 7c8519003de911f5cba05af7e04f3b73af79db13
1 file changed +13 -10
--- src/http_transport.c
+++ src/http_transport.c
@@ -109,19 +109,19 @@
109109
** and run an SSH command to talk to the remote machine.
110110
*/
111111
const char *zSsh; /* The base SSH command */
112112
Blob zCmd; /* The SSH command */
113113
char *zHost; /* The host name to contact */
114
- char zIn[200]; /* An input line received back from remote */
114
+ char *zIn; /* An input line received back from remote */
115115
116116
zSsh = db_get("ssh-command", zDefaultSshCmd);
117117
blob_init(&zCmd, zSsh, -1);
118118
if( g.urlPort!=g.urlDfltPort ){
119119
#ifdef __MINGW32__
120
- blob_appendf(&zCmd, " -P %d", g.urlPort);
120
+ blob_appendf(&zCmd, " -T -P %d", g.urlPort);
121121
#else
122
- blob_appendf(&zCmd, " -p %d", g.urlPort);
122
+ blob_appendf(&zCmd, " -e none -T -p %d", g.urlPort);
123123
#endif
124124
}
125125
if( g.urlUser && g.urlUser[0] ){
126126
zHost = mprintf("%s@%s", g.urlUser, g.urlName);
127127
#ifdef __MINGW32__
@@ -146,11 +146,11 @@
146146
zHost = mprintf("%s", g.urlName);
147147
}
148148
blob_append(&zCmd, " ", 1);
149149
shell_escape(&zCmd, zHost);
150150
free(zHost);
151
- /* printf("%s\n", blob_str(&zCmd)); */
151
+ /* printf("%s\n", blob_str(&zCmd)); */
152152
popen2(blob_str(&zCmd), &sshIn, &sshOut, &sshPid);
153153
if( sshPid==0 ){
154154
fossil_fatal("cannot start ssh tunnel using [%b]", &zCmd);
155155
}
156156
blob_reset(&zCmd);
@@ -158,15 +158,17 @@
158158
/* Send an "echo" command to the other side to make sure that the
159159
** connection is up and working.
160160
*/
161161
fprintf(sshOut, "echo test\n");
162162
fflush(sshOut);
163
- sshin_read(zIn, sizeof(zIn));
163
+ zIn = fossil_malloc(16000);
164
+ sshin_read(zIn, 16000);
164165
if( memcmp(zIn, "test", 4)!=0 ){
165166
pclose2(sshIn, sshOut, sshPid);
166167
fossil_fatal("ssh connection failed: [%s]", zIn);
167168
}
169
+ fossil_free(zIn);
168170
}
169171
}
170172
171173
/*
172174
** Open a connection to the server. The server is defined by the following
@@ -185,11 +187,11 @@
185187
Blob cmd;
186188
blob_zero(&cmd);
187189
shell_escape(&cmd, g.urlFossil);
188190
blob_append(&cmd, " test-http ", -1);
189191
shell_escape(&cmd, g.urlPath);
190
- /* fprintf(stdout, "%s\n", blob_str(&cmd)); */
192
+ /* printf("%s\n", blob_str(&cmd)); fflush(stdout); */
191193
fprintf(sshOut, "%s\n", blob_str(&cmd));
192194
fflush(sshOut);
193195
blob_reset(&cmd);
194196
}else if( g.urlIsHttps ){
195197
#ifdef FOSSIL_ENABLE_SSL
@@ -339,10 +341,11 @@
339341
int got;
340342
if( sshIn ){
341343
int x;
342344
int wanted = N;
343345
got = 0;
346
+ /* printf("want %d bytes...\n", wanted); fflush(stdout); */
344347
while( wanted>0 ){
345348
x = read(sshIn, &zBuf[got], wanted);
346349
if( x<=0 ) break;
347350
got += x;
348351
wanted -= x;
@@ -356,11 +359,11 @@
356359
}else if( g.urlIsFile ){
357360
got = fread(zBuf, 1, N, transport.pFile);
358361
}else{
359362
got = socket_receive(0, zBuf, N);
360363
}
361
- /* printf("received %d of %d bytes\n", got, N); fflush(stdout); */
364
+ /* printf("received %d of %d bytes\n", got, N); fflush(stdout); */
362365
if( transport.pLog ){
363366
fwrite(zBuf, 1, got, transport.pLog);
364367
fflush(transport.pLog);
365368
}
366369
return got;
@@ -373,11 +376,11 @@
373376
int transport_receive(char *zBuf, int N){
374377
int onHand; /* Bytes current held in the transport buffer */
375378
int nByte = 0; /* Bytes of content received */
376379
377380
onHand = transport.nUsed - transport.iCursor;
378
- /* printf("request %d with %d on hand\n", N, onHand); fflush(stdout); */
381
+ /* printf("request %d with %d on hand\n", N, onHand); fflush(stdout); */
379382
if( onHand>0 ){
380383
int toMove = onHand;
381384
if( toMove>N ) toMove = N;
382385
/* printf("bytes on hand: %d of %d\n", toMove, N); fflush(stdout); */
383386
memcpy(zBuf, &transport.pBuf[transport.iCursor], toMove);
@@ -447,11 +450,11 @@
447450
int iStart;
448451
449452
i = iStart = transport.iCursor;
450453
while(1){
451454
if( i >= transport.nUsed ){
452
- transport_load_buffer(1000);
455
+ transport_load_buffer(g.urlIsSsh ? 2 : 1000);
453456
i -= iStart;
454457
iStart = 0;
455458
if( i >= transport.nUsed ){
456459
transport.pBuf[i] = 0;
457460
transport.iCursor = i;
@@ -466,11 +469,11 @@
466469
}
467470
break;
468471
}
469472
i++;
470473
}
471
- /* printf("Got line: [%s]\n", &transport.pBuf[iStart]); */
474
+ /* printf("Got line: [%s]\n", &transport.pBuf[iStart]); */
472475
return &transport.pBuf[iStart];
473476
}
474477
475478
void transport_global_shutdown(void){
476479
if( g.urlIsSsh && sshPid ){
477480
--- src/http_transport.c
+++ src/http_transport.c
@@ -109,19 +109,19 @@
109 ** and run an SSH command to talk to the remote machine.
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[200]; /* 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__
120 blob_appendf(&zCmd, " -P %d", g.urlPort);
121 #else
122 blob_appendf(&zCmd, " -p %d", g.urlPort);
123 #endif
124 }
125 if( g.urlUser && g.urlUser[0] ){
126 zHost = mprintf("%s@%s", g.urlUser, g.urlName);
127 #ifdef __MINGW32__
@@ -146,11 +146,11 @@
146 zHost = mprintf("%s", g.urlName);
147 }
148 blob_append(&zCmd, " ", 1);
149 shell_escape(&zCmd, zHost);
150 free(zHost);
151 /* printf("%s\n", blob_str(&zCmd)); */
152 popen2(blob_str(&zCmd), &sshIn, &sshOut, &sshPid);
153 if( sshPid==0 ){
154 fossil_fatal("cannot start ssh tunnel using [%b]", &zCmd);
155 }
156 blob_reset(&zCmd);
@@ -158,15 +158,17 @@
158 /* Send an "echo" command to the other side to make sure that the
159 ** connection is up and working.
160 */
161 fprintf(sshOut, "echo test\n");
162 fflush(sshOut);
163 sshin_read(zIn, sizeof(zIn));
 
164 if( memcmp(zIn, "test", 4)!=0 ){
165 pclose2(sshIn, sshOut, sshPid);
166 fossil_fatal("ssh connection failed: [%s]", zIn);
167 }
 
168 }
169 }
170
171 /*
172 ** Open a connection to the server. The server is defined by the following
@@ -185,11 +187,11 @@
185 Blob cmd;
186 blob_zero(&cmd);
187 shell_escape(&cmd, g.urlFossil);
188 blob_append(&cmd, " test-http ", -1);
189 shell_escape(&cmd, g.urlPath);
190 /* fprintf(stdout, "%s\n", blob_str(&cmd)); */
191 fprintf(sshOut, "%s\n", blob_str(&cmd));
192 fflush(sshOut);
193 blob_reset(&cmd);
194 }else if( g.urlIsHttps ){
195 #ifdef FOSSIL_ENABLE_SSL
@@ -339,10 +341,11 @@
339 int got;
340 if( sshIn ){
341 int x;
342 int wanted = N;
343 got = 0;
 
344 while( wanted>0 ){
345 x = read(sshIn, &zBuf[got], wanted);
346 if( x<=0 ) break;
347 got += x;
348 wanted -= x;
@@ -356,11 +359,11 @@
356 }else if( g.urlIsFile ){
357 got = fread(zBuf, 1, N, transport.pFile);
358 }else{
359 got = socket_receive(0, zBuf, N);
360 }
361 /* printf("received %d of %d bytes\n", got, N); fflush(stdout); */
362 if( transport.pLog ){
363 fwrite(zBuf, 1, got, transport.pLog);
364 fflush(transport.pLog);
365 }
366 return got;
@@ -373,11 +376,11 @@
373 int transport_receive(char *zBuf, int N){
374 int onHand; /* Bytes current held in the transport buffer */
375 int nByte = 0; /* Bytes of content received */
376
377 onHand = transport.nUsed - transport.iCursor;
378 /* printf("request %d with %d on hand\n", N, onHand); fflush(stdout); */
379 if( onHand>0 ){
380 int toMove = onHand;
381 if( toMove>N ) toMove = N;
382 /* printf("bytes on hand: %d of %d\n", toMove, N); fflush(stdout); */
383 memcpy(zBuf, &transport.pBuf[transport.iCursor], toMove);
@@ -447,11 +450,11 @@
447 int iStart;
448
449 i = iStart = transport.iCursor;
450 while(1){
451 if( i >= transport.nUsed ){
452 transport_load_buffer(1000);
453 i -= iStart;
454 iStart = 0;
455 if( i >= transport.nUsed ){
456 transport.pBuf[i] = 0;
457 transport.iCursor = i;
@@ -466,11 +469,11 @@
466 }
467 break;
468 }
469 i++;
470 }
471 /* printf("Got line: [%s]\n", &transport.pBuf[iStart]); */
472 return &transport.pBuf[iStart];
473 }
474
475 void transport_global_shutdown(void){
476 if( g.urlIsSsh && sshPid ){
477
--- src/http_transport.c
+++ src/http_transport.c
@@ -109,19 +109,19 @@
109 ** and run an SSH command to talk to the remote machine.
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__
120 blob_appendf(&zCmd, " -T -P %d", g.urlPort);
121 #else
122 blob_appendf(&zCmd, " -e none -T -p %d", g.urlPort);
123 #endif
124 }
125 if( g.urlUser && g.urlUser[0] ){
126 zHost = mprintf("%s@%s", g.urlUser, g.urlName);
127 #ifdef __MINGW32__
@@ -146,11 +146,11 @@
146 zHost = mprintf("%s", g.urlName);
147 }
148 blob_append(&zCmd, " ", 1);
149 shell_escape(&zCmd, zHost);
150 free(zHost);
151 /* printf("%s\n", blob_str(&zCmd)); */
152 popen2(blob_str(&zCmd), &sshIn, &sshOut, &sshPid);
153 if( sshPid==0 ){
154 fossil_fatal("cannot start ssh tunnel using [%b]", &zCmd);
155 }
156 blob_reset(&zCmd);
@@ -158,15 +158,17 @@
158 /* Send an "echo" command to the other side to make sure that the
159 ** connection is up and working.
160 */
161 fprintf(sshOut, "echo test\n");
162 fflush(sshOut);
163 zIn = fossil_malloc(16000);
164 sshin_read(zIn, 16000);
165 if( memcmp(zIn, "test", 4)!=0 ){
166 pclose2(sshIn, sshOut, sshPid);
167 fossil_fatal("ssh connection failed: [%s]", zIn);
168 }
169 fossil_free(zIn);
170 }
171 }
172
173 /*
174 ** Open a connection to the server. The server is defined by the following
@@ -185,11 +187,11 @@
187 Blob cmd;
188 blob_zero(&cmd);
189 shell_escape(&cmd, g.urlFossil);
190 blob_append(&cmd, " test-http ", -1);
191 shell_escape(&cmd, g.urlPath);
192 /* printf("%s\n", blob_str(&cmd)); fflush(stdout); */
193 fprintf(sshOut, "%s\n", blob_str(&cmd));
194 fflush(sshOut);
195 blob_reset(&cmd);
196 }else if( g.urlIsHttps ){
197 #ifdef FOSSIL_ENABLE_SSL
@@ -339,10 +341,11 @@
341 int got;
342 if( sshIn ){
343 int x;
344 int wanted = N;
345 got = 0;
346 /* printf("want %d bytes...\n", wanted); fflush(stdout); */
347 while( wanted>0 ){
348 x = read(sshIn, &zBuf[got], wanted);
349 if( x<=0 ) break;
350 got += x;
351 wanted -= x;
@@ -356,11 +359,11 @@
359 }else if( g.urlIsFile ){
360 got = fread(zBuf, 1, N, transport.pFile);
361 }else{
362 got = socket_receive(0, zBuf, N);
363 }
364 /* printf("received %d of %d bytes\n", got, N); fflush(stdout); */
365 if( transport.pLog ){
366 fwrite(zBuf, 1, got, transport.pLog);
367 fflush(transport.pLog);
368 }
369 return got;
@@ -373,11 +376,11 @@
376 int transport_receive(char *zBuf, int N){
377 int onHand; /* Bytes current held in the transport buffer */
378 int nByte = 0; /* Bytes of content received */
379
380 onHand = transport.nUsed - transport.iCursor;
381 /* printf("request %d with %d on hand\n", N, onHand); fflush(stdout); */
382 if( onHand>0 ){
383 int toMove = onHand;
384 if( toMove>N ) toMove = N;
385 /* printf("bytes on hand: %d of %d\n", toMove, N); fflush(stdout); */
386 memcpy(zBuf, &transport.pBuf[transport.iCursor], toMove);
@@ -447,11 +450,11 @@
450 int iStart;
451
452 i = iStart = transport.iCursor;
453 while(1){
454 if( i >= transport.nUsed ){
455 transport_load_buffer(g.urlIsSsh ? 2 : 1000);
456 i -= iStart;
457 iStart = 0;
458 if( i >= transport.nUsed ){
459 transport.pBuf[i] = 0;
460 transport.iCursor = i;
@@ -466,11 +469,11 @@
469 }
470 break;
471 }
472 i++;
473 }
474 /* printf("Got line: [%s]\n", &transport.pBuf[iStart]); */
475 return &transport.pBuf[iStart];
476 }
477
478 void transport_global_shutdown(void){
479 if( g.urlIsSsh && sshPid ){
480

Keyboard Shortcuts

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