summaryrefslogtreecommitdiff
path: root/compat
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2022-08-08 13:27:48 (GMT)
committerJunio C Hamano <gitster@pobox.com>2022-08-08 16:29:29 (GMT)
commite883e04b68ba7393029bcbeaa2aacb3dff5d3fbd (patch)
tree11789e440efe995c2edc76987b2c75f3fd748fb3 /compat
parent17d3883fe9c88b823002ad9fafb42313ddc3d3d5 (diff)
downloadgit-e883e04b68ba7393029bcbeaa2aacb3dff5d3fbd.zip
git-e883e04b68ba7393029bcbeaa2aacb3dff5d3fbd.tar.gz
git-e883e04b68ba7393029bcbeaa2aacb3dff5d3fbd.tar.bz2
mingw: provide details about unsafe directories' ownership
When Git refuses to use an existing repository because it is owned by someone else than the current user, it can be a bit tricky on Windows to figure out what is going on. Let's help with that by providing more detailed information. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'compat')
-rw-r--r--compat/mingw.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/compat/mingw.c b/compat/mingw.c
index f12b7df..2c09c5b 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -1,6 +1,7 @@
#include "../git-compat-util.h"
#include "win32.h"
#include <aclapi.h>
+#include <sddl.h>
#include <conio.h>
#include <wchar.h>
#include "../strbuf.h"
@@ -2720,6 +2721,29 @@ int is_path_owned_by_current_sid(const char *path, struct strbuf *report)
IsValidSid(current_user_sid) &&
EqualSid(sid, current_user_sid))
result = 1;
+ else if (report) {
+ LPSTR str1, str2, to_free1 = NULL, to_free2 = NULL;
+
+ if (ConvertSidToStringSidA(sid, &str1))
+ to_free1 = str1;
+ else
+ str1 = "(inconvertible)";
+
+ if (!current_user_sid)
+ str2 = "(none)";
+ else if (!IsValidSid(current_user_sid))
+ str2 = "(invalid)";
+ else if (ConvertSidToStringSidA(current_user_sid, &str2))
+ to_free2 = str2;
+ else
+ str2 = "(inconvertible)";
+ strbuf_addf(report,
+ "'%s' is owned by:\n"
+ "\t'%s'\nbut the current user is:\n"
+ "\t'%s'\n", path, str1, str2);
+ LocalFree(to_free1);
+ LocalFree(to_free2);
+ }
}
/*