147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
|
shell_escape(&zCmd, zHost);
fossil_print(" %s\n", zHost); /* Show the conclusion of the SSH command */
free(zHost);
/* Append fossil test-http command directly during the invocation of ssh,
** to make sure no output from shell or login will pollute the sshIn pipe.
*/
blob_append(&zCmd, " \"", 2);
shell_escape(&zCmd, g.urlFossil);
blob_append(&zCmd, " test-http ", -1);
shell_escape(&zCmd, g.urlPath);
blob_append(&zCmd, "\"", 1);
popen2(blob_str(&zCmd), &sshIn, &sshOut, &sshPid);
if( sshPid==0 ){
fossil_fatal("cannot start ssh tunnel using [%b]", &zCmd);
}
blob_reset(&zCmd);
}
}
/*
** Open a connection to the server. The server is defined by the following
** global variables:
**
** g.urlName Name of the server. Ex: www.fossil-scm.org
** g.urlPort TCP/IP port. Ex: 80
** g.urlIsHttps Use TLS for the connection
**
** Return the number of errors.
*/
int transport_open(void){
int rc = 0;
if( transport.isOpen==0 ){
if( g.urlIsSsh ){
transport.isOpen = 1;
}else if( g.urlIsHttps ){
#ifdef FOSSIL_ENABLE_SSL
rc = ssl_open();
if( rc==0 ) transport.isOpen = 1;
#else
socket_set_errmsg("HTTPS: Fossil has been compiled without SSL support");
rc = 1;
|
|
<
<
<
<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
>
|
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
|
shell_escape(&zCmd, zHost);
fossil_print(" %s\n", zHost); /* Show the conclusion of the SSH command */
free(zHost);
/* Append fossil test-http command directly during the invocation of ssh,
** to make sure no output from shell or login will pollute the sshIn pipe.
*/
blob_append(&zCmd, " /bin/sh", -1);
popen2(blob_str(&zCmd), &sshIn, &sshOut, &sshPid);
if( sshPid==0 ){
fossil_fatal("cannot start ssh tunnel using [%b]", &zCmd);
}
blob_reset(&zCmd);
/* Send an "echo" command to the other side to make sure that the
** connection is up and working.
*/
fprintf(sshOut, "echo test\n");
fflush(sshOut);
zIn = fossil_malloc(16000);
sshin_read(zIn, 16000);
if( memcmp(zIn, "test", 4)!=0 ){
pclose2(sshIn, sshOut, sshPid);
fossil_fatal("ssh connection failed: [%s]", zIn);
}
fossil_free(zIn);
}
}
/*
** Open a connection to the server. The server is defined by the following
** global variables:
**
** g.urlName Name of the server. Ex: www.fossil-scm.org
** g.urlPort TCP/IP port. Ex: 80
** g.urlIsHttps Use TLS for the connection
**
** Return the number of errors.
*/
int transport_open(void){
int rc = 0;
if( transport.isOpen==0 ){
if( g.urlIsSsh ){
Blob cmd;
blob_zero(&cmd);
shell_escape(&cmd, g.urlFossil);
blob_append(&cmd, " test-http ", -1);
shell_escape(&cmd, g.urlPath);
/* printf("%s\n", blob_str(&cmd)); fflush(stdout); */
fprintf(sshOut, "%s\n", blob_str(&cmd));
fflush(sshOut);
blob_reset(&cmd);
}else if( g.urlIsHttps ){
#ifdef FOSSIL_ENABLE_SSL
rc = ssl_open();
if( rc==0 ) transport.isOpen = 1;
#else
socket_set_errmsg("HTTPS: Fossil has been compiled without SSL support");
rc = 1;
|