From: Aneesh Bhasin <contact.aneesh@gmail.com>
To: git@vger.kernel.org
Subject: patch for git-daemon base-path trailing '/' problem
Date: Sat, 23 May 2009 21:03:18 +0530 [thread overview]
Message-ID: <f662f0210905230833p781d8e7ck77a40b4cd58a799d@mail.gmail.com> (raw)
Hi All,
I was trying to setup git-daemon on our server with the following args :
git-daemon --base-path=/git_repo/ --export-all --syslog --inetd
--verbose /git_repo/external_repos/
There are two git repos in /git_repo/external_repos/ :-
linux-test/.git and linux-release/.git
When I try to clone the linux-test/.git repo using :
git clone 192.168.1.100/external_repos/linux-test
I get an error at the server side from git-daemon saying that
"/git_repo//external/repos/linux-test/.git not in whitelist".
The problem is because fo the trailing '/' in base-path in git-daemon
args. I think it might be fairly common that a person might add a '/'
at the end of base-path. The following patch takes care of this
trailing patch :
diff --git a/daemon.c b/daemon.c
index daa4c8e..cd4dfed 100644
--- a/daemon.c
+++ b/daemon.c
@@ -209,11 +209,15 @@ static char *path_ok(char *directory)
dir = interp_path;
}
else if (base_path) {
+ int base_pathlen;
if (*dir != '/') {
/* Allow only absolute */
logerror("'%s': Non-absolute path denied (base-path acti
return NULL;
}
+ base_pathlen = strlen(base_path);
+ if(base_path[base_pathlen-1]=='/')
+ base_path[base_pathlen-1]='\0';
snprintf(rpath, PATH_MAX, "%s%s", base_path, dir);
dir = rpath;
}
@@ -229,7 +233,7 @@ static char *path_ok(char *directory)
}
---------------------------------------
Regards,
Aneesh Bhasin
reply other threads:[~2009-05-23 15:34 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=f662f0210905230833p781d8e7ck77a40b4cd58a799d@mail.gmail.com \
--to=contact.aneesh@gmail.com \
--cc=git@vger.kernel.org \
/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).