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

Re: [PATCH] git-cvsserver runs hooks/post-update

From
Michael Witten <mfwitten@mit.edu>
Date
Dec 5, 2007, 11:07 UTC
Message-ID
<7245A47D-143F-4DC7-8414-D8C99C0ED9C3@mit.edu>
In-Reply-To
<7v63zdtnjz.fsf@gitster.siamese.dyndns.org>
On 5 Dec 2007, at 5:59:12 AM, Junio C Hamano wrote:
Show 6 quoted lines
> +	### Then hooks/post-update
> +	$hook = $ENV{GIT_DIR}.'hooks/post-update';
> +	if (-x $hook) {
> +		system($hook, "refs/heads/$state->{module}");
> +	}
> +

Firstly, I apologize for not getting this small patch done myself; it's very hectic this time of year.

Secondly, I'd like to recall my unanswered question:
> Also, I explicitly decided to pipe input into post-receive
> by hand rather than relying on a system() call that someone
> might exploit maliciously:
	### Emulate git-receive-pack by running hooks/post-receive
	my $hook = $ENV{GIT_DIR}.'hooks/post-receive';
	if( -x $hook ) {
		open(my $pipe, "| $hook") || die "can't fork $!";
		local $SIG{PIPE} = sub { die 'pipe broke' };
		print $pipe "$parenthash $commithash refs/heads/$state->{module}\n";
		close $pipe || die "bad pipe: $! $?";
	}
Show 7 quoted lines
> Unfortunately, it turns out that open() with a pipe essentially
> invokes system(); the solution is to fork a child process and
> then to turn the child into the process with which communication
> is desired via a call to exec().
>
> Because the rest of git-cvsserver.perl uses explicit system()
> calls, I have been wondering if I am being overly cautious.
Am I being overly cautious?
Previous: Junio C HamanoNext: Junio C Hamano
Message 2 of 3 in “git-cvsserver runs hooks/post-update”
  1. git-cvsserver runs hooks/post-updateJunio C Hamano, Dec 5, 2007
  2. Michael WittenDec 5, 2007
  3. Junio C HamanoDec 5, 2007

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.