# [PATCH] git-instaweb: detect difference between mod_cgi and mod_cgid for apache2

2 messages from 2009-08-10 to 2009-08-11. Participants: Mark A Rada.
Thread: https://gitlist.dev/t/20512

## Mark A Rada, 2009-08-10 05:19

Subject: [PATCH] git-instaweb: detect difference between mod_cgi and mod_cgid for apache2
Message-ID: <8366E0BD-3A64-4DDD-B12C-2FD48C357FFB@mailservices.uwaterloo.ca>
URL: https://gitlist.dev/e/8366E0BD-3A64-4DDD-B12C-2FD48C357FFB%40mailservices.uwaterloo.ca

```
I'm not sure if this should have been two patches or just one.

First I changed the check of whether mod_cgi is built in or not from  
matching against
'mod_cgi.c' to 'mod_cgi' because I made the assumption that mod_cgid  
would be called
'mod_cgid.c' (I haven't actually checked this, but it sounds  
reasonable). Then, the
second change handles the two cases when no cgi module is built in,  
which I  did try
(for mod_cgid that is).

Also, should the socket needed for mod_cgid be put in $GIT_DIR or  
somewhere else?


tl;dr I only actually tried 1/4 cases, everything else looks reasonable


--
Mark A Rada (ferrous26)
marada@uwaterloo.ca


--->8---
Some people have mod_cgid in place of mod_cgi, this will check which one
the user has available to them first, and then act accordingly.

Signed-off-by: Mark Rada <marada@uwaterloo.ca>
---
  git-instaweb.sh |   10 ++++++++--
  1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/git-instaweb.sh b/git-instaweb.sh
index 5f5cac7..fdac0d0 100755
--- a/git-instaweb.sh
+++ b/git-instaweb.sh
@@ -297,8 +297,14 @@ EOF
  		# plain-old CGI
  		resolve_full_httpd
  		list_mods=$(echo "$full_httpd" | sed "s/-f$/-l/")
-		$list_mods | grep 'mod_cgi\.c' >/dev/null 2>&1 || \
-		echo "LoadModule cgi_module $module_path/mod_cgi.so" >> "$conf"
+		$list_mods | grep 'mod_cgi' >/dev/null 2>&1 || \
+		if test -f "$module_path/mod_cgi.so"
+		then
+			echo "LoadModule cgi_module $module_path/mod_cgi.so" >> "$conf"
+		else
+			echo "LoadModule cgi_module $module_path/mod_cgid.so" >> "$conf"
+			echo "ScriptSock $GIT_DIR/gitweb.sock" >> "$conf"
+		fi
  		cat >> "$conf" <<EOF
  AddHandler cgi-script .cgi
  <Location /gitweb.cgi>
-- 
1.6.4

```

## Mark A Rada, 2009-08-11 01:23

Subject: Re: [PATCH] git-instaweb: detect difference between mod_cgi and mod_cgid for apache2
Message-ID: <7B93F2E3-D6F9-4A5D-BAE1-F630F09E9909@mailservices.uwaterloo.ca>
URL: https://gitlist.dev/e/7B93F2E3-D6F9-4A5D-BAE1-F630F09E9909%40mailservices.uwaterloo.ca
In-Reply-To: <8366E0BD-3A64-4DDD-B12C-2FD48C357FFB@mailservices.uwaterloo.ca>

```
If you haven't already, ignore this patch, I'm pretty sure it won't  
work for cases where mod_cgid
is built in. I think it should be including the ScriptSock directive  
when built in as well, but I don't
have a setup to test that on, and the apache documentation isn't very  
specific.

I'll try again later, sorry for the spam.


--
Mark A Rada (ferrous26)
marada@uwaterloo.ca


On 10-Aug-09, at 1:19 AM, Mark A Rada wrote:

> I'm not sure if this should have been two patches or just one.
>
> First I changed the check of whether mod_cgi is built in or not from  
> matching against
> 'mod_cgi.c' to 'mod_cgi' because I made the assumption that mod_cgid  
> would be called
> 'mod_cgid.c' (I haven't actually checked this, but it sounds  
> reasonable). Then, the
> second change handles the two cases when no cgi module is built in,  
> which I  did try
> (for mod_cgid that is).
>
> Also, should the socket needed for mod_cgid be put in $GIT_DIR or  
> somewhere else?
>
>
> tl;dr I only actually tried 1/4 cases, everything else looks  
> reasonable
>
>
> --
> Mark A Rada (ferrous26)
> marada@uwaterloo.ca
>
>
> --->8---
> Some people have mod_cgid in place of mod_cgi, this will check which  
> one
> the user has available to them first, and then act accordingly.
>
> Signed-off-by: Mark Rada <marada@uwaterloo.ca>
> ---
> git-instaweb.sh |   10 ++++++++--
> 1 files changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/git-instaweb.sh b/git-instaweb.sh
> index 5f5cac7..fdac0d0 100755
> --- a/git-instaweb.sh
> +++ b/git-instaweb.sh
> @@ -297,8 +297,14 @@ EOF
> 		# plain-old CGI
> 		resolve_full_httpd
> 		list_mods=$(echo "$full_httpd" | sed "s/-f$/-l/")
> -		$list_mods | grep 'mod_cgi\.c' >/dev/null 2>&1 || \
> -		echo "LoadModule cgi_module $module_path/mod_cgi.so" >> "$conf"
> +		$list_mods | grep 'mod_cgi' >/dev/null 2>&1 || \
> +		if test -f "$module_path/mod_cgi.so"
> +		then
> +			echo "LoadModule cgi_module $module_path/mod_cgi.so" >> "$conf"
> +		else
> +			echo "LoadModule cgi_module $module_path/mod_cgid.so" >> "$conf"
> +			echo "ScriptSock $GIT_DIR/gitweb.sock" >> "$conf"
> +		fi
> 		cat >> "$conf" <<EOF
> AddHandler cgi-script .cgi
> <Location /gitweb.cgi>
> -- 
> 1.6.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

```
