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

Re: hooks scripts and noexec partition

From
Jeff King <peff@peff.net>
Date
Dec 17, 2014, 03:03 UTC
Message-ID
<20141217030328.GB4033@peff.net>
In-Reply-To
<CAJ1PRS=KmiQJG91nxG5pQXPHX2XruoyL9c4yzzPeYayw+UAjPw@mail.gmail.com>
On Sun, Dec 14, 2014 at 02:44:35AM +0100, krzf83@gmail.com  wrote:
> Thanks for the patch, however it is not working (no change, hooks
> still dont work on noexec partition). Since I see that you are fluent
> in git code and C can you by any chance tell me how to modify
> run-command.c to make git run hooks as: /bin/sh <hook_path> ?

I do not think that is a smart thing to do in general, as there is no guarantee that the hook is in fact a shell script (and not a binary, or some other scripting language). But if you want do a one-off patch for yourself, knowing that you will only use shell scripts, it is probably something like:

diff --git a/run-command.c b/run-command.c
index a476999..ccfccf0 100644
--- a/run-command.c
+++ b/run-command.c
@@ -812,6 +812,7 @@ int run_hook_ve(const char *const *env, const char *name, va_list args)
 	if (!p)
 		return 0;
 
+	argv_array_push(&hook.args, "/bin/sh");
 	argv_array_push(&hook.args, p);
 	while ((p = va_arg(args, const char *)))
 		argv_array_push(&hook.args, p);

-Peff
Previous: krzf83@gmail.com
Message 4 of 4 in “hooks scripts and noexec partition”
  1. krzf83@gmail.comJan 14, 2014
  2. Jeff KingJan 15, 2014
  3. krzf83@gmail.comDec 14, 2014
  4. Jeff KingDec 17, 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.