File tree Expand file tree Collapse file tree 3 files changed +39
-2
lines changed Expand file tree Collapse file tree 3 files changed +39
-2
lines changed Original file line number Diff line number Diff line change @@ -59,3 +59,9 @@ which id the original user has.
59
59
If that is not what you would prefer and want git to only trust
60
60
repositories that are owned by root instead, then you can remove
61
61
the `SUDO_UID` variable from root's environment before invoking git.
62
+ +
63
+ Due to the permission model on Windows where ACLs are used instead of
64
+ Unix' simpler permission model, it can be a bit tricky to figure out why
65
+ a directory is considered unsafe. To help with this, Git will provide
66
+ more detailed information when the environment variable
67
+ `GIT_TEST_DEBUG_UNSAFE_DIRECTORIES` is set to `true`.
Original file line number Diff line number Diff line change 1
1
#include "../git-compat-util.h"
2
2
#include "win32.h"
3
3
#include <aclapi.h>
4
+ #include <sddl.h>
4
5
#include <conio.h>
5
6
#include <wchar.h>
6
7
#include "../strbuf.h"
@@ -2717,6 +2718,26 @@ int is_path_owned_by_current_sid(const char *path)
2717
2718
IsValidSid (current_user_sid ) &&
2718
2719
EqualSid (sid , current_user_sid ))
2719
2720
result = 1 ;
2721
+ else if (git_env_bool ("GIT_TEST_DEBUG_UNSAFE_DIRECTORIES" , 0 )) {
2722
+ LPSTR str1 , str2 , to_free1 = NULL , to_free2 = NULL ;
2723
+
2724
+ if (ConvertSidToStringSidA (sid , & str1 ))
2725
+ to_free1 = str1 ;
2726
+ else
2727
+ str1 = "(inconvertible)" ;
2728
+
2729
+ if (!current_user_sid )
2730
+ str2 = "(none)" ;
2731
+ else if (!IsValidSid (current_user_sid ))
2732
+ str2 = "(invalid)" ;
2733
+ else if (ConvertSidToStringSidA (current_user_sid , & str2 ))
2734
+ to_free2 = str2 ;
2735
+ else
2736
+ str2 = "(inconvertible)" ;
2737
+ warning ("'%s' is owned by:\n\t'%s'\nbut the current user is:\n\t'%s'" , path , str1 , str2 );
2738
+ LocalFree (to_free1 );
2739
+ LocalFree (to_free2 );
2740
+ }
2720
2741
}
2721
2742
2722
2743
/*
Original file line number Diff line number Diff line change @@ -1480,13 +1480,23 @@ const char *setup_git_directory_gently(int *nongit_ok)
1480
1480
case GIT_DIR_INVALID_OWNERSHIP :
1481
1481
if (!nongit_ok ) {
1482
1482
struct strbuf quoted = STRBUF_INIT ;
1483
+ struct strbuf hint = STRBUF_INIT ;
1484
+
1485
+ #ifdef __MINGW32__
1486
+ if (!git_env_bool ("GIT_TEST_DEBUG_UNSAFE_DIRECTORIES" , 0 ))
1487
+ strbuf_addstr (& hint ,
1488
+ _ ("\n\nSet the environment variable "
1489
+ "GIT_TEST_DEBUG_UNSAFE_DIRECTORIES=true "
1490
+ "and run\n"
1491
+ "again for more information." ));
1492
+ #endif
1483
1493
1484
1494
sq_quote_buf_pretty (& quoted , dir .buf );
1485
1495
die (_ ("detected dubious ownership in repository at '%s'\n"
1486
1496
"To add an exception for this directory, call:\n"
1487
1497
"\n"
1488
- "\tgit config --global --add safe.directory %s" ),
1489
- dir .buf , quoted .buf );
1498
+ "\tgit config --global --add safe.directory %s%s " ),
1499
+ dir .buf , quoted .buf , hint . buf );
1490
1500
}
1491
1501
* nongit_ok = 1 ;
1492
1502
break ;
You can’t perform that action at this time.
0 commit comments