Fossil SCM

Now, just call /bin/sh as command argument.. I don't have problem with mail checking and motd and modification is very simple.. - Have to check if it work in all conditions and all systems. - Might not work for settups where server use a restricted shell..

mgagnon 2012-09-12 15:27 mg_sshfix
Commit 531a58fd2178c56bb448414a71b7e943d6eadac9
1 file changed +23 -6
--- src/http_transport.c
+++ src/http_transport.c
@@ -149,21 +149,30 @@
149149
free(zHost);
150150
151151
/* Append fossil test-http command directly during the invocation of ssh,
152152
** to make sure no output from shell or login will pollute the sshIn pipe.
153153
*/
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);
154
+ blob_append(&zCmd, " /bin/sh", -1);
159155
160156
popen2(blob_str(&zCmd), &sshIn, &sshOut, &sshPid);
161157
if( sshPid==0 ){
162158
fossil_fatal("cannot start ssh tunnel using [%b]", &zCmd);
163159
}
164160
blob_reset(&zCmd);
161
+
162
+ /* Send an "echo" command to the other side to make sure that the
163
+ ** connection is up and working.
164
+ */
165
+ fprintf(sshOut, "echo test\n");
166
+ fflush(sshOut);
167
+ zIn = fossil_malloc(16000);
168
+ sshin_read(zIn, 16000);
169
+ if( memcmp(zIn, "test", 4)!=0 ){
170
+ pclose2(sshIn, sshOut, sshPid);
171
+ fossil_fatal("ssh connection failed: [%s]", zIn);
172
+ }
173
+ fossil_free(zIn);
165174
}
166175
}
167176
168177
/*
169178
** Open a connection to the server. The server is defined by the following
@@ -177,11 +186,19 @@
177186
*/
178187
int transport_open(void){
179188
int rc = 0;
180189
if( transport.isOpen==0 ){
181190
if( g.urlIsSsh ){
182
- transport.isOpen = 1;
191
+ Blob cmd;
192
+ blob_zero(&cmd);
193
+ shell_escape(&cmd, g.urlFossil);
194
+ blob_append(&cmd, " test-http ", -1);
195
+ shell_escape(&cmd, g.urlPath);
196
+ /* printf("%s\n", blob_str(&cmd)); fflush(stdout); */
197
+ fprintf(sshOut, "%s\n", blob_str(&cmd));
198
+ fflush(sshOut);
199
+ blob_reset(&cmd);
183200
}else if( g.urlIsHttps ){
184201
#ifdef FOSSIL_ENABLE_SSL
185202
rc = ssl_open();
186203
if( rc==0 ) transport.isOpen = 1;
187204
#else
188205
--- src/http_transport.c
+++ src/http_transport.c
@@ -149,21 +149,30 @@
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
@@ -177,11 +186,19 @@
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
--- src/http_transport.c
+++ src/http_transport.c
@@ -149,21 +149,30 @@
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, " /bin/sh", -1);
 
 
 
 
155
156 popen2(blob_str(&zCmd), &sshIn, &sshOut, &sshPid);
157 if( sshPid==0 ){
158 fossil_fatal("cannot start ssh tunnel using [%b]", &zCmd);
159 }
160 blob_reset(&zCmd);
161
162 /* Send an "echo" command to the other side to make sure that the
163 ** connection is up and working.
164 */
165 fprintf(sshOut, "echo test\n");
166 fflush(sshOut);
167 zIn = fossil_malloc(16000);
168 sshin_read(zIn, 16000);
169 if( memcmp(zIn, "test", 4)!=0 ){
170 pclose2(sshIn, sshOut, sshPid);
171 fossil_fatal("ssh connection failed: [%s]", zIn);
172 }
173 fossil_free(zIn);
174 }
175 }
176
177 /*
178 ** Open a connection to the server. The server is defined by the following
@@ -177,11 +186,19 @@
186 */
187 int transport_open(void){
188 int rc = 0;
189 if( transport.isOpen==0 ){
190 if( g.urlIsSsh ){
191 Blob cmd;
192 blob_zero(&cmd);
193 shell_escape(&cmd, g.urlFossil);
194 blob_append(&cmd, " test-http ", -1);
195 shell_escape(&cmd, g.urlPath);
196 /* printf("%s\n", blob_str(&cmd)); fflush(stdout); */
197 fprintf(sshOut, "%s\n", blob_str(&cmd));
198 fflush(sshOut);
199 blob_reset(&cmd);
200 }else if( g.urlIsHttps ){
201 #ifdef FOSSIL_ENABLE_SSL
202 rc = ssl_open();
203 if( rc==0 ) transport.isOpen = 1;
204 #else
205

Keyboard Shortcuts

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