5 #include <sys/socket.h>
9 #define COMMAND_SIZE 4096
11 int setup_connection(int *fd_in, int *fd_out, const char *remote_prog,
12 char *url, int rmt_argc, char **rmt_argv)
17 char command[COMMAND_SIZE];
21 if (!strcmp(url, "-")) {
27 host = strstr(url, "//");
30 path = strchr(host, '/');
33 path = strchr(host, ':');
38 return error("Bad URL: %s", url);
40 /* ssh <host> 'cd <path>; stdio-pull <arg...> <commit-id>' */
41 snprintf(command, COMMAND_SIZE,
43 GIT_DIR_ENVIRONMENT, path, remote_prog);
45 posn = command + strlen(command);
46 for (i = 0; i < rmt_argc; i++) {
48 strncpy(posn, rmt_argv[i], COMMAND_SIZE - (posn - command));
49 posn += strlen(rmt_argv[i]);
50 if (posn - command + 4 >= COMMAND_SIZE) {
51 return error("Command line too long");
55 if (socketpair(AF_UNIX, SOCK_STREAM, 0, sv)) {
56 return error("Couldn't create socket");
62 execlp("ssh", "ssh", host, command, NULL);