Commit | Line | Data |
---|---|---|
ae5ed3b8 FF |
1 | diff -u -r ../git-2.14.3/config.c ./config.c |
2 | --- ../git-2.14.3/config.c 2017-10-23 08:03:35.000000000 +0200 | |
3 | +++ ./config.c 2017-10-25 14:27:28.038111765 +0200 | |
4 | @@ -73,6 +73,25 @@ | |
5 | static int pack_compression_seen; | |
6 | static int zlib_compression_seen; | |
11c62dd2 FF |
7 | |
8 | +/* | |
9 | + * Protecting the project-specific git configuration file (.git/config) is | |
10 | + * not possible on a shared file system on Android, which on an unpatched | |
11 | + * git causes operations such as clone to fail with an error message. | |
12 | + * | |
13 | + * For the Termux git package we introduce a warning about the configuration | |
14 | + * file being unprotected, but proceed in order to allow git repositories | |
15 | + * to be cloned to shared storage accessible to other apps. | |
16 | + */ | |
17 | +static void termux_warn_once_about_lockfile() | |
18 | +{ | |
19 | + static int already_warned; | |
20 | + if (!already_warned) { | |
21 | + warning("Cannot protect .git/config on this file system" | |
22 | + " - do not store sensitive information here."); | |
23 | + already_warned = 1; | |
24 | + } | |
25 | +} | |
26 | + | |
27 | static int config_file_fgetc(struct config_source *conf) | |
28 | { | |
29 | return getc_unlocked(conf->u.file); | |
ae5ed3b8 | 30 | @@ -2535,9 +2554,13 @@ |
11c62dd2 FF |
31 | in_fd = -1; |
32 | ||
ae5ed3b8 | 33 | if (chmod(get_lock_file_path(&lock), st.st_mode & 07777) < 0) { |
11c62dd2 FF |
34 | +#ifdef __ANDROID__ |
35 | + termux_warn_once_about_lockfile(); | |
36 | +#else | |
ae5ed3b8 | 37 | error_errno("chmod on %s failed", get_lock_file_path(&lock)); |
11c62dd2 FF |
38 | ret = CONFIG_NO_WRITE; |
39 | goto out_free; | |
40 | +#endif | |
41 | } | |
42 | ||
43 | if (store.seen == 0) | |
ae5ed3b8 FF |
44 | @@ -2737,9 +2760,13 @@ |
45 | } | |
11c62dd2 FF |
46 | |
47 | if (chmod(get_lock_file_path(lock), st.st_mode & 07777) < 0) { | |
48 | +#ifdef __ANDROID__ | |
49 | + termux_warn_once_about_lockfile(); | |
50 | +#else | |
40c3588b FF |
51 | ret = error_errno("chmod on %s failed", |
52 | get_lock_file_path(lock)); | |
11c62dd2 FF |
53 | goto out; |
54 | +#endif | |
55 | } | |
56 | ||
57 | while (fgets(buf, sizeof(buf), config_file)) { |