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

Re: [PATCH 2/2] daemon: Verify base-path and interpolated-path early

From
Johannes Sixt <j.sixt@viscovery.net>
Date
Feb 26, 2008, 12:00 UTC
Message-ID
<47C3FF77.2060902@viscovery.net>
In-Reply-To
<7vejb0j04z.fsf@gitster.siamese.dyndns.org>
Junio C Hamano schrieb:
Show 10 quoted lines
> Johannes Sixt <j.sixt@viscovery.net> writes:
> 
>> Any request to the daemon would fail if either interpolated-path or
>> base-path (if specified) would not be absolute. Hence, we can check those
>> paths for validity upfront and not start the daemon at all if the paths are
>> invalid.
>>
>> Additionally, we now check that the base-path is an existing directory.
> 
> Looks good.  Thanks.
I just discovered that this patch is crap. Please drop it!

We must not remove the checks from path_ok() because they verify the *client-supplied* part of the path, which must be absolute.

Nevertheless, it would be useful to verify that --base-path points to an existing directory. What I actually wanted to implement is this:

-- >8 -- daemon: ensure that base-path is an existing directory

Any request to the daemon would fail if base-path (if specified) is not a directory. We now check for this condition early.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
---
 daemon.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/daemon.c b/daemon.c
index dd0177f..2b4a6f1 100644
--- a/daemon.c
+++ b/daemon.c
@@ -1184,6 +1184,14 @@ int main(int argc, char **argv)
 	if (strict_paths && (!ok_paths || !*ok_paths))
 		die("option --strict-paths requires a whitelist");

+	if (base_path) {
+		struct stat st;
+
+		if (stat(base_path, &st) || !S_ISDIR(st.st_mode))
+			die("base-path '%s' does not exist or "
+			    "is not a directory", base_path);
+	}
+
 	if (inetd_mode) {
 		struct sockaddr_storage ss;
 		struct sockaddr *peer = (struct sockaddr *)&ss;
-- 
1.5.4.3.231.g5d43e
Previous: Junio C Hamano
Message 3 of 3 in “daemon: Verify base-path and interpolated-path early”
  1. 2/2 daemon: Verify base-path and interpolated-path earlyJohannes Sixt, Feb 25, 2008
  2. Junio C HamanoFeb 25, 2008
  3. Johannes SixtFeb 26, 2008

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.