5 * First, make it shell-safe. We do this by just disallowing any
6 * special characters. Somebody who cares can do escaping and let
7 * through the rest. But since we're doing to feed this to ssh as
8 * a command line, we're going to be pretty damn anal for now.
10 static char *shell_safe(char *url)
14 static const char flags[256] = {
23 while ((c = *n++) != 0) {
25 die("I don't like '%c'. Sue me.", c);
31 * Yeah, yeah, fixme. Need to pass in the heads etc.
33 int git_connect(int fd[2], char *url, const char *prog)
36 const char *host, *path;
41 url = shell_safe(url);
44 colon = strchr(url, ':');
50 snprintf(command, sizeof(command), "%s %s", prog, path);
51 if (pipe(pipefd[0]) < 0 || pipe(pipefd[1]) < 0)
52 die("unable to create pipe pair for communication");
55 dup2(pipefd[1][0], 0);
56 dup2(pipefd[0][1], 1);
62 execlp("ssh", "ssh", host, command, NULL);
64 execlp("sh", "sh", "-c", command, NULL);
74 int finish_connect(pid_t pid)
79 ret = waitpid(pid, NULL, 0);