git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: "Publishing your work" questions?

From
Linus Torvalds <torvalds@osdl.org>
Date
Aug 20, 2005, 16:12 UTC
Message-ID
<Pine.LNX.4.58.0508200911250.3317@g5.osdl.org>
In-Reply-To
<Pine.LNX.4.58.0508200821220.3317@g5.osdl.org>
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);
}
Previous: Linus TorvaldsNext: Junio C Hamano
Message 3 of 4 in “"Publishing your work" questions?”
  1. Alan ChandlerAug 20, 2005
  2. Linus TorvaldsAug 20, 2005
  3. Linus TorvaldsAug 20, 2005
  4. Junio C HamanoAug 20, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.