Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
5561070c
Unverified
Commit
5561070c
authored
Feb 20, 2023
by
Edward Thomson
Committed by
GitHub
Feb 20, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6493 from libgit2/ethomson/ownership
Handle Win32 shares
parents
96e85df6
be3a78cc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
7 deletions
+43
-7
src/libgit2/repository.c
+42
-6
src/util/fs_path.c
+1
-1
No files found.
src/libgit2/repository.c
View file @
5561070c
...
...
@@ -496,14 +496,47 @@ static int validate_ownership_cb(const git_config_entry *entry, void *payload)
{
validate_ownership_data
*
data
=
payload
;
if
(
strcmp
(
entry
->
value
,
""
)
==
0
)
if
(
strcmp
(
entry
->
value
,
""
)
==
0
)
{
*
data
->
is_safe
=
false
;
if
(
strcmp
(
entry
->
value
,
"*"
)
==
0
)
*
data
->
is_safe
=
true
;
else
if
(
git_fs_path_prettify_dir
(
&
data
->
tmp
,
entry
->
value
,
NULL
)
==
0
&&
strcmp
(
data
->
tmp
.
ptr
,
data
->
repo_path
)
==
0
)
}
else
if
(
strcmp
(
entry
->
value
,
"*"
)
==
0
)
{
*
data
->
is_safe
=
true
;
}
else
{
const
char
*
test_path
=
entry
->
value
;
#ifdef GIT_WIN32
/*
* Git for Windows does some truly bizarre things with
* paths that start with a forward slash; and expects you
* to escape that with `%(prefix)`. This syntax generally
* means to add the prefix that Git was installed to -- eg
* `/usr/local` -- unless it's an absolute path, in which
* case the leading `%(prefix)/` is just removed. And Git
* for Windows expects you to use this syntax for absolute
* Unix-style paths (in "Git Bash" or Windows Subsystem for
* Linux).
*
* Worse, the behavior used to be that a leading `/` was
* not absolute. It would indicate that Git for Windows
* should add the prefix. So `//` is required for absolute
* Unix-style paths. Yes, this is truly horrifying.
*
* Emulate that behavior, I guess, but only for absolute
* paths. We won't deal with the Git install prefix. Also,
* give WSL users an escape hatch where they don't have to
* think about this and can use the literal path that the
* filesystem APIs provide (`//wsl.localhost/...`).
*/
if
(
strncmp
(
test_path
,
"%(prefix)//"
,
strlen
(
"%(prefix)//"
))
==
0
)
test_path
+=
strlen
(
"%(prefix)/"
);
else
if
(
strncmp
(
test_path
,
"//"
,
2
)
==
0
&&
strncmp
(
test_path
,
"//wsl.localhost/"
,
strlen
(
"//wsl.localhost/"
))
!=
0
)
test_path
++
;
#endif
if
(
git_fs_path_prettify_dir
(
&
data
->
tmp
,
test_path
,
NULL
)
==
0
&&
strcmp
(
data
->
tmp
.
ptr
,
data
->
repo_path
)
==
0
)
*
data
->
is_safe
=
true
;
}
return
0
;
}
...
...
@@ -547,6 +580,9 @@ static int validate_ownership_path(bool *is_safe, const char *path)
if
(
error
==
GIT_ENOTFOUND
)
{
*
is_safe
=
true
;
error
=
0
;
}
else
if
(
error
==
GIT_EINVALID
)
{
*
is_safe
=
false
;
error
=
0
;
}
return
error
;
...
...
src/util/fs_path.c
View file @
5561070c
...
...
@@ -1855,7 +1855,7 @@ static int file_owner_sid(PSID *out, const char *path)
PSECURITY_DESCRIPTOR
descriptor
=
NULL
;
PSID
owner_sid
;
DWORD
ret
;
int
error
=
-
1
;
int
error
=
GIT_EINVALID
;
if
(
git_win32_path_from_utf8
(
path_w32
,
path
)
<
0
)
return
-
1
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment