From: "Torsten Bögershausen" <tboegi@web.de>
To: git@vger.kernel.org
Cc: tboegi@web.de
Subject: [PATCH] Improve the filemode trustability check
Date: Wed, 19 Nov 2014 16:10:48 +0100 [thread overview]
Message-ID: <546CB2F8.7040501@web.de> (raw)
Some file systems do not support the executable bit:
a) The user executable bit is always 0, e.g. VFAT mounted with -onoexec
b) The user executable bit is always 1, e.g. cifs mounted with -ofile_mode=0755
c) There are system where user executable bit is 1 even if it should be 0
like b), but the file mode can be maintained locally. chmod -x changes the
file mode from 0766 to 0666, until the file system is unmounted and
remounted and the file mode is 0766 again.
This been observed when a Windows machine with NTFS exports a share to
Mac OS X via smb or afp.
Case a) and b) are handled by the current code.
Case c) qualifies as "non trustable executable bit" and core.filemode
should be false, but this is not done.
Solution:
Detect when ".git/config" has the user executable bit set after
creat(".git/config", 0666) and set core.filemode to false.
Signed-off-by: Torsten Bögershausen <tboegi@web.de>
---
This should go on top of "mh/config-flip-xbit-back-after-checking"
Michael, thanks for the test case.
And no, I havent seen any systems with behaving like d)
builtin/init-db.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/builtin/init-db.c b/builtin/init-db.c
index aab44d2..9b50dde 100644
--- a/builtin/init-db.c
+++ b/builtin/init-db.c
@@ -252,10 +252,10 @@ static int create_default_files(const char *template_path)
filemode = TEST_FILEMODE;
if (TEST_FILEMODE && !lstat(path, &st1)) {
struct stat st2;
- filemode = (!chmod(path, st1.st_mode ^ S_IXUSR) &&
+ filemode = (!chmod(path, st1.st_mode | S_IXUSR) &&
!lstat(path, &st2) &&
st1.st_mode != st2.st_mode &&
- !chmod(path, st1.st_mode));
+ !chmod(path, st1.st_mode & (~S_IXUSR)));
}
git_config_set("core.filemode", filemode ? "true" : "false");
--
1.9.1.dirty
next reply other threads:[~2014-11-19 15:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-19 15:10 Torsten Bögershausen [this message]
2014-11-19 18:58 ` [PATCH] Improve the filemode trustability check Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=546CB2F8.7040501@web.de \
--to=tboegi@web.de \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).