rugged 1.3.1 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/rugged/extconf.rb +1 -1
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +1 -1
- data/vendor/libgit2/include/git2/common.h +11 -1
- data/vendor/libgit2/include/git2/errors.h +1 -0
- data/vendor/libgit2/include/git2/version.h +2 -2
- data/vendor/libgit2/src/config.c +10 -6
- data/vendor/libgit2/src/libgit2.c +8 -0
- data/vendor/libgit2/src/path.c +213 -54
- data/vendor/libgit2/src/path.h +28 -8
- data/vendor/libgit2/src/repository.c +103 -22
- data/vendor/libgit2/src/repository.h +1 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d3a62d428f320d5ee63e21ce25ffc00ac84912e9980b782e4663b9c339f32f6
|
4
|
+
data.tar.gz: '09e9ef581a5ce5248505535edcef74dcf3e52cb0f1019285c258bd03f4b48471'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21505d114417de7410ea8f34f05bb4347f6610f64e219d4687f33b89b8b52fccc9c6d99f2ee581a92080033ad40e81572310c6d0b2cf6f64c0359f3e976d088e
|
7
|
+
data.tar.gz: d3aeea031ffb9598fc2b8b313eefc2927d1a7b1fe3b594c6010d06d8c1c557791fdb68134b2ac3c6573290d46eb8c38c6d502f098d43986e1abc7c3fda20c97a
|
data/ext/rugged/extconf.rb
CHANGED
data/lib/rugged/version.rb
CHANGED
@@ -211,7 +211,9 @@ typedef enum {
|
|
211
211
|
GIT_OPT_SET_ODB_PACKED_PRIORITY,
|
212
212
|
GIT_OPT_SET_ODB_LOOSE_PRIORITY,
|
213
213
|
GIT_OPT_GET_EXTENSIONS,
|
214
|
-
GIT_OPT_SET_EXTENSIONS
|
214
|
+
GIT_OPT_SET_EXTENSIONS,
|
215
|
+
GIT_OPT_GET_OWNER_VALIDATION,
|
216
|
+
GIT_OPT_SET_OWNER_VALIDATION
|
215
217
|
} git_libgit2_opt_t;
|
216
218
|
|
217
219
|
/**
|
@@ -449,6 +451,14 @@ typedef enum {
|
|
449
451
|
* > to support repositories with the `noop` extension but does want
|
450
452
|
* > to support repositories with the `newext` extension.
|
451
453
|
*
|
454
|
+
* opts(GIT_OPT_GET_OWNER_VALIDATION, int *enabled)
|
455
|
+
* > Gets the owner validation setting for repository
|
456
|
+
* > directories.
|
457
|
+
*
|
458
|
+
* opts(GIT_OPT_SET_OWNER_VALIDATION, int enabled)
|
459
|
+
* > Set that repository directories should be owned by the current
|
460
|
+
* > user. The default is to validate ownership.
|
461
|
+
*
|
452
462
|
* @param option Option key
|
453
463
|
* @param ... value to set the option
|
454
464
|
* @return 0 on success, <0 on failure
|
@@ -58,6 +58,7 @@ typedef enum {
|
|
58
58
|
GIT_EMISMATCH = -33, /**< Hashsum mismatch in object */
|
59
59
|
GIT_EINDEXDIRTY = -34, /**< Unsaved changes in the index would be overwritten */
|
60
60
|
GIT_EAPPLYFAIL = -35, /**< Patch application failed */
|
61
|
+
GIT_EOWNER = -36 /**< The object is not owned by the current user */
|
61
62
|
} git_error_code;
|
62
63
|
|
63
64
|
/**
|
@@ -7,10 +7,10 @@
|
|
7
7
|
#ifndef INCLUDE_git_version_h__
|
8
8
|
#define INCLUDE_git_version_h__
|
9
9
|
|
10
|
-
#define LIBGIT2_VERSION "1.3.
|
10
|
+
#define LIBGIT2_VERSION "1.3.1"
|
11
11
|
#define LIBGIT2_VER_MAJOR 1
|
12
12
|
#define LIBGIT2_VER_MINOR 3
|
13
|
-
#define LIBGIT2_VER_REVISION
|
13
|
+
#define LIBGIT2_VER_REVISION 1
|
14
14
|
#define LIBGIT2_VER_PATCH 0
|
15
15
|
|
16
16
|
#define LIBGIT2_SOVERSION "1.3"
|
data/vendor/libgit2/src/config.c
CHANGED
@@ -1118,16 +1118,20 @@ int git_config_find_system(git_buf *path)
|
|
1118
1118
|
int git_config_find_programdata(git_buf *path)
|
1119
1119
|
{
|
1120
1120
|
int ret;
|
1121
|
+
bool is_safe;
|
1121
1122
|
|
1122
|
-
if ((ret = git_buf_sanitize(path)) < 0
|
1123
|
+
if ((ret = git_buf_sanitize(path)) < 0 ||
|
1124
|
+
(ret = git_sysdir_find_programdata_file(path,
|
1125
|
+
GIT_CONFIG_FILENAME_PROGRAMDATA)) < 0 ||
|
1126
|
+
(ret = git_path_owner_is_system_or_current_user(&is_safe, path->ptr)) < 0)
|
1123
1127
|
return ret;
|
1124
1128
|
|
1125
|
-
|
1126
|
-
|
1127
|
-
|
1128
|
-
|
1129
|
+
if (!is_safe) {
|
1130
|
+
git_error_set(GIT_ERROR_CONFIG, "programdata path has invalid ownership");
|
1131
|
+
return -1;
|
1132
|
+
}
|
1129
1133
|
|
1130
|
-
return
|
1134
|
+
return 0;
|
1131
1135
|
}
|
1132
1136
|
|
1133
1137
|
int git_config__global_location(git_buf *buf)
|
@@ -390,6 +390,14 @@ int git_libgit2_opts(int key, ...)
|
|
390
390
|
}
|
391
391
|
break;
|
392
392
|
|
393
|
+
case GIT_OPT_GET_OWNER_VALIDATION:
|
394
|
+
*(va_arg(ap, int *)) = git_repository__validate_ownership;
|
395
|
+
break;
|
396
|
+
|
397
|
+
case GIT_OPT_SET_OWNER_VALIDATION:
|
398
|
+
git_repository__validate_ownership = (va_arg(ap, int) != 0);
|
399
|
+
break;
|
400
|
+
|
393
401
|
default:
|
394
402
|
git_error_set(GIT_ERROR_INVALID, "invalid option key");
|
395
403
|
error = -1;
|
data/vendor/libgit2/src/path.c
CHANGED
@@ -2024,78 +2024,237 @@ done:
|
|
2024
2024
|
return supported;
|
2025
2025
|
}
|
2026
2026
|
|
2027
|
-
|
2027
|
+
static git_path__mock_owner_t mock_owner = GIT_PATH_MOCK_OWNER_NONE;
|
2028
|
+
|
2029
|
+
void git_path__set_owner(git_path__mock_owner_t owner)
|
2030
|
+
{
|
2031
|
+
mock_owner = owner;
|
2032
|
+
}
|
2033
|
+
|
2034
|
+
#ifdef GIT_WIN32
|
2035
|
+
static PSID *sid_dup(PSID sid)
|
2036
|
+
{
|
2037
|
+
DWORD len;
|
2038
|
+
PSID dup;
|
2039
|
+
|
2040
|
+
len = GetLengthSid(sid);
|
2041
|
+
|
2042
|
+
if ((dup = git__malloc(len)) == NULL)
|
2043
|
+
return NULL;
|
2044
|
+
|
2045
|
+
if (!CopySid(len, dup, sid)) {
|
2046
|
+
git_error_set(GIT_ERROR_OS, "could not duplicate sid");
|
2047
|
+
git__free(dup);
|
2048
|
+
return NULL;
|
2049
|
+
}
|
2050
|
+
|
2051
|
+
return dup;
|
2052
|
+
}
|
2053
|
+
|
2054
|
+
static int current_user_sid(PSID *out)
|
2028
2055
|
{
|
2029
|
-
#ifndef GIT_WIN32
|
2030
|
-
GIT_UNUSED(path);
|
2031
|
-
return GIT_OK;
|
2032
|
-
#else
|
2033
|
-
git_win32_path buf;
|
2034
|
-
PSID owner_sid;
|
2035
|
-
PSECURITY_DESCRIPTOR descriptor = NULL;
|
2036
|
-
HANDLE token;
|
2037
2056
|
TOKEN_USER *info = NULL;
|
2038
|
-
|
2039
|
-
|
2057
|
+
HANDLE token = NULL;
|
2058
|
+
DWORD len = 0;
|
2059
|
+
int error = -1;
|
2040
2060
|
|
2041
|
-
if (
|
2042
|
-
|
2061
|
+
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token)) {
|
2062
|
+
git_error_set(GIT_ERROR_OS, "could not lookup process information");
|
2063
|
+
goto done;
|
2064
|
+
}
|
2065
|
+
|
2066
|
+
if (GetTokenInformation(token, TokenUser, NULL, 0, &len) ||
|
2067
|
+
GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
|
2068
|
+
git_error_set(GIT_ERROR_OS, "could not lookup token metadata");
|
2069
|
+
goto done;
|
2070
|
+
}
|
2043
2071
|
|
2044
|
-
|
2045
|
-
|
2046
|
-
DACL_SECURITY_INFORMATION,
|
2047
|
-
&owner_sid, NULL, NULL, NULL, &descriptor);
|
2072
|
+
info = git__malloc(len);
|
2073
|
+
GIT_ERROR_CHECK_ALLOC(info);
|
2048
2074
|
|
2049
|
-
if (
|
2050
|
-
|
2051
|
-
goto
|
2075
|
+
if (!GetTokenInformation(token, TokenUser, info, len, &len)) {
|
2076
|
+
git_error_set(GIT_ERROR_OS, "could not lookup current user");
|
2077
|
+
goto done;
|
2052
2078
|
}
|
2053
2079
|
|
2054
|
-
if (
|
2080
|
+
if ((*out = sid_dup(info->User.Sid)))
|
2081
|
+
error = 0;
|
2082
|
+
|
2083
|
+
done:
|
2084
|
+
if (token)
|
2085
|
+
CloseHandle(token);
|
2086
|
+
|
2087
|
+
git__free(info);
|
2088
|
+
return error;
|
2089
|
+
}
|
2090
|
+
|
2091
|
+
static int file_owner_sid(PSID *out, const char *path)
|
2092
|
+
{
|
2093
|
+
git_win32_path path_w32;
|
2094
|
+
PSECURITY_DESCRIPTOR descriptor = NULL;
|
2095
|
+
PSID owner_sid;
|
2096
|
+
DWORD ret;
|
2097
|
+
int error = -1;
|
2098
|
+
|
2099
|
+
if (git_win32_path_from_utf8(path_w32, path) < 0)
|
2100
|
+
return -1;
|
2101
|
+
|
2102
|
+
ret = GetNamedSecurityInfoW(path_w32, SE_FILE_OBJECT,
|
2103
|
+
OWNER_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION,
|
2104
|
+
&owner_sid, NULL, NULL, NULL, &descriptor);
|
2105
|
+
|
2106
|
+
if (ret == ERROR_FILE_NOT_FOUND || ret == ERROR_PATH_NOT_FOUND)
|
2107
|
+
error = GIT_ENOTFOUND;
|
2108
|
+
else if (ret != ERROR_SUCCESS)
|
2055
2109
|
git_error_set(GIT_ERROR_OS, "failed to get security information");
|
2056
|
-
|
2057
|
-
|
2110
|
+
else if (!IsValidSid(owner_sid))
|
2111
|
+
git_error_set(GIT_ERROR_OS, "file owner is not valid");
|
2112
|
+
else if ((*out = sid_dup(owner_sid)))
|
2113
|
+
error = 0;
|
2114
|
+
|
2115
|
+
if (descriptor)
|
2116
|
+
LocalFree(descriptor);
|
2117
|
+
|
2118
|
+
return error;
|
2119
|
+
}
|
2120
|
+
|
2121
|
+
int git_path_owner_is_current_user(bool *out, const char *path)
|
2122
|
+
{
|
2123
|
+
PSID owner_sid = NULL, user_sid = NULL;
|
2124
|
+
int error = -1;
|
2125
|
+
|
2126
|
+
if (mock_owner) {
|
2127
|
+
*out = (mock_owner == GIT_PATH_MOCK_OWNER_CURRENT_USER);
|
2128
|
+
return 0;
|
2129
|
+
}
|
2130
|
+
|
2131
|
+
if ((error = file_owner_sid(&owner_sid, path)) < 0 ||
|
2132
|
+
(error = current_user_sid(&user_sid)) < 0)
|
2133
|
+
goto done;
|
2134
|
+
|
2135
|
+
*out = EqualSid(owner_sid, user_sid);
|
2136
|
+
error = 0;
|
2137
|
+
|
2138
|
+
done:
|
2139
|
+
git__free(owner_sid);
|
2140
|
+
git__free(user_sid);
|
2141
|
+
return error;
|
2142
|
+
}
|
2143
|
+
|
2144
|
+
int git_path_owner_is_system(bool *out, const char *path)
|
2145
|
+
{
|
2146
|
+
PSID owner_sid;
|
2147
|
+
|
2148
|
+
if (mock_owner) {
|
2149
|
+
*out = (mock_owner == GIT_PATH_MOCK_OWNER_SYSTEM);
|
2150
|
+
return 0;
|
2058
2151
|
}
|
2059
2152
|
|
2060
|
-
if (
|
2061
|
-
|
2062
|
-
|
2063
|
-
|
2153
|
+
if (file_owner_sid(&owner_sid, path) < 0)
|
2154
|
+
return -1;
|
2155
|
+
|
2156
|
+
*out = IsWellKnownSid(owner_sid, WinBuiltinAdministratorsSid) ||
|
2157
|
+
IsWellKnownSid(owner_sid, WinLocalSystemSid);
|
2158
|
+
|
2159
|
+
git__free(owner_sid);
|
2160
|
+
return 0;
|
2161
|
+
}
|
2162
|
+
|
2163
|
+
int git_path_owner_is_system_or_current_user(bool *out, const char *path)
|
2164
|
+
{
|
2165
|
+
PSID owner_sid = NULL, user_sid = NULL;
|
2166
|
+
int error = -1;
|
2167
|
+
|
2168
|
+
if (mock_owner) {
|
2169
|
+
*out = (mock_owner == GIT_PATH_MOCK_OWNER_SYSTEM ||
|
2170
|
+
mock_owner == GIT_PATH_MOCK_OWNER_CURRENT_USER);
|
2171
|
+
return 0;
|
2064
2172
|
}
|
2065
2173
|
|
2174
|
+
if (file_owner_sid(&owner_sid, path) < 0)
|
2175
|
+
goto done;
|
2176
|
+
|
2066
2177
|
if (IsWellKnownSid(owner_sid, WinBuiltinAdministratorsSid) ||
|
2067
2178
|
IsWellKnownSid(owner_sid, WinLocalSystemSid)) {
|
2068
|
-
|
2069
|
-
|
2070
|
-
|
2071
|
-
|
2072
|
-
|
2073
|
-
if (
|
2074
|
-
|
2075
|
-
|
2076
|
-
|
2077
|
-
|
2078
|
-
|
2079
|
-
|
2179
|
+
*out = 1;
|
2180
|
+
error = 0;
|
2181
|
+
goto done;
|
2182
|
+
}
|
2183
|
+
|
2184
|
+
if (current_user_sid(&user_sid) < 0)
|
2185
|
+
goto done;
|
2186
|
+
|
2187
|
+
*out = EqualSid(owner_sid, user_sid);
|
2188
|
+
error = 0;
|
2189
|
+
|
2190
|
+
done:
|
2191
|
+
git__free(owner_sid);
|
2192
|
+
git__free(user_sid);
|
2193
|
+
return error;
|
2194
|
+
}
|
2195
|
+
|
2196
|
+
#else
|
2197
|
+
|
2198
|
+
static int path_owner_is(bool *out, const char *path, uid_t *uids, size_t uids_len)
|
2199
|
+
{
|
2200
|
+
struct stat st;
|
2201
|
+
size_t i;
|
2202
|
+
|
2203
|
+
*out = false;
|
2204
|
+
|
2205
|
+
if (p_lstat(path, &st) != 0) {
|
2206
|
+
if (errno == ENOENT)
|
2207
|
+
return GIT_ENOTFOUND;
|
2208
|
+
|
2209
|
+
git_error_set(GIT_ERROR_OS, "could not stat '%s'", path);
|
2210
|
+
return -1;
|
2211
|
+
}
|
2212
|
+
|
2213
|
+
for (i = 0; i < uids_len; i++) {
|
2214
|
+
if (uids[i] == st.st_uid) {
|
2215
|
+
*out = true;
|
2216
|
+
break;
|
2080
2217
|
}
|
2081
2218
|
}
|
2082
2219
|
|
2083
|
-
|
2084
|
-
|
2085
|
-
|
2086
|
-
|
2087
|
-
|
2088
|
-
|
2089
|
-
|
2090
|
-
|
2091
|
-
|
2220
|
+
return 0;
|
2221
|
+
}
|
2222
|
+
|
2223
|
+
int git_path_owner_is_current_user(bool *out, const char *path)
|
2224
|
+
{
|
2225
|
+
uid_t userid = geteuid();
|
2226
|
+
|
2227
|
+
if (mock_owner) {
|
2228
|
+
*out = (mock_owner == GIT_PATH_MOCK_OWNER_CURRENT_USER);
|
2229
|
+
return 0;
|
2092
2230
|
}
|
2093
|
-
git__free(info);
|
2094
2231
|
|
2095
|
-
|
2096
|
-
|
2097
|
-
LocalFree(descriptor);
|
2232
|
+
return path_owner_is(out, path, &userid, 1);
|
2233
|
+
}
|
2098
2234
|
|
2099
|
-
|
2100
|
-
|
2235
|
+
int git_path_owner_is_system(bool *out, const char *path)
|
2236
|
+
{
|
2237
|
+
uid_t userid = 0;
|
2238
|
+
|
2239
|
+
if (mock_owner) {
|
2240
|
+
*out = (mock_owner == GIT_PATH_MOCK_OWNER_SYSTEM);
|
2241
|
+
return 0;
|
2242
|
+
}
|
2243
|
+
|
2244
|
+
return path_owner_is(out, path, &userid, 1);
|
2245
|
+
}
|
2246
|
+
|
2247
|
+
int git_path_owner_is_system_or_current_user(bool *out, const char *path)
|
2248
|
+
{
|
2249
|
+
uid_t userids[2] = { geteuid(), 0 };
|
2250
|
+
|
2251
|
+
if (mock_owner) {
|
2252
|
+
*out = (mock_owner == GIT_PATH_MOCK_OWNER_SYSTEM ||
|
2253
|
+
mock_owner == GIT_PATH_MOCK_OWNER_CURRENT_USER);
|
2254
|
+
return 0;
|
2255
|
+
}
|
2256
|
+
|
2257
|
+
return path_owner_is(out, path, userids, 2);
|
2101
2258
|
}
|
2259
|
+
|
2260
|
+
#endif
|
data/vendor/libgit2/src/path.h
CHANGED
@@ -722,16 +722,36 @@ int git_path_normalize_slashes(git_buf *out, const char *path);
|
|
722
722
|
|
723
723
|
bool git_path_supports_symlinks(const char *dir);
|
724
724
|
|
725
|
+
typedef enum {
|
726
|
+
GIT_PATH_MOCK_OWNER_NONE = 0, /* do filesystem lookups as normal */
|
727
|
+
GIT_PATH_MOCK_OWNER_SYSTEM = 1,
|
728
|
+
GIT_PATH_MOCK_OWNER_CURRENT_USER = 2,
|
729
|
+
GIT_PATH_MOCK_OWNER_OTHER = 3
|
730
|
+
} git_path__mock_owner_t;
|
731
|
+
|
732
|
+
/**
|
733
|
+
* Sets the mock ownership for files; subsequent calls to
|
734
|
+
* `git_path_owner_is_*` functions will return this data until cleared
|
735
|
+
* with `GIT_PATH_MOCK_OWNER_NONE`.
|
736
|
+
*/
|
737
|
+
void git_path__set_owner(git_path__mock_owner_t owner);
|
738
|
+
|
725
739
|
/**
|
726
|
-
* Validate a system file's ownership
|
727
|
-
*
|
728
740
|
* Verify that the file in question is owned by an administrator or system
|
729
|
-
* account
|
730
|
-
|
731
|
-
*
|
732
|
-
|
733
|
-
|
741
|
+
* account.
|
742
|
+
*/
|
743
|
+
int git_path_owner_is_system(bool *out, const char *path);
|
744
|
+
|
745
|
+
/**
|
746
|
+
* Verify that the file in question is owned by the current user;
|
747
|
+
*/
|
748
|
+
|
749
|
+
int git_path_owner_is_current_user(bool *out, const char *path);
|
750
|
+
|
751
|
+
/**
|
752
|
+
* Verify that the file in question is owned by an administrator or system
|
753
|
+
* account _or_ the current user;
|
734
754
|
*/
|
735
|
-
int
|
755
|
+
int git_path_owner_is_system_or_current_user(bool *out, const char *path);
|
736
756
|
|
737
757
|
#endif
|
@@ -38,6 +38,7 @@
|
|
38
38
|
# include "win32/w32_util.h"
|
39
39
|
#endif
|
40
40
|
|
41
|
+
bool git_repository__validate_ownership = true;
|
41
42
|
bool git_repository__fsync_gitdir = false;
|
42
43
|
|
43
44
|
static const struct {
|
@@ -64,6 +65,7 @@ static const struct {
|
|
64
65
|
|
65
66
|
static int check_repositoryformatversion(int *version, git_config *config);
|
66
67
|
static int check_extensions(git_config *config, int version);
|
68
|
+
static int load_global_config(git_config **config);
|
67
69
|
|
68
70
|
#define GIT_COMMONDIR_FILE "commondir"
|
69
71
|
#define GIT_GITDIR_FILE "gitdir"
|
@@ -482,6 +484,63 @@ static int read_gitfile(git_buf *path_out, const char *file_path)
|
|
482
484
|
return error;
|
483
485
|
}
|
484
486
|
|
487
|
+
typedef struct {
|
488
|
+
const char *repo_path;
|
489
|
+
git_buf tmp;
|
490
|
+
bool is_safe;
|
491
|
+
} validate_ownership_data;
|
492
|
+
|
493
|
+
static int validate_ownership_cb(const git_config_entry *entry, void *payload)
|
494
|
+
{
|
495
|
+
validate_ownership_data *data = payload;
|
496
|
+
|
497
|
+
if (strcmp(entry->value, "") == 0)
|
498
|
+
data->is_safe = false;
|
499
|
+
|
500
|
+
if (git_path_prettify_dir(&data->tmp, entry->value, NULL) == 0 &&
|
501
|
+
strcmp(data->tmp.ptr, data->repo_path) == 0)
|
502
|
+
data->is_safe = true;
|
503
|
+
|
504
|
+
return 0;
|
505
|
+
}
|
506
|
+
|
507
|
+
static int validate_ownership(const char *repo_path)
|
508
|
+
{
|
509
|
+
git_config *config = NULL;
|
510
|
+
validate_ownership_data data = { repo_path, GIT_BUF_INIT, false };
|
511
|
+
bool is_safe;
|
512
|
+
int error;
|
513
|
+
|
514
|
+
if ((error = git_path_owner_is_current_user(&is_safe, repo_path)) < 0) {
|
515
|
+
if (error == GIT_ENOTFOUND)
|
516
|
+
error = 0;
|
517
|
+
|
518
|
+
goto done;
|
519
|
+
}
|
520
|
+
|
521
|
+
if (is_safe) {
|
522
|
+
error = 0;
|
523
|
+
goto done;
|
524
|
+
}
|
525
|
+
|
526
|
+
if (load_global_config(&config) == 0) {
|
527
|
+
error = git_config_get_multivar_foreach(config, "safe.directory", NULL, validate_ownership_cb, &data);
|
528
|
+
|
529
|
+
if (!error && data.is_safe)
|
530
|
+
goto done;
|
531
|
+
}
|
532
|
+
|
533
|
+
git_error_set(GIT_ERROR_CONFIG,
|
534
|
+
"repository path '%s' is not owned by current user",
|
535
|
+
repo_path);
|
536
|
+
error = GIT_EOWNER;
|
537
|
+
|
538
|
+
done:
|
539
|
+
git_config_free(config);
|
540
|
+
git_buf_dispose(&data.tmp);
|
541
|
+
return error;
|
542
|
+
}
|
543
|
+
|
485
544
|
static int find_repo(
|
486
545
|
git_buf *gitdir_path,
|
487
546
|
git_buf *workdir_path,
|
@@ -855,6 +914,7 @@ int git_repository_open_ext(
|
|
855
914
|
gitlink = GIT_BUF_INIT, commondir = GIT_BUF_INIT;
|
856
915
|
git_repository *repo = NULL;
|
857
916
|
git_config *config = NULL;
|
917
|
+
const char *validation_path;
|
858
918
|
int version = 0;
|
859
919
|
|
860
920
|
if (flags & GIT_REPOSITORY_OPEN_FROM_ENV)
|
@@ -903,16 +963,24 @@ int git_repository_open_ext(
|
|
903
963
|
if ((error = check_extensions(config, version)) < 0)
|
904
964
|
goto cleanup;
|
905
965
|
|
906
|
-
if ((flags & GIT_REPOSITORY_OPEN_BARE) != 0)
|
966
|
+
if ((flags & GIT_REPOSITORY_OPEN_BARE) != 0) {
|
907
967
|
repo->is_bare = 1;
|
908
|
-
else {
|
909
|
-
|
968
|
+
} else {
|
910
969
|
if (config &&
|
911
970
|
((error = load_config_data(repo, config)) < 0 ||
|
912
971
|
(error = load_workdir(repo, config, &workdir)) < 0))
|
913
972
|
goto cleanup;
|
914
973
|
}
|
915
974
|
|
975
|
+
/*
|
976
|
+
* Ensure that the git directory is owned by the current user.
|
977
|
+
*/
|
978
|
+
validation_path = repo->is_bare ? repo->gitdir : repo->workdir;
|
979
|
+
|
980
|
+
if (git_repository__validate_ownership &&
|
981
|
+
(error = validate_ownership(validation_path)) < 0)
|
982
|
+
goto cleanup;
|
983
|
+
|
916
984
|
cleanup:
|
917
985
|
git_buf_dispose(&gitdir);
|
918
986
|
git_buf_dispose(&workdir);
|
@@ -1609,13 +1677,40 @@ static bool is_filesystem_case_insensitive(const char *gitdir_path)
|
|
1609
1677
|
return is_insensitive;
|
1610
1678
|
}
|
1611
1679
|
|
1612
|
-
|
1680
|
+
/*
|
1681
|
+
* Return a configuration object with only the global and system
|
1682
|
+
* configurations; no repository-level configuration.
|
1683
|
+
*/
|
1684
|
+
static int load_global_config(git_config **config)
|
1613
1685
|
{
|
1614
|
-
git_config *config = NULL;
|
1615
1686
|
git_buf global_buf = GIT_BUF_INIT;
|
1616
1687
|
git_buf xdg_buf = GIT_BUF_INIT;
|
1617
1688
|
git_buf system_buf = GIT_BUF_INIT;
|
1618
1689
|
git_buf programdata_buf = GIT_BUF_INIT;
|
1690
|
+
int error;
|
1691
|
+
|
1692
|
+
git_config_find_global(&global_buf);
|
1693
|
+
git_config_find_xdg(&xdg_buf);
|
1694
|
+
git_config_find_system(&system_buf);
|
1695
|
+
git_config_find_programdata(&programdata_buf);
|
1696
|
+
|
1697
|
+
error = load_config(config, NULL,
|
1698
|
+
path_unless_empty(&global_buf),
|
1699
|
+
path_unless_empty(&xdg_buf),
|
1700
|
+
path_unless_empty(&system_buf),
|
1701
|
+
path_unless_empty(&programdata_buf));
|
1702
|
+
|
1703
|
+
git_buf_dispose(&global_buf);
|
1704
|
+
git_buf_dispose(&xdg_buf);
|
1705
|
+
git_buf_dispose(&system_buf);
|
1706
|
+
git_buf_dispose(&programdata_buf);
|
1707
|
+
|
1708
|
+
return error;
|
1709
|
+
}
|
1710
|
+
|
1711
|
+
static bool are_symlinks_supported(const char *wd_path)
|
1712
|
+
{
|
1713
|
+
git_config *config = NULL;
|
1619
1714
|
int symlinks = 0;
|
1620
1715
|
|
1621
1716
|
/*
|
@@ -1626,19 +1721,9 @@ static bool are_symlinks_supported(const char *wd_path)
|
|
1626
1721
|
* _not_ set, then we do not test or enable symlink support.
|
1627
1722
|
*/
|
1628
1723
|
#ifdef GIT_WIN32
|
1629
|
-
|
1630
|
-
|
1631
|
-
|
1632
|
-
git_config_find_programdata(&programdata_buf);
|
1633
|
-
|
1634
|
-
if (load_config(&config, NULL,
|
1635
|
-
path_unless_empty(&global_buf),
|
1636
|
-
path_unless_empty(&xdg_buf),
|
1637
|
-
path_unless_empty(&system_buf),
|
1638
|
-
path_unless_empty(&programdata_buf)) < 0)
|
1639
|
-
goto done;
|
1640
|
-
|
1641
|
-
if (git_config_get_bool(&symlinks, config, "core.symlinks") < 0 || !symlinks)
|
1724
|
+
if (load_global_config(&config) < 0 ||
|
1725
|
+
git_config_get_bool(&symlinks, config, "core.symlinks") < 0 ||
|
1726
|
+
!symlinks)
|
1642
1727
|
goto done;
|
1643
1728
|
#endif
|
1644
1729
|
|
@@ -1646,10 +1731,6 @@ static bool are_symlinks_supported(const char *wd_path)
|
|
1646
1731
|
goto done;
|
1647
1732
|
|
1648
1733
|
done:
|
1649
|
-
git_buf_dispose(&global_buf);
|
1650
|
-
git_buf_dispose(&xdg_buf);
|
1651
|
-
git_buf_dispose(&system_buf);
|
1652
|
-
git_buf_dispose(&programdata_buf);
|
1653
1734
|
git_config_free(config);
|
1654
1735
|
return symlinks != 0;
|
1655
1736
|
}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rugged
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Chacon
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-
|
12
|
+
date: 2022-04-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake-compiler
|
@@ -697,7 +697,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
697
697
|
- !ruby/object:Gem::Version
|
698
698
|
version: '0'
|
699
699
|
requirements: []
|
700
|
-
rubygems_version: 3.
|
700
|
+
rubygems_version: 3.2.33
|
701
701
|
signing_key:
|
702
702
|
specification_version: 4
|
703
703
|
summary: Rugged is a Ruby binding to the libgit2 linkable library
|