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

[PATCH] Replace hard-coded path with one configurable at make time

From
Chris Webb <chris@arachsys.com>
Date
Apr 4, 2010, 20:48 UTC
Message-ID
<186fa4afcc08ad6ba10906a231c437536fbdb8e9.1270412075.git.chris@arachsys.com>

In exec_cmd.c and git-instaweb.sh, git hard-codes a default path of /usr/local/bin:/usr/bin:/bin. Introduce a make variable allowing this to be overridden by passing defpath to make. --- I haven't worked out the capitalisation convention in the makefile, so I'm not sure if this should be DEFPATH or defpath. (For example, prefix is lower-case but DESTDIR is all-caps.)

 Makefile        |    6 +++++-
 exec_cmd.c      |    2 +-
 git-instaweb.sh |    4 ++--
 3 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile
index 11ec3e2..2f4b39e 100644
--- a/Makefile
+++ b/Makefile
@@ -278,6 +278,7 @@ endif
 lib = lib
 # DESTDIR=
 pathsep = :
+defpath = /usr/local/bin:/usr/bin:/bin
 
 # JavaScript minifier invocation that can function as filter
 JSMIN =
@@ -1426,6 +1427,7 @@ gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
 template_dir_SQ = $(subst ','\'',$(template_dir))
 htmldir_SQ = $(subst ','\'',$(htmldir))
 prefix_SQ = $(subst ','\'',$(prefix))
+defpath_SQ = $(subst ','\'',$(defpath))
 
 SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
 PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
@@ -1588,6 +1590,7 @@ git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/gitweb.css gitweb/gitweb.
 	    -e '/@@GITWEB_JS@@/r gitweb/gitweb.js' \
 	    -e '/@@GITWEB_JS@@/d' \
 	    -e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \
+	    -e 's|@@DEFPATH@@|$(defpath_SQ)|g' \
 	    $@.sh > $@+ && \
 	chmod +x $@+ && \
 	mv $@+ $@
@@ -1774,7 +1777,8 @@ endif
 exec_cmd.s exec_cmd.o: EXTRA_CPPFLAGS = \
 	'-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' \
 	'-DBINDIR="$(bindir_relative_SQ)"' \
-	'-DPREFIX="$(prefix_SQ)"'
+	'-DPREFIX="$(prefix_SQ)"' \
+	'-DDEFPATH="$(defpath_SQ)"'
 
 builtin/init-db.s builtin/init-db.o: EXTRA_CPPFLAGS = \
 	-DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_SQ)"'
diff --git a/exec_cmd.c b/exec_cmd.c
index b2c07c7..39c6a59 100644
--- a/exec_cmd.c
+++ b/exec_cmd.c
@@ -107,7 +107,7 @@ void setup_path(void)
 	if (old_path)
 		strbuf_addstr(&new_path, old_path);
 	else
-		strbuf_addstr(&new_path, "/usr/local/bin:/usr/bin:/bin");
+		strbuf_addstr(&new_path, DEFPATH);
 
 	setenv("PATH", new_path.buf, 1);
 
diff --git a/git-instaweb.sh b/git-instaweb.sh
index 6a65f25..72d8b12 100755
--- a/git-instaweb.sh
+++ b/git-instaweb.sh
@@ -212,7 +212,7 @@ server.errorlog = "$fqgitdir/gitweb/error.log"
 # variable above and uncomment this
 #accesslog.filename = "$fqgitdir/gitweb/access.log"
 
-setenv.add-environment = ( "PATH" => "/usr/local/bin:/usr/bin:/bin" )
+setenv.add-environment = ( "PATH" => "@@DEFPATH@@" )
 
 cgi.assign = ( ".cgi" => "" )
 
@@ -361,7 +361,7 @@ error_log	$fqgitdir/gitweb/error.log
 access_log	$fqgitdir/gitweb/access.log
 
 #cgi setup
-cgi_env		PATH=/usr/local/bin:/usr/bin:/bin,GIT_DIR=$GIT_DIR,GIT_EXEC_PATH=$GIT_EXEC_PATH
+cgi_env		PATH=@@DEFPATH@@,GIT_DIR=$GIT_DIR,GIT_EXEC_PATH=$GIT_EXEC_PATH
 cgi_interp	$PERL
 cgi_ext		cgi,pl
 
-- 
1.7.0.3
Next: Junio C Hamano
Message 1 of 24 in “Replace hard-coded path with one configurable at make time”
  1. Replace hard-coded path with one configurable at make timeChris Webb, Apr 4, 2010
  2. Junio C HamanoApr 4, 2010
  3. Chris WebbApr 4, 2010
  4. Chris WebbApr 6, 2010
  5. Replace hard-coded path with one from <paths.h>Chris Webb, Apr 6, 2010
  6. Erik Faye-LundApr 7, 2010
  7. Chris WebbApr 8, 2010
  8. Erik Faye-LundApr 8, 2010
  9. Replace hard-coded path with one from <paths.h>Chris Webb, Apr 8, 2010
  10. Erik Faye-LundApr 8, 2010
  11. Chris WebbApr 9, 2010
  12. Chris WebbApr 13, 2010
  13. Replace hard-coded path with one from <paths.h>Chris Webb, Apr 13, 2010
  14. Junio C HamanoApr 13, 2010
  15. Chris WebbApr 14, 2010
  16. Jakub NarebskiApr 15, 2010
  17. Junio C HamanoApr 15, 2010
  18. Jakub NarebskiApr 15, 2010
  19. Chris WebbApr 15, 2010
  20. Jakub NarebskiApr 15, 2010
  21. Chris WebbApr 15, 2010
  22. Replace hard-coded path with one from <paths.h>Chris Webb, Apr 15, 2010
  23. TaitApr 9, 2010
  24. git-instaweb: pass through invoking user's path to gitweb CGI scriptChris Webb, Apr 6, 2010

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.