Fossil SCM
For the ssh: transport method, use the -T option to disable pseudottys. Increase the size of the buffer for holding the MOTD.
Commit
7c8519003de911f5cba05af7e04f3b73af79db13
Parent
352066b267c392f…
1 file changed
+13
-10
+13
-10
| --- src/http_transport.c | ||
| +++ src/http_transport.c | ||
| @@ -109,19 +109,19 @@ | ||
| 109 | 109 | ** and run an SSH command to talk to the remote machine. |
| 110 | 110 | */ |
| 111 | 111 | const char *zSsh; /* The base SSH command */ |
| 112 | 112 | Blob zCmd; /* The SSH command */ |
| 113 | 113 | 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 */ | |
| 115 | 115 | |
| 116 | 116 | zSsh = db_get("ssh-command", zDefaultSshCmd); |
| 117 | 117 | blob_init(&zCmd, zSsh, -1); |
| 118 | 118 | if( g.urlPort!=g.urlDfltPort ){ |
| 119 | 119 | #ifdef __MINGW32__ |
| 120 | - blob_appendf(&zCmd, " -P %d", g.urlPort); | |
| 120 | + blob_appendf(&zCmd, " -T -P %d", g.urlPort); | |
| 121 | 121 | #else |
| 122 | - blob_appendf(&zCmd, " -p %d", g.urlPort); | |
| 122 | + blob_appendf(&zCmd, " -e none -T -p %d", g.urlPort); | |
| 123 | 123 | #endif |
| 124 | 124 | } |
| 125 | 125 | if( g.urlUser && g.urlUser[0] ){ |
| 126 | 126 | zHost = mprintf("%s@%s", g.urlUser, g.urlName); |
| 127 | 127 | #ifdef __MINGW32__ |
| @@ -146,11 +146,11 @@ | ||
| 146 | 146 | zHost = mprintf("%s", g.urlName); |
| 147 | 147 | } |
| 148 | 148 | blob_append(&zCmd, " ", 1); |
| 149 | 149 | shell_escape(&zCmd, zHost); |
| 150 | 150 | free(zHost); |
| 151 | - /* printf("%s\n", blob_str(&zCmd)); */ | |
| 151 | + /* printf("%s\n", blob_str(&zCmd)); */ | |
| 152 | 152 | popen2(blob_str(&zCmd), &sshIn, &sshOut, &sshPid); |
| 153 | 153 | if( sshPid==0 ){ |
| 154 | 154 | fossil_fatal("cannot start ssh tunnel using [%b]", &zCmd); |
| 155 | 155 | } |
| 156 | 156 | blob_reset(&zCmd); |
| @@ -158,15 +158,17 @@ | ||
| 158 | 158 | /* Send an "echo" command to the other side to make sure that the |
| 159 | 159 | ** connection is up and working. |
| 160 | 160 | */ |
| 161 | 161 | fprintf(sshOut, "echo test\n"); |
| 162 | 162 | fflush(sshOut); |
| 163 | - sshin_read(zIn, sizeof(zIn)); | |
| 163 | + zIn = fossil_malloc(16000); | |
| 164 | + sshin_read(zIn, 16000); | |
| 164 | 165 | if( memcmp(zIn, "test", 4)!=0 ){ |
| 165 | 166 | pclose2(sshIn, sshOut, sshPid); |
| 166 | 167 | fossil_fatal("ssh connection failed: [%s]", zIn); |
| 167 | 168 | } |
| 169 | + fossil_free(zIn); | |
| 168 | 170 | } |
| 169 | 171 | } |
| 170 | 172 | |
| 171 | 173 | /* |
| 172 | 174 | ** Open a connection to the server. The server is defined by the following |
| @@ -185,11 +187,11 @@ | ||
| 185 | 187 | Blob cmd; |
| 186 | 188 | blob_zero(&cmd); |
| 187 | 189 | shell_escape(&cmd, g.urlFossil); |
| 188 | 190 | blob_append(&cmd, " test-http ", -1); |
| 189 | 191 | shell_escape(&cmd, g.urlPath); |
| 190 | - /* fprintf(stdout, "%s\n", blob_str(&cmd)); */ | |
| 192 | + /* printf("%s\n", blob_str(&cmd)); fflush(stdout); */ | |
| 191 | 193 | fprintf(sshOut, "%s\n", blob_str(&cmd)); |
| 192 | 194 | fflush(sshOut); |
| 193 | 195 | blob_reset(&cmd); |
| 194 | 196 | }else if( g.urlIsHttps ){ |
| 195 | 197 | #ifdef FOSSIL_ENABLE_SSL |
| @@ -339,10 +341,11 @@ | ||
| 339 | 341 | int got; |
| 340 | 342 | if( sshIn ){ |
| 341 | 343 | int x; |
| 342 | 344 | int wanted = N; |
| 343 | 345 | got = 0; |
| 346 | + /* printf("want %d bytes...\n", wanted); fflush(stdout); */ | |
| 344 | 347 | while( wanted>0 ){ |
| 345 | 348 | x = read(sshIn, &zBuf[got], wanted); |
| 346 | 349 | if( x<=0 ) break; |
| 347 | 350 | got += x; |
| 348 | 351 | wanted -= x; |
| @@ -356,11 +359,11 @@ | ||
| 356 | 359 | }else if( g.urlIsFile ){ |
| 357 | 360 | got = fread(zBuf, 1, N, transport.pFile); |
| 358 | 361 | }else{ |
| 359 | 362 | got = socket_receive(0, zBuf, N); |
| 360 | 363 | } |
| 361 | - /* printf("received %d of %d bytes\n", got, N); fflush(stdout); */ | |
| 364 | + /* printf("received %d of %d bytes\n", got, N); fflush(stdout); */ | |
| 362 | 365 | if( transport.pLog ){ |
| 363 | 366 | fwrite(zBuf, 1, got, transport.pLog); |
| 364 | 367 | fflush(transport.pLog); |
| 365 | 368 | } |
| 366 | 369 | return got; |
| @@ -373,11 +376,11 @@ | ||
| 373 | 376 | int transport_receive(char *zBuf, int N){ |
| 374 | 377 | int onHand; /* Bytes current held in the transport buffer */ |
| 375 | 378 | int nByte = 0; /* Bytes of content received */ |
| 376 | 379 | |
| 377 | 380 | 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); */ | |
| 379 | 382 | if( onHand>0 ){ |
| 380 | 383 | int toMove = onHand; |
| 381 | 384 | if( toMove>N ) toMove = N; |
| 382 | 385 | /* printf("bytes on hand: %d of %d\n", toMove, N); fflush(stdout); */ |
| 383 | 386 | memcpy(zBuf, &transport.pBuf[transport.iCursor], toMove); |
| @@ -447,11 +450,11 @@ | ||
| 447 | 450 | int iStart; |
| 448 | 451 | |
| 449 | 452 | i = iStart = transport.iCursor; |
| 450 | 453 | while(1){ |
| 451 | 454 | if( i >= transport.nUsed ){ |
| 452 | - transport_load_buffer(1000); | |
| 455 | + transport_load_buffer(g.urlIsSsh ? 2 : 1000); | |
| 453 | 456 | i -= iStart; |
| 454 | 457 | iStart = 0; |
| 455 | 458 | if( i >= transport.nUsed ){ |
| 456 | 459 | transport.pBuf[i] = 0; |
| 457 | 460 | transport.iCursor = i; |
| @@ -466,11 +469,11 @@ | ||
| 466 | 469 | } |
| 467 | 470 | break; |
| 468 | 471 | } |
| 469 | 472 | i++; |
| 470 | 473 | } |
| 471 | - /* printf("Got line: [%s]\n", &transport.pBuf[iStart]); */ | |
| 474 | + /* printf("Got line: [%s]\n", &transport.pBuf[iStart]); */ | |
| 472 | 475 | return &transport.pBuf[iStart]; |
| 473 | 476 | } |
| 474 | 477 | |
| 475 | 478 | void transport_global_shutdown(void){ |
| 476 | 479 | if( g.urlIsSsh && sshPid ){ |
| 477 | 480 |
| --- 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 |