summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4dbd135)
raw | patch | inline | side by side (parent: 4dbd135)
author | Junio C Hamano <junkio@cox.net> | |
Mon, 21 Nov 2005 09:21:18 +0000 (01:21 -0800) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Mon, 21 Nov 2005 21:47:00 +0000 (13:47 -0800) |
- Do validation only on canonicalized paths
- Run upload-pack with "." as repository argument
Signed-off-by: Junio C Hamano <junkio@cox.net>
- Run upload-pack with "." as repository argument
Signed-off-by: Junio C Hamano <junkio@cox.net>
Documentation/git-daemon.txt | patch | blob | history | |
daemon.c | patch | blob | history |
index 972e0e1571391efb6041f0e7bff5df18fb1a4eaf..2a8f371ec95b619bcfb3fc289770ab7ef929214d 100644 (file)
SYNOPSIS
--------
'git-daemon' [--verbose] [--syslog] [--inetd | --port=n] [--export-all]
- [--timeout=n] [--init-timeout=n] [directory...]
+ [--timeout=n] [--init-timeout=n] [--strict-paths] [directory...]
DESCRIPTION
-----------
OPTIONS
-------
-+--strict-paths::
+--strict-paths::
Match paths exactly (i.e. don't allow "/foo/repo" when the real path is
"/foo/repo.git" or "/foo/repo/.git") and don't do user-relative paths.
git-daemon will refuse to start when this option is enabled and no
diff --git a/daemon.c b/daemon.c
index ac4c94bc709350471d66180d427a7e5df91c6235..d788167ae0bbce0995329e0263e7082513087441 100644 (file)
--- a/daemon.c
+++ b/daemon.c
}
if ( ok_paths && *ok_paths ) {
- char **pp = NULL;
- int dirlen = strlen(dir);
+ char **pp;
int pathlen = strlen(path);
+ /* The validation is done on the paths after enter_repo
+ * canonicalization, so whitelist should be written in
+ * terms of real pathnames (i.e. after ~user is expanded
+ * and symlinks resolved).
+ */
for ( pp = ok_paths ; *pp ; pp++ ) {
int len = strlen(*pp);
- /* because of symlinks we must match both what the
- * user passed and the canonicalized path, otherwise
- * the user can send a string matching either a whitelist
- * entry or an actual directory exactly and still not
- * get through */
- if (len <= pathlen && !memcmp(*pp, path, len)) {
- if (path[len] == '\0' || (!strict_paths && path[len] == '/'))
- return path;
- }
- if (len <= dirlen && !memcmp(*pp, dir, len)) {
- if (dir[len] == '\0' || (!strict_paths && dir[len] == '/'))
- return path;
- }
+ if (len <= pathlen &&
+ !memcmp(*pp, path, len) &&
+ (path[len] == '\0' ||
+ (!strict_paths && path[len] == '/')))
+ return path;
}
}
else {
snprintf(timeout_buf, sizeof timeout_buf, "--timeout=%u", timeout);
/* git-upload-pack only ever reads stuff, so this is safe */
- execlp("git-upload-pack", "git-upload-pack", "--strict", timeout_buf, path, NULL);
+ execlp("git-upload-pack", "git-upload-pack", "--strict", timeout_buf, ".", NULL);
return -1;
}