New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Windows permissions problems #475
Conversation
Move the callers of git_futils_mv_atomic to use p_rename. Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
👍 |
👍 |
When you tested this with Git itself, did you first change your umask to
You should be using |
return GIT_ERROR; | ||
|
||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First question: Is this just refactoring, or is it required to fix Windows support?
Second question: Aren't things in posix.h
supposed to use the real underlying POSIX implementations if they're available? Why isn't this just a #define
for rename(2)
? And why does this call link()
and unlink()
instead of just doing rename()
? If anything, wouldn't that open up the possibility of this operation not being atomic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On Mon, Nov 07, 2011 at 12:58:24PM -0800, Brodie Rao wrote:
@@ -39,6 +39,20 @@ int p_getcwd(char *buffer_out, size_t size)
return GIT_SUCCESS;
}+int p_rename(const char *from, const char *to)
+{
- if (!link(from, to)) {
p_unlink(from);
return GIT_SUCCESS;
- }
- if (!rename(from, to))
return GIT_SUCCESS;
- return GIT_ERROR;
+}
+First question: Is this just refactoring, or is it required to fix Windows support?
Yes and no. Our current test suite doesn't test the Unicode support so
it doesn't actually fix any problems we're seeing, but p_rename
needs to transform the path to UTF-16 on Windows, so it does fix a
problem (just not this particular one).
Second question: Aren't things in
posix.h
supposed to use the real
underlying POSIX implementations if they're available? Why isn't
Not exactly. We stick to POSIX except where we find it to be lacking
or annoying for our purposes.
this just a
#define
forrename(2)
? And why does this call
link()
andunlink()
instead of just doingrename()
? If
anything, wouldn't that open up the possibility of this operation
not being atomic?
I believe @tanoku wrote that originally, I'm just moving the Windows
part so it uses UTF-16.
cmn
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does umask
even exist on Windows?@xpaulbettsx could you share your wisdom?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ummm, in a way - ACLs inherit their parent's ACLs if the directory is set to do so, it's not set via any global mask like umask is.
Paul Betts
SENT FROM MY COMMODORE 64: RESPONSES MAY BE IN ALL CAPS
On Nov 8, 2011, at 8:18, Carlos Martín Nietoreply@reply.github.com wrote:
@@ -39,6 +39,20 @@ int p_getcwd(char *buffer_out, size_t size)
return GIT_SUCCESS;
}+int p_rename(const char *from, const char *to)
+{
- if (!link(from, to)) {
p_unlink(from);
return GIT_SUCCESS;
- }
- if (!rename(from, to))
return GIT_SUCCESS;
- return GIT_ERROR;
+}
+Does
umask
even exist on Windows?@xpaulbettsx could you share your wisdom?
Reply to this email directly or view it on GitHub:
https://github.com/libgit2/libgit2/pull/475/files#r215829
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might want to set ACLs to do something equivalent to git init --shared
. MSDN tells me that the _umask
does exist (but with quite limited capabilities, as the umask doesn't really exist on Windows). I was thinking that maybe we should apply the umask in p_chmod
ourselves under Windows, but since it would only affect the user's permissions and all the default umask does there is remove the execute bit, which doesn't exist under Windows (or rather, it can't be unset), so we might just as well ignore it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You shouldn't need to use umask()
in libgit2. That's just for changing the current umask. open()
, chmod()
, etc. will respect the umask.
I was just mentioning it as a way to confirm exactly what permissions Git uses.
On Mon, Nov 07, 2011 at 12:52:39PM -0800, Brodie Rao wrote:
I didn't check with git.git. I was trying to solve the problem libgit2
You're the one who wrote the permissions code; As I said, I was just cmn |
Fix Windows permissions problems
packed-refs
should not be treated like a packfile. It looks like windows doesn't like it when we're not allowed to write to that file. It looks like Windows won't let us overwrite a file if we can't write to it (or something like that, I don't particularly care why).This fixes the tests for both MSVC and MSYS. The real fix is the last commit. The rest is stuff I found whilst hunting this down.