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

Re: [PATCH] daemon, path.c: fix a bug with ~ in repo paths

From
LSLuke Shumaker <lukeshu@sbcglobal.net>
Date
Oct 18, 2016, 18:05 UTC
Message-ID
<87pomxildc.wl-lukeshu@sbcglobal.net>
In-Reply-To
<xmqqvawppote.fsf@gitster.mtv.corp.google.com>

On Tue, 18 Oct 2016 13:08:45 -0400, Junio C Hamano wrote:

Show 19 quoted lines
> 
> Luke Shumaker <lukeshu@sbcglobal.net> writes:
> 
> > The superficial aspect of this change is that git-daemon now allows paths
> > that start with a "~".  Previously, if git-daemon was run with
> > "--base-path=/srv/git", it was impossible to get it to serve
> > "/srv/git/~foo/bar.git".
> 
> I am not sure I understand what you are saying here.  Do you mean
> 
>     I have a path on my server /srv/git/~foo/bar.git; the tilde does
>     not mean anything special--it is just a byte in a valid pathname.
> 
>     I want to allow my users to say
> 
> 	git fetch git://my.server/~foo/bar.git
> 
>     and fetch from that repository, but "git daemon" lacks the way
>     to configure to allow it.
Yes, that is what I am saying.
> If that is the case, what happens instead?  Due to the leading
> "~foo/" getting noticed as an attempt to use the user-path expansion
> it is not treated as just a literal character?
What happens instead is
	if (*dir == '~') {
		if (!user_path) {
			logerror("'%s': User-path not allowed", dir);
			return NULL;
		}
which to the user looks like
	git clone git://my.server/~foo/bar.git
	Cloning into 'bar'...
	fatal: remote error: access denied or repository not exported: ~foo/bar.git
> I am not sure if it is even a bug.  As you can easily lose that
> tilde that appears in front of subdirectory of /srv/git/ or replace
> it with something else (e.g. "u/"), this smells like "Don't do it if
> it hurts" thing to me.

I buy into "Don't do it if it hurts", but that doesn't mean it's not a bug on an uncommon edge-case. Note that it doesn't hurt with git-shell or cgit (I haven't checked with gitweb).

Many programs (especially shell scripts) fail to deal with filenames containing a space. "Don't put spaces in filenames if it hurts". It's still a bug in the program.

Similarly, `git gui` used to not be able to add a file in a directory starting with '~' (when one clicked the file named "~foo/bar", it said something along the lines of "/home/~foo/bar is outside repository"), and one had to use `git add '~foo/bar` directly. "Don't do it if it hurts"; it was still a bug.

  Aside: one (somewhat silly) non-user reason that I've seen for a
  directory to start with '~' is that it sorts after all other ASCII
  characters; it moves the directory to the end of any lists.
-- 
Happy hacking,
~ Luke Shumaker
Previous: Junio C HamanoNext: Duy Nguyen
Message 3 of 7 in “daemon, path.c: fix a bug with ~ in repo paths”
  1. daemon, path.c: fix a bug with ~ in repo pathsLuke Shumaker, Oct 18, 2016
  2. Junio C HamanoOct 18, 2016
  3. Luke ShumakerOct 18, 2016
  4. Duy NguyenOct 19, 2016
  5. Junio C HamanoOct 21, 2016
  6. Junio C HamanoOct 21, 2016
  7. Jeff KingOct 22, 2016

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.