Fossil

Check-in [531a58fd]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment: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..

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | mg_sshfix
Files: files | file ages | folders
SHA1:531a58fd2178c56bb448414a71b7e943d6eadac9
User & Date: mgagnon 2012-09-12 15:27:25
Context
2012-09-12
16:24
Need this "-e none" options to ssh.. if not, ssh can process the escape caracter to process command from data that's goes to fossil proces.. Closed-Leaf check-in: 297cb3e5 user: mgagnon tags: mg_sshfix
15:27
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.. check-in: 531a58fd user: mgagnon tags: mg_sshfix

12:59
Seems to fix it.. will try on the real conditions.. check-in: e8fac25a user: mgagnon tags: mg_sshfix
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/http_transport.c.

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
...
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:
**
................................................................................
**
** 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
...
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:
**
................................................................................
**
** 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;