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

Re: [PATCH 3/3] daemon: Support a --user-path option.

From
Junio C Hamano <junkio@cox.net>
Date
Feb 4, 2006, 08:50 UTC
Message-ID
<7v8xsr33ur.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<7vr76kcggx.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano <junkio@cox.net> writes:
> Wouldn't loosening the "request must be absolute if you use
> --base-path" check in the area your first patch in the series
> touches to also allow paths that start with a '~' be enough?
That is, something like this is what I mean.
Tested, of course ;-).
diff --git a/daemon.c b/daemon.c
index 532bb0c..324bb04 100644
--- a/daemon.c
+++ b/daemon.c
@@ -145,13 +145,17 @@ static char *path_ok(char *dir)
 
 	if (base_path) {
 		static char rpath[PATH_MAX];
-		if (*dir != '/') {
-			/* Forbid possible base-path evasion using ~paths. */
+		if (!strict_paths && *dir == '~')
+			; /* allow user relative paths */
+		else if (*dir != '/') {
+			/* otherwise allow only absolute */
 			logerror("'%s': Non-absolute path denied (base-path active)", dir);
 			return NULL;
 		}
-		snprintf(rpath, PATH_MAX, "%s%s", base_path, dir);
-		dir = rpath;
+		else {
+			snprintf(rpath, PATH_MAX, "%s%s", base_path, dir);
+			dir = rpath;
+		}
 	}
 
 	path = enter_repo(dir, strict_paths);
Previous: Junio C HamanoNext: Mark Wooding
Message 9 of 13 in “git-daemon hacking”
  1. 0/3 git-daemon hackingMark Wooding, Feb 3, 2006
  2. 1/3 daemon: Provide missing argument for logerror() call.Mark Wooding, Feb 3, 2006
  3. 2/3 daemon: Set SO_REUSEADDR on listening sockets.Mark Wooding, Feb 3, 2006
  4. Junio C HamanoFeb 3, 2006
  5. Junio C HamanoFeb 4, 2006
  6. Mark WoodingFeb 4, 2006
  7. 3/3 daemon: Support a --user-path option.Mark Wooding, Feb 3, 2006
  8. Junio C HamanoFeb 3, 2006
  9. Junio C HamanoFeb 4, 2006
  10. Mark WoodingFeb 4, 2006
  11. Junio C HamanoFeb 4, 2006
  12. Mark WoodingFeb 4, 2006
  13. Junio C HamanoFeb 4, 2006

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.