Skip to content

Commit 1ac7422

Browse files
committed
Sync with Git 2.35.3
2 parents 11cfe55 + d516b2d commit 1ac7422

File tree

9 files changed

+106
-3
lines changed

9 files changed

+106
-3
lines changed

Documentation/RelNotes/2.30.4.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Git v2.30.4 Release Notes
2+
=========================
3+
4+
This release contains minor fix-ups for the changes that went into
5+
Git 2.30.3, which was made to address CVE-2022-24765.
6+
7+
* The code that was meant to parse the new `safe.directory`
8+
configuration variable was not checking what configuration
9+
variable was being fed to it, which has been corrected.
10+
11+
* '*' can be used as the value for the `safe.directory` variable to
12+
signal that the user considers that any directory is safe.
13+
14+
15+
16+
Derrick Stolee (2):
17+
t0033: add tests for safe.directory
18+
setup: opt-out of check with safe.directory=*
19+
20+
Matheus Valadares (1):
21+
setup: fix safe.directory key not being checked

Documentation/RelNotes/2.31.3.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Git Documentation/RelNotes/2.31.3.txt Release Notes
2+
=========================
3+
4+
This release merges up the fixes that appear in v2.31.3.

Documentation/RelNotes/2.32.2.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Git Documentation/RelNotes/2.32.2.txt Release Notes
2+
=========================
3+
4+
This release merges up the fixes that appear in v2.32.2.

Documentation/RelNotes/2.33.3.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Git Documentation/RelNotes/2.33.3.txt Release Notes
2+
=========================
3+
4+
This release merges up the fixes that appear in v2.33.3.

Documentation/RelNotes/2.34.3.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Git Documentation/RelNotes/2.34.3.txt Release Notes
2+
=========================
3+
4+
This release merges up the fixes that appear in v2.34.3.

Documentation/RelNotes/2.35.3.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Git Documentation/RelNotes/2.35.3.txt Release Notes
2+
=========================
3+
4+
This release merges up the fixes that appear in v2.35.3.

Documentation/config/safe.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,10 @@ line option `-c safe.directory=<path>`.
1919
The value of this setting is interpolated, i.e. `~/<path>` expands to a
2020
path relative to the home directory and `%(prefix)/<path>` expands to a
2121
path relative to Git's (runtime) prefix.
22+
+
23+
To completely opt-out of this security check, set `safe.directory` to the
24+
string `*`. This will allow all repositories to be treated as if their
25+
directory was listed in the `safe.directory` list. If `safe.directory=*`
26+
is set in system config and you want to re-enable this protection, then
27+
initialize your list with an empty value before listing the repositories
28+
that you deem safe.

setup.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,9 +1100,14 @@ static int safe_directory_cb(const char *key, const char *value, void *d)
11001100
{
11011101
struct safe_directory_data *data = d;
11021102

1103-
if (!value || !*value)
1103+
if (strcmp(key, "safe.directory"))
1104+
return 0;
1105+
1106+
if (!value || !*value) {
11041107
data->is_safe = 0;
1105-
else {
1108+
} else if (!strcmp(value, "*")) {
1109+
data->is_safe = 1;
1110+
} else {
11061111
const char *interpolated = NULL;
11071112

11081113
if (!git_config_pathname(&interpolated, key, value) &&
@@ -1119,7 +1124,8 @@ static int ensure_valid_ownership(const char *path)
11191124
{
11201125
struct safe_directory_data data = { .path = path };
11211126

1122-
if (is_path_owned_by_current_user(path))
1127+
if (!git_env_bool("GIT_TEST_ASSUME_DIFFERENT_OWNER", 0) &&
1128+
is_path_owned_by_current_user(path))
11231129
return 1;
11241130

11251131
read_very_early_config(safe_directory_cb, &data);

t/t0033-safe-directory.sh

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/sh
2+
3+
test_description='verify safe.directory checks'
4+
5+
. ./test-lib.sh
6+
7+
GIT_TEST_ASSUME_DIFFERENT_OWNER=1
8+
export GIT_TEST_ASSUME_DIFFERENT_OWNER
9+
10+
expect_rejected_dir () {
11+
test_must_fail git status 2>err &&
12+
grep "safe.directory" err
13+
}
14+
15+
test_expect_success 'safe.directory is not set' '
16+
expect_rejected_dir
17+
'
18+
19+
test_expect_success 'safe.directory does not match' '
20+
git config --global safe.directory bogus &&
21+
expect_rejected_dir
22+
'
23+
24+
test_expect_success 'path exist as different key' '
25+
git config --global foo.bar "$(pwd)" &&
26+
expect_rejected_dir
27+
'
28+
29+
test_expect_success 'safe.directory matches' '
30+
git config --global --add safe.directory "$(pwd)" &&
31+
git status
32+
'
33+
34+
test_expect_success 'safe.directory matches, but is reset' '
35+
git config --global --add safe.directory "" &&
36+
expect_rejected_dir
37+
'
38+
39+
test_expect_success 'safe.directory=*' '
40+
git config --global --add safe.directory "*" &&
41+
git status
42+
'
43+
44+
test_expect_success 'safe.directory=*, but is reset' '
45+
git config --global --add safe.directory "" &&
46+
expect_rejected_dir
47+
'
48+
49+
test_done

0 commit comments

Comments
 (0)