Library code for user-relative paths, take three.
PATCH 1/5 Library code for user-relative paths, take three.
See the threads "User-relative paths", "[RFC] GIT paths" and "[PATCH 0/4] User-relative paths, take two" for previous discussions on this topic.
This patch provides the work-horse of the user-relative paths feature, using Linus' idea of a blind chdir() and getcwd() which makes it remarkably simple.
---
cache.h | 1 + path.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 0 deletions(-)
applies-to: 8ff699dffc817e92fb2101f538f84c38d5ed0a0f 416ee0a4f47244471b52b9dc8aca3e984b20445f
cache.h +1 -0
@@ -192,6 +192,7 @@ extern int diff_rename_limit_default;/* Return a statically allocated filename matching the sha1 signature */ extern char *mkpath (const char *fmt, ...) __attribute__((format (printf,1 ,2 ))); +extern char *enter_repo (char *path,int strict);extern char *git_path (const char *fmt, ...) __attribute__((format (printf,1 ,2 )));extern char *sha1_file_name (const unsigned char *sha1);extern char *sha1_pack_name (const unsigned char *sha1);
path.c +72 -0
81 lines not on this page · raw message
---
0.99.9.GIT
path.c char *safe_strncpy(char *dest, const cha · line 105
Quoted 1 line · [email protected] (Andreas Ericsson) writes:
path.c +1
-0+if (strict && *dir !='/' )
(style everywhere)
if (strict ...
path.c char *safe_strncpy(char *dest, const cha · line 155
Quoted 3 lines
path.c +3
-0+/* This is perfectly safe, and people tend to think of the directory +* where they ran git-init-db as their repository, so humour them. */ + (void )chdir (".git" );
It might be safe, but I think it changes the behaviour of upload-pack with strict case. My gut reaction is we would want "if (!strict)" in front. Thoughts?
Quoted 10 lines · Junio C Hamano
path.c char *safe_strncpy(char *dest, const cha · line 155
Quoted 4 lines
path.c +3
-0+/* This is perfectly safe, and people tend to think of the directory +* where they ran git-init-db as their repository, so humour them. */ + (void )chdir (".git" );It might be safe, but I think it changes the behaviour of upload-pack with strict case. My gut reaction is we would want "if (!strict)" in front. Thoughts?
As it says in the comment; People tend to think of the directory where they ran "git init-db" as their repository, so humour them. It's nice for sharing files between devs in the office, and it *is* safe. Do as you please though. It's the generality of the
Signature · 3 lines
Andreas Ericsson [email protected] OP5 AB www.op5.se Tel: +46 8-230225 Fax: +46 8-230231
Quoted 11 lines · Andreas Ericsson
Quoted 9 lines · Junio C Hamano
Quoted 6 lines
+ /* This is perfectly safe, and people tend to think of the
directory
+ * where they ran git-init-db as their repository, so humour
them. */
+ (void)chdir(".git");
Quoted 7 lines
Quoted 4 lines
It might be safe, but I think it changes the behaviour of upload-pack with strict case. My gut reaction is we would want "if (!strict)" in front. Thoughts?
As it says in the comment; People tend to think of the directory where they ran "git init-db" as their repository, so humour them. It's nice for sharing files between devs in the office, and it *is* safe. Do as you please though. It's the generality of the
Butter-fingers be me. Sorry about that.
What I meant to say was that:
"it's the general idea of the patchset I'm after".
Signature · 3 lines
Andreas Ericsson [email protected] OP5 AB www.op5.se Tel: +46 8-230225 Fax: +46 8-230231
Quoted 10 lines · Andreas Ericsson
Quoted 8 lines · Junio C Hamano
Quoted 6 lines
+ /* This is perfectly safe, and people tend to think of the
directory
+ * where they ran git-init-db as their repository, so humour
them. */
+ (void)chdir(".git");
Quoted 5 lines
Quoted 3 lines
It might be safe, but I think it changes the behaviour of upload-pack with strict case. My gut reaction is we would want "if (!strict)" in front. Thoughts?
As it says in the comment; People tend to think of the directory where they ran "git init-db" as their repository, so humour them. It's nice for sharing files between devs in the office, and it *is* safe.
No, it's not.
The whole point with --strict is that it shouldn't DWIM. DWIMming is *NOT* safe if the data has previously passed through a security screen.
Don't DWIM in strict mode, ever. If you do, you create security holes.
If not immediately, then later.
-hpa
Quoted 2 lines · H. Peter Anvin
The whole point with --strict is that it shouldn't DWIM. DWIMming is *NOT* safe if the data has previously passed through a security screen.
But it hasn't at this point. The security scan is done afterwards, when the canonical path is compared against the whitelist which, in strict mode, only matches if it matches exactly.
But anyways, how about doing
enter_repo(path, 2)
from the daemon to make enter_repo() do the chdir(".git")?
Signature · 3 lines
Andreas Ericsson [email protected] OP5 AB www.op5.se Tel: +46 8-230225 Fax: +46 8-230231
Quoted 5 lines · Andreas Ericsson
Quoted 2 lines · H. Peter Anvin
The whole point with --strict is that it shouldn't DWIM. DWIMming is *NOT* safe if the data has previously passed through a security screen.
Quoted 8 lines
But it hasn't at this point. The security scan is done afterwards, when the canonical path is compared against the whitelist which, in strict mode, only matches if it matches exactly.
But anyways, how about doing
enter_repo(path, 2)from the daemon to make
enter_repo()do thechdir(".git")?
... while preventing the later call from git-upload-pack from doing so.
Signature · 3 lines
Andreas Ericsson [email protected] OP5 AB www.op5.se Tel: +46 8-230225 Fax: +46 8-230231