Skip to content

Commit d36cc0d

Browse files
committed
Merge branch 'fixes/2.45.1/2.44' into jc/fix-2.45.1-and-friends-for-maint
* fixes/2.45.1/2.44: Revert "fsck: warn about symlink pointing inside a gitdir" Revert "Add a helper function to compare file contents" clone: drop the protections where hooks aren't run tests: verify that `clone -c core.hooksPath=/dev/null` works again Revert "core.hooksPath: add some protection while cloning" init: use the correct path of the templates directory again hook: plug a new memory leak ci: stop installing "gcc-13" for osx-gcc ci: avoid bare "gcc" for osx-gcc job ci: drop mention of BREW_INSTALL_PACKAGES variable send-email: avoid creating more than one Term::ReadLine object send-email: drop FakeTerm hack
2 parents 2c7b491 + 863c0ed commit d36cc0d

File tree

16 files changed

+11
-366
lines changed

16 files changed

+11
-366
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,7 @@ jobs:
284284
cc: clang
285285
pool: macos-13
286286
- jobname: osx-gcc
287-
cc: gcc
288-
cc_package: gcc-13
287+
cc: gcc-13
289288
pool: macos-13
290289
- jobname: linux-gcc-default
291290
cc: gcc

Documentation/fsck-msgids.txt

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -164,18 +164,6 @@
164164
`nullSha1`::
165165
(WARN) Tree contains entries pointing to a null sha1.
166166

167-
`symlinkPointsToGitDir`::
168-
(WARN) Symbolic link points inside a gitdir.
169-
170-
`symlinkTargetBlob`::
171-
(ERROR) A non-blob found instead of a symbolic link's target.
172-
173-
`symlinkTargetLength`::
174-
(WARN) Symbolic link target longer than maximum path length.
175-
176-
`symlinkTargetMissing`::
177-
(ERROR) Unable to read symbolic link target's blob.
178-
179167
`treeNotSorted`::
180168
(ERROR) A tree is not properly sorted.
181169

builtin/clone.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -967,8 +967,6 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
967967
int hash_algo;
968968
unsigned int ref_storage_format = REF_STORAGE_FORMAT_UNKNOWN;
969969
const int do_not_override_repo_unix_permissions = -1;
970-
const char *template_dir;
971-
char *template_dir_dup = NULL;
972970

973971
struct transport_ls_refs_options transport_ls_refs_options =
974972
TRANSPORT_LS_REFS_OPTIONS_INIT;
@@ -988,13 +986,6 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
988986
usage_msg_opt(_("You must specify a repository to clone."),
989987
builtin_clone_usage, builtin_clone_options);
990988

991-
xsetenv("GIT_CLONE_PROTECTION_ACTIVE", "true", 0 /* allow user override */);
992-
template_dir = get_template_dir(option_template);
993-
if (*template_dir && !is_absolute_path(template_dir))
994-
template_dir = template_dir_dup =
995-
absolute_pathdup(template_dir);
996-
xsetenv("GIT_CLONE_TEMPLATE_DIR", template_dir, 1);
997-
998989
if (option_depth || option_since || option_not.nr)
999990
deepen = 1;
1000991
if (option_single_branch == -1)
@@ -1156,7 +1147,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
11561147
* repository, and reference backends may persist that information into
11571148
* their on-disk data structures.
11581149
*/
1159-
init_db(git_dir, real_git_dir, template_dir, GIT_HASH_UNKNOWN,
1150+
init_db(git_dir, real_git_dir, option_template, GIT_HASH_UNKNOWN,
11601151
ref_storage_format, NULL,
11611152
do_not_override_repo_unix_permissions, INIT_DB_QUIET | INIT_DB_SKIP_REFDB);
11621153

@@ -1545,7 +1536,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
15451536
free(dir);
15461537
free(path);
15471538
free(repo_to_free);
1548-
free(template_dir_dup);
1539+
UNLEAK(repo);
15491540
junk_mode = JUNK_LEAVE_ALL;
15501541

15511542
transport_ls_refs_options_release(&transport_ls_refs_options);

ci/install-dependencies.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ macos-*)
3434
export HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_NO_INSTALL_CLEANUP=1
3535
# Uncomment this if you want to run perf tests:
3636
# brew install gnu-time
37-
test -z "$BREW_INSTALL_PACKAGES" ||
38-
brew install $BREW_INSTALL_PACKAGES
3937
brew link --force gettext
4038

4139
mkdir -p "$P4_PATH"

config.c

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1416,19 +1416,8 @@ static int git_default_core_config(const char *var, const char *value,
14161416
if (!strcmp(var, "core.attributesfile"))
14171417
return git_config_pathname(&git_attributes_file, var, value);
14181418

1419-
if (!strcmp(var, "core.hookspath")) {
1420-
if (ctx->kvi && ctx->kvi->scope == CONFIG_SCOPE_LOCAL &&
1421-
git_env_bool("GIT_CLONE_PROTECTION_ACTIVE", 0))
1422-
die(_("active `core.hooksPath` found in the local "
1423-
"repository config:\n\t%s\nFor security "
1424-
"reasons, this is disallowed by default.\nIf "
1425-
"this is intentional and the hook should "
1426-
"actually be run, please\nrun the command "
1427-
"again with "
1428-
"`GIT_CLONE_PROTECTION_ACTIVE=false`"),
1429-
value);
1419+
if (!strcmp(var, "core.hookspath"))
14301420
return git_config_pathname(&git_hooks_path, var, value);
1431-
}
14321421

14331422
if (!strcmp(var, "core.bare")) {
14341423
is_bare_repository_cfg = git_config_bool(var, value);

copy.c

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -70,61 +70,3 @@ int copy_file_with_time(const char *dst, const char *src, int mode)
7070
return copy_times(dst, src);
7171
return status;
7272
}
73-
74-
static int do_symlinks_match(const char *path1, const char *path2)
75-
{
76-
struct strbuf buf1 = STRBUF_INIT, buf2 = STRBUF_INIT;
77-
int ret = 0;
78-
79-
if (!strbuf_readlink(&buf1, path1, 0) &&
80-
!strbuf_readlink(&buf2, path2, 0))
81-
ret = !strcmp(buf1.buf, buf2.buf);
82-
83-
strbuf_release(&buf1);
84-
strbuf_release(&buf2);
85-
return ret;
86-
}
87-
88-
int do_files_match(const char *path1, const char *path2)
89-
{
90-
struct stat st1, st2;
91-
int fd1 = -1, fd2 = -1, ret = 1;
92-
char buf1[8192], buf2[8192];
93-
94-
if ((fd1 = open_nofollow(path1, O_RDONLY)) < 0 ||
95-
fstat(fd1, &st1) || !S_ISREG(st1.st_mode)) {
96-
if (fd1 < 0 && errno == ELOOP)
97-
/* maybe this is a symbolic link? */
98-
return do_symlinks_match(path1, path2);
99-
ret = 0;
100-
} else if ((fd2 = open_nofollow(path2, O_RDONLY)) < 0 ||
101-
fstat(fd2, &st2) || !S_ISREG(st2.st_mode)) {
102-
ret = 0;
103-
}
104-
105-
if (ret)
106-
/* to match, neither must be executable, or both */
107-
ret = !(st1.st_mode & 0111) == !(st2.st_mode & 0111);
108-
109-
if (ret)
110-
ret = st1.st_size == st2.st_size;
111-
112-
while (ret) {
113-
ssize_t len1 = read_in_full(fd1, buf1, sizeof(buf1));
114-
ssize_t len2 = read_in_full(fd2, buf2, sizeof(buf2));
115-
116-
if (len1 < 0 || len2 < 0 || len1 != len2)
117-
ret = 0; /* read error or different file size */
118-
else if (!len1) /* len2 is also 0; hit EOF on both */
119-
break; /* ret is still true */
120-
else
121-
ret = !memcmp(buf1, buf2, len1);
122-
}
123-
124-
if (fd1 >= 0)
125-
close(fd1);
126-
if (fd2 >= 0)
127-
close(fd2);
128-
129-
return ret;
130-
}

copy.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,4 @@ int copy_fd(int ifd, int ofd);
77
int copy_file(const char *dst, const char *src, int mode);
88
int copy_file_with_time(const char *dst, const char *src, int mode);
99

10-
/*
11-
* Compare the file mode and contents of two given files.
12-
*
13-
* If both files are actually symbolic links, the function returns 1 if the link
14-
* targets are identical or 0 if they are not.
15-
*
16-
* If any of the two files cannot be accessed or in case of read failures, this
17-
* function returns 0.
18-
*
19-
* If the file modes and contents are identical, the function returns 1,
20-
* otherwise it returns 0.
21-
*/
22-
int do_files_match(const char *path1, const char *path2);
23-
2410
#endif /* COPY_H */

fsck.c

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -658,8 +658,6 @@ static int fsck_tree(const struct object_id *tree_oid,
658658
retval += report(options, tree_oid, OBJ_TREE,
659659
FSCK_MSG_MAILMAP_SYMLINK,
660660
".mailmap is a symlink");
661-
oidset_insert(&options->symlink_targets_found,
662-
entry_oid);
663661
}
664662

665663
if ((backslash = strchr(name, '\\'))) {
@@ -1168,56 +1166,6 @@ static int fsck_blob(const struct object_id *oid, const char *buf,
11681166
}
11691167
}
11701168

1171-
if (oidset_contains(&options->symlink_targets_found, oid)) {
1172-
const char *ptr = buf;
1173-
const struct object_id *reported = NULL;
1174-
1175-
oidset_insert(&options->symlink_targets_done, oid);
1176-
1177-
if (!buf || size > PATH_MAX) {
1178-
/*
1179-
* A missing buffer here is a sign that the caller found the
1180-
* blob too gigantic to load into memory. Let's just consider
1181-
* that an error.
1182-
*/
1183-
return report(options, oid, OBJ_BLOB,
1184-
FSCK_MSG_SYMLINK_TARGET_LENGTH,
1185-
"symlink target too long");
1186-
}
1187-
1188-
while (!reported && ptr) {
1189-
const char *p = ptr;
1190-
char c, *slash = strchrnul(ptr, '/');
1191-
char *backslash = memchr(ptr, '\\', slash - ptr);
1192-
1193-
c = *slash;
1194-
*slash = '\0';
1195-
1196-
while (!reported && backslash) {
1197-
*backslash = '\0';
1198-
if (is_ntfs_dotgit(p))
1199-
ret |= report(options, reported = oid, OBJ_BLOB,
1200-
FSCK_MSG_SYMLINK_POINTS_TO_GIT_DIR,
1201-
"symlink target points to git dir");
1202-
*backslash = '\\';
1203-
p = backslash + 1;
1204-
backslash = memchr(p, '\\', slash - p);
1205-
}
1206-
if (!reported && is_ntfs_dotgit(p))
1207-
ret |= report(options, reported = oid, OBJ_BLOB,
1208-
FSCK_MSG_SYMLINK_POINTS_TO_GIT_DIR,
1209-
"symlink target points to git dir");
1210-
1211-
if (!reported && is_hfs_dotgit(ptr))
1212-
ret |= report(options, reported = oid, OBJ_BLOB,
1213-
FSCK_MSG_SYMLINK_POINTS_TO_GIT_DIR,
1214-
"symlink target points to git dir");
1215-
1216-
*slash = c;
1217-
ptr = c ? slash + 1 : NULL;
1218-
}
1219-
}
1220-
12211169
return ret;
12221170
}
12231171

@@ -1316,10 +1264,6 @@ int fsck_finish(struct fsck_options *options)
13161264
FSCK_MSG_GITATTRIBUTES_MISSING, FSCK_MSG_GITATTRIBUTES_BLOB,
13171265
options, ".gitattributes");
13181266

1319-
ret |= fsck_blobs(&options->symlink_targets_found, &options->symlink_targets_done,
1320-
FSCK_MSG_SYMLINK_TARGET_MISSING, FSCK_MSG_SYMLINK_TARGET_BLOB,
1321-
options, "<symlink-target>");
1322-
13231267
return ret;
13241268
}
13251269

fsck.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ enum fsck_msg_type {
6464
FUNC(GITATTRIBUTES_LARGE, ERROR) \
6565
FUNC(GITATTRIBUTES_LINE_LENGTH, ERROR) \
6666
FUNC(GITATTRIBUTES_BLOB, ERROR) \
67-
FUNC(SYMLINK_TARGET_MISSING, ERROR) \
68-
FUNC(SYMLINK_TARGET_BLOB, ERROR) \
6967
/* warnings */ \
7068
FUNC(EMPTY_NAME, WARN) \
7169
FUNC(FULL_PATHNAME, WARN) \
@@ -76,8 +74,6 @@ enum fsck_msg_type {
7674
FUNC(ZERO_PADDED_FILEMODE, WARN) \
7775
FUNC(NUL_IN_COMMIT, WARN) \
7876
FUNC(LARGE_PATHNAME, WARN) \
79-
FUNC(SYMLINK_TARGET_LENGTH, WARN) \
80-
FUNC(SYMLINK_POINTS_TO_GIT_DIR, WARN) \
8177
/* infos (reported as warnings, but ignored by default) */ \
8278
FUNC(BAD_FILEMODE, INFO) \
8379
FUNC(GITMODULES_PARSE, INFO) \
@@ -145,8 +141,6 @@ struct fsck_options {
145141
struct oidset gitmodules_done;
146142
struct oidset gitattributes_found;
147143
struct oidset gitattributes_done;
148-
struct oidset symlink_targets_found;
149-
struct oidset symlink_targets_done;
150144
kh_oid_map_t *object_names;
151145
};
152146

@@ -156,8 +150,6 @@ struct fsck_options {
156150
.gitmodules_done = OIDSET_INIT, \
157151
.gitattributes_found = OIDSET_INIT, \
158152
.gitattributes_done = OIDSET_INIT, \
159-
.symlink_targets_found = OIDSET_INIT, \
160-
.symlink_targets_done = OIDSET_INIT, \
161153
.error_func = fsck_error_function \
162154
}
163155
#define FSCK_OPTIONS_STRICT { \
@@ -166,8 +158,6 @@ struct fsck_options {
166158
.gitmodules_done = OIDSET_INIT, \
167159
.gitattributes_found = OIDSET_INIT, \
168160
.gitattributes_done = OIDSET_INIT, \
169-
.symlink_targets_found = OIDSET_INIT, \
170-
.symlink_targets_done = OIDSET_INIT, \
171161
.error_func = fsck_error_function, \
172162
}
173163
#define FSCK_OPTIONS_MISSING_GITMODULES { \
@@ -176,8 +166,6 @@ struct fsck_options {
176166
.gitmodules_done = OIDSET_INIT, \
177167
.gitattributes_found = OIDSET_INIT, \
178168
.gitattributes_done = OIDSET_INIT, \
179-
.symlink_targets_found = OIDSET_INIT, \
180-
.symlink_targets_done = OIDSET_INIT, \
181169
.error_func = fsck_error_cb_print_missing_gitmodules, \
182170
}
183171

hook.c

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,6 @@
99
#include "strbuf.h"
1010
#include "environment.h"
1111
#include "setup.h"
12-
#include "copy.h"
13-
14-
static int identical_to_template_hook(const char *name, const char *path)
15-
{
16-
const char *env = getenv("GIT_CLONE_TEMPLATE_DIR");
17-
const char *template_dir = get_template_dir(env && *env ? env : NULL);
18-
struct strbuf template_path = STRBUF_INIT;
19-
int found_template_hook, ret;
20-
21-
strbuf_addf(&template_path, "%s/hooks/%s", template_dir, name);
22-
found_template_hook = access(template_path.buf, X_OK) >= 0;
23-
#ifdef STRIP_EXTENSION
24-
if (!found_template_hook) {
25-
strbuf_addstr(&template_path, STRIP_EXTENSION);
26-
found_template_hook = access(template_path.buf, X_OK) >= 0;
27-
}
28-
#endif
29-
if (!found_template_hook)
30-
return 0;
31-
32-
ret = do_files_match(template_path.buf, path);
33-
34-
strbuf_release(&template_path);
35-
return ret;
36-
}
3712

3813
const char *find_hook(const char *name)
3914
{
@@ -70,14 +45,6 @@ const char *find_hook(const char *name)
7045
}
7146
return NULL;
7247
}
73-
if (!git_hooks_path && git_env_bool("GIT_CLONE_PROTECTION_ACTIVE", 0) &&
74-
!identical_to_template_hook(name, path.buf))
75-
die(_("active `%s` hook found during `git clone`:\n\t%s\n"
76-
"For security reasons, this is disallowed by default.\n"
77-
"If this is intentional and the hook should actually "
78-
"be run, please\nrun the command again with "
79-
"`GIT_CLONE_PROTECTION_ACTIVE=false`"),
80-
name, path.buf);
8148
return path.buf;
8249
}
8350

t/helper/test-path-utils.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -501,16 +501,6 @@ int cmd__path_utils(int argc, const char **argv)
501501
return !!res;
502502
}
503503

504-
if (argc == 4 && !strcmp(argv[1], "do_files_match")) {
505-
int ret = do_files_match(argv[2], argv[3]);
506-
507-
if (ret)
508-
printf("equal\n");
509-
else
510-
printf("different\n");
511-
return !ret;
512-
}
513-
514504
fprintf(stderr, "%s: unknown function name: %s\n", argv[0],
515505
argv[1] ? argv[1] : "(there was none)");
516506
return 1;

0 commit comments

Comments
 (0)