git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2] Improve the filemode trustability check

From
Torsten Bögershausen <tboegi@web.de>
Date
Nov 20, 2014, 11:49 UTC
Message-ID
<546DD52F.90302@web.de>
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 currently not done.

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>
---
Changes since V1:
- Improved commit msg (hopefully)
- Simplified the patch
 builtin/init-db.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/builtin/init-db.c b/builtin/init-db.c
index aab44d2..195a88b 100644
--- a/builtin/init-db.c
+++ b/builtin/init-db.c
@@ -252,7 +252,8 @@ 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 = (!(st1.st_mode & S_IXUSR) &&
+				!chmod(path, st1.st_mode ^ S_IXUSR) &&
 				!lstat(path, &st2) &&
 				st1.st_mode != st2.st_mode &&
 				!chmod(path, st1.st_mode));
-- 
2.0.0.GIT
Next: Junio C Hamano
Message 1 of 2 in “Improve the filemode trustability check”
  1. Improve the filemode trustability checkTorsten Bögershausen, Nov 20, 2014
  2. Junio C HamanoNov 20, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.