4 int path_match(const char *path
, int nr
, char **match
)
7 int pathlen
= strlen(path
);
9 for (i
= 0; i
< nr
; i
++) {
13 if (!len
|| len
> pathlen
)
15 if (memcmp(path
+ pathlen
- len
, s
, len
))
17 if (pathlen
> len
&& path
[pathlen
- len
- 1] != '/')
26 * First, make it shell-safe. We do this by just disallowing any
27 * special characters. Somebody who cares can do escaping and let
28 * through the rest. But since we're doing to feed this to ssh as
29 * a command line, we're going to be pretty damn anal for now.
31 static char *shell_safe(char *url
)
35 static const char flags
[256] = {
44 while ((c
= *n
++) != 0) {
46 die("I don't like '%c'. Sue me.", c
);
52 * Yeah, yeah, fixme. Need to pass in the heads etc.
54 int git_connect(int fd
[2], char *url
, const char *prog
)
57 const char *host
, *path
;
62 url
= shell_safe(url
);
65 colon
= strchr(url
, ':');
71 snprintf(command
, sizeof(command
), "%s %s", prog
, path
);
72 if (pipe(pipefd
[0]) < 0 || pipe(pipefd
[1]) < 0)
73 die("unable to create pipe pair for communication");
76 dup2(pipefd
[1][0], 0);
77 dup2(pipefd
[0][1], 1);
83 execlp("ssh", "ssh", host
, command
, NULL
);
85 execlp("sh", "sh", "-c", command
, NULL
);
95 int finish_connect(pid_t pid
)
100 ret
= waitpid(pid
, NULL
, 0);