git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Franck Bui-Huu <vagabon.xyz@gmail.com>
To: Franck Bui-Huu <vagabon.xyz@gmail.com>
Cc: junkio@cox.net, git@vger.kernel.org
Subject: Re: [PATCH 1/3] daemon.c: introduce daemon's service
Date: Thu, 31 Aug 2006 15:07:00 +0200	[thread overview]
Message-ID: <44F6DEF4.6000609@innova-card.com> (raw)
In-Reply-To: <1157027723594-git-send-email-vagabon.xyz@gmail.com>

Franck Bui-Huu wrote:
> Signed-off-by: Franck Bui-Huu <vagabon.xyz@gmail.com>
> ---
>  daemon.c |   78 ++++++++++++++++++++++++++++++++++++++++++++++++--------------
>  1 files changed, 61 insertions(+), 17 deletions(-)
> 
> diff --git a/daemon.c b/daemon.c
> index 66ec830..ed3a13d 100644
> --- a/daemon.c
> +++ b/daemon.c
> @@ -232,16 +232,57 @@ static char *path_ok(char *dir)
>  	return NULL;		/* Fallthrough. Deny by default */
>  }
>  
> -static int upload(char *dir)
> +/*
> + * Services we're able to deal with.
> + */
> +static int service_upload_pack(const char *dir, const char *args)
>  {
>  	/* Timeout as string */
>  	char timeout_buf[64];
> +
> +	snprintf(timeout_buf, sizeof timeout_buf, "--timeout=%u", timeout);
> +
> +	/* git-upload-pack only ever reads stuff, so this is safe */
> +	execl_git_cmd("upload-pack", "--strict", timeout_buf, ".", NULL);
> +	return -1;
> +}
> +
> +/* service options */
> +#define NEED_REPO	(1<<0)
> +
> +struct service_info {
> +	const char *name;
> +	int (*fn)(const char *dir, const char *args);
> +	int options;
> +};
> +
> +static struct service_info services[] = {
> +	{ "git-upload-pack", service_upload_pack, NEED_REPO },
> +};
> +
> +static int run_service(char *cmdline)
> +{
> +	struct service_info *serv;
>  	const char *path;
> +	size_t len;
> +	int i;
>  
> -	loginfo("Request for '%s'", dir);
> +	for (i = 0; i < ARRAY_SIZE(services); i++) {
> +		serv = &services[i];
> +		

OMG, trailing white spaces !

> +		len = strlen(serv->name);
> +		if (strncmp(cmdline, serv->name, len))
> +			continue;
> +		if (cmdline[len] != ' ')
> +			continue;
> +		goto found;
> +	}
> +	return -1;
> +found:
> +	cmdline += len + 1;
> +	path = NULL;
>  
> -	if (!(path = path_ok(dir)))
> -		return -1;
> +	loginfo("Request '%s' for '%s'", serv->name, cmdline);
>  
>  	/*
>  	 * Security on the cheap.
> @@ -253,30 +294,33 @@ static int upload(char *dir)
>  	 * path_ok() uses enter_repo() and does whitelist checking.
>  	 * We only need to make sure the repository is exported.
>  	 */
> +	if (serv->options & NEED_REPO) {
> +		if (!(path = path_ok(cmdline)))
> +			return -1;
>  
> -	if (!export_all_trees && access("git-daemon-export-ok", F_OK)) {
> -		logerror("'%s': repository not exported.", path);
> -		errno = EACCES;
> -		return -1;
> +		if (!export_all_trees && access("git-daemon-export-ok", F_OK)) {
> +			logerror("'%s': repository not exported.", path);
> +			errno = EACCES;
> +			return -1;
> +		}
> +		cmdline += strlen(path) + 1;
>  	}
> -
> +	

ditto

		Franck

  reply	other threads:[~2006-08-31 13:07 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-31 12:35 [PATCH 0/3] git-daemon: plug new upload-tar command Franck Bui-Huu
2006-08-31 12:35 ` [PATCH 1/3] daemon.c: introduce daemon's service Franck Bui-Huu
2006-08-31 13:07   ` Franck Bui-Huu [this message]
2006-08-31 15:15     ` [PATCH 1/3] daemon.c: introduce daemon's service [take #2] Franck Bui-Huu
2006-08-31 12:35 ` [PATCH 2/3] daemon.c: added upload-tar service Franck Bui-Huu
2006-08-31 12:35 ` [PATCH 3/3] git-tar-tree.c: no need to be in a git repo when using --remote Franck Bui-Huu
2006-08-31 17:45 ` [PATCH 0/3] git-daemon: plug new upload-tar command Rene Scharfe
2006-09-02  8:14   ` Franck Bui-Huu
2006-09-02 10:32     ` Junio C Hamano
2006-09-02 10:36       ` Jakub Narebski
2006-09-02 20:12       ` Franck Bui-Huu

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=44F6DEF4.6000609@innova-card.com \
    --to=vagabon.xyz@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    /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).