On Sat, 20 Aug 2005, Linus Torvalds wrote:
>
> But yes, you _should_ be able to do it with that ultra-simplistic login
> shell. Probably just a 5-liner main() function or something.
This is entirely untested, and a lot more than five lines of code. Edit
until it works.
Linus
----
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
static char *parse_argument(char *orig)
{
int i;
int len = strlen(orig);
/* We only accept properly quoted arguments */
if (len < 2 || orig[0] != '\'' || orig[len-1] != '\'')
exit(2);
orig[len-1] = 0;
orig++;
len -= 2;
/*
* Go look for quoted single-ticks. They are always
* quoted as '\'', we don't accept anything else
*/
for (i = 0; len ; i++, len--) {
char c = orig[i];
if (c != '\'')
continue;
if (len < 4 || memcmp(orig+i, "'\\''", 4))
exit(2);
len -= 3;
memmove(orig+1, orig+4, len+1);
}
return orig;
}
int main(int argc, char **argv)
{
int i;
char *cmd, *arg;
if (argc < 2)
exit(1);
i = 2;
cmd = argv[1];
if (!strcmp(cmd, "-c"))
cmd = argv[i++];
/* We're not going to allow anything else */
if (argc != i)
exit(1);
/*
* Right now we only accept "upload" commands, but
* we could have some maintenance commands too, to
* create new archives or delete old ones..
*/
if (strncmp(cmd, "git-upload-pack ", 16))
exit(1);
arg = parse_argument(cmd+16);
execlp("git-upload-pack", "git-upload-pack", arg, NULL);
exit(3);
}
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html