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..
Commit
531a58fd2178c56bb448414a71b7e943d6eadac9
Parent
e8fac25a20c840f…
1 file changed
+23
-6
+23
-6
| --- src/http_transport.c | ||
| +++ src/http_transport.c | ||
| @@ -149,21 +149,30 @@ | ||
| 149 | 149 | free(zHost); |
| 150 | 150 | |
| 151 | 151 | /* Append fossil test-http command directly during the invocation of ssh, |
| 152 | 152 | ** to make sure no output from shell or login will pollute the sshIn pipe. |
| 153 | 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); | |
| 154 | + blob_append(&zCmd, " /bin/sh", -1); | |
| 159 | 155 | |
| 160 | 156 | popen2(blob_str(&zCmd), &sshIn, &sshOut, &sshPid); |
| 161 | 157 | if( sshPid==0 ){ |
| 162 | 158 | fossil_fatal("cannot start ssh tunnel using [%b]", &zCmd); |
| 163 | 159 | } |
| 164 | 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); | |
| 165 | 174 | } |
| 166 | 175 | } |
| 167 | 176 | |
| 168 | 177 | /* |
| 169 | 178 | ** Open a connection to the server. The server is defined by the following |
| @@ -177,11 +186,19 @@ | ||
| 177 | 186 | */ |
| 178 | 187 | int transport_open(void){ |
| 179 | 188 | int rc = 0; |
| 180 | 189 | if( transport.isOpen==0 ){ |
| 181 | 190 | 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); | |
| 183 | 200 | }else if( g.urlIsHttps ){ |
| 184 | 201 | #ifdef FOSSIL_ENABLE_SSL |
| 185 | 202 | rc = ssl_open(); |
| 186 | 203 | if( rc==0 ) transport.isOpen = 1; |
| 187 | 204 | #else |
| 188 | 205 |
| --- 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 |