git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Sixt <j.sixt@viscovery.net>
To: "Johan Sørensen" <johan@johansorensen.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Introduce a filter-path argument to git-daemon, for doing custom path transformations
Date: Wed, 11 Mar 2009 16:58:25 +0100	[thread overview]
Message-ID: <49B7DFA1.4030409@viscovery.net> (raw)
In-Reply-To: <1236784647-71388-1-git-send-email-johan@johansorensen.com>

Johan Sørensen schrieb:
> The argument is an executable script that will receive the path to the repos
> the client wishes to clone as an argument. It is then the responsibility of the
> script to return a zero-terminated string on its stdout with the real path of
> the target repository.
> 
> This buys us a lot of flexibility when it comes to managing different
> repositories, possibly located in many different dirs, but with a uniform
> url-structure to the outside world.

It's the first time that I see a deamon with this feature - except perhaps
Apache's ModRewrite. Are you sure you are not working around your problem
at the wrong place?

Doesn't --interpolated-path already solve your problem? If not, then you
at least you must describe in the documentation the use-cases when
--path-filter should be preferred.

Your implementation does not pass the target hostname to the script, but
it should; otherwise you lose flexibility (for virtual hosting).

> +static char *run_path_filter_script(char *requested_dir) {
> +	pid_t pid;
> +	char result[256]; /* arbitary */
> +	char *real_path;
> +	int pipe_out[2];
> +	int exit_code = 1;
> +
> +	pipe(pipe_out);
> +
> +	loginfo("Executing path filter script: '%s %s'", path_filter_script, requested_dir);
> +
> +	switch ((pid = fork())) {
> +		case -1:
> +			logerror("path filter script fork() failed: %s", strerror(errno));
> +			return NULL;
> +		case 0:
> +		close(pipe_out[0]);
> +		dup2(pipe_out[1], 1);
> +		close(pipe_out[1]);
> +
> +		execl(path_filter_script, path_filter_script, requested_dir, NULL);

Use start_command()/finish_command() instead of rolling your own fork/exec
combo.

-- Hannes

  reply	other threads:[~2009-03-11 16:00 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-11 15:17 [PATCH] Introduce a filter-path argument to git-daemon, for doing custom path transformations Johan Sørensen
2009-03-11 15:58 ` Johannes Sixt [this message]
2009-03-12 10:13   ` Johan Sørensen
2009-03-12 11:29     ` Johannes Schindelin
2009-03-12 15:48       ` Johan Sørensen
2009-03-12 16:50         ` Johannes Schindelin
2009-03-12 19:06       ` Johan Sørensen
2009-03-14  6:58         ` Junio C Hamano
2009-03-14 14:39           ` Johan Sørensen
2009-03-14 18:23             ` Junio C Hamano
2009-03-19  0:15               ` Johannes Schindelin
2009-03-19 13:02                 ` Johan Sørensen
2009-03-20 22:27                   ` Johannes Schindelin
2009-03-12 10:26   ` Johan Sørensen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=49B7DFA1.4030409@viscovery.net \
    --to=j.sixt@viscovery.net \
    --cc=git@vger.kernel.org \
    --cc=johan@johansorensen.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).