Skip to contentSkip to conversation

Smart-http documentation: add example of how to execute from userdir

PATCH In review Tarmigan Casebolt 4 participants 14 messages Jun 15, 2016 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Smart-http documentation: add example of how to execute from userdir

Smart-http may be an attactive and easy way for people to setup git hosting on shared servers whose primary web server configuration they do not control. To facilite this, provide an example of how it may be done.

---
 Documentation/git-http-backend.txt |   40 ++++++++++++++++++++++++++++++++++-
 1 files changed, 38 insertions(+), 2 deletions(-)
Documentation/git-http-backend.txt +38 -2
index 67aec06..0cca5ba 100644
@@ -60,8 +60,8 @@ automatically by the web server.
 
 EXAMPLES
 --------
-All of the following examples map 'http://$hostname/git/foo/bar.git'
-to '/var/www/git/foo/bar.git'.
+Unless otherwise noted, the following examples map
+'http://$hostname/git/foo/bar.git' to '/var/www/git/foo/bar.git'.
 
 Apache 2.x::
 	Ensure mod_cgi, mod_alias, and mod_env are enabled, set
@@ -144,6 +144,42 @@ ScriptAliasMatch \
 ScriptAlias /git/ /var/www/cgi-bin/gitweb.cgi/
 ----------------------------------------------------------------
 
+In the following example, a repository at
+'/home/$username/devel/foo/bar.git' will be accessible at
+'http://$hostname/\~$username/cgi-bin/git/foo/bar.git'
+
+From UserDir on Apache 2.x::
+       One way to configure 'git-http-backend' to execute and serve
+       from a user directory (for example, on a shared hosting
+       provider), is to have a symbolic link that points from the cgi
+       directory to the 'git-http-backend' executable in libexec.  The
+       advantage of the symblic link is that any updates to the
+       installed version of 'git-http-backend' also update the version
+       that is run in the userdir.  Depending on the configuration of
+       the server, the symbolic link may be able to point to a global
+       installation of git.  If, for security reasons, the server is
+       configured to follow symbolic links only if the owner matches,
+       an installation of git into the user directory may be required.
+       In that case, install git as that user into \~/bin, \~/libexec
+       etc.  Then create a symlink named 'git' in the cgi-bin
+       directory that points to
+       \~/libexec/git-core/git-http-backend. Put the following in
+       \~/public_html/cgi-bin/.htaccess:
++
+----------------------------------------------------------------
+SetHandler cgi-script
+Options +SymLinksIfOwnerMatch
+SetEnv GIT_PROJECT_ROOT /home/$username/devel
+----------------------------------------------------------------
++
+Also add any needed authentication to the .htaccess file as discussed
+in earlier examples.
++
+If the web server does not follow any symbolic links, the
+'git-http-backend' executable may be copied into the cgi-bin directory
+and renamed to 'git' to acheive the same effect, but it will also need
+to be manually updated whenever a new version of 'git-http-backend' is
+installed.
 
 ENVIRONMENT
 -----------
Signature · 1 line
1.6.6
#1 lore raw
Quoted 4 lines · Tarmigan Casebolt

Smart-http may be an attactive and easy way for people to setup git hosting on shared servers whose primary web server configuration they do not control. To facilite this, provide an example of how it may be done.

...

Documentation/git-http-backend.txt ScriptAliasMatch \ · line 173

Quoted 7 lines
Documentation/git-http-backend.txt +7 -0
+       \~/public_html/cgi-bin/.htaccess:
++
+----------------------------------------------------------------
+SetHandler cgi-script
+Options +SymLinksIfOwnerMatch
+SetEnv GIT_PROJECT_ROOT /home/$username/devel
+----------------------------------------------------------------

At this point, isn't this just easier?

mkdir ~/public_html/git
vi ~/public_html/git/.htaccess

SetEnv GIT_PROJECT_ROOT /home/$username/devel ScriptAlias / /usr/libexec/git-core/git-http-backend/

No need to mess around with SymlinksIfOwnerMatch and all of that fun. If you have .htaccess override allows, you should be able to setup a ScriptAlias without needing to use a cgi-bin directory.

Signature · 1 line
Shawn.
author
#2 lore raw
Quoted 16 lines · Shawn O. Pearce
Quoted 4 lines · Tarmigan Casebolt

Smart-http may be an attactive and easy way for people to setup git hosting on shared servers whose primary web server configuration they do not control.  To facilite this, provide an example of how it may be done.

...

Documentation/git-http-backend.txt ScriptAliasMatch \ · line 173

Quoted 7 lines

+       \~/public_html/cgi-bin/.htaccess:
++
+----------------------------------------------------------------

Documentation/git-http-backend.txt +4 -0
+SetHandler cgi-script
+Options +SymLinksIfOwnerMatch
+SetEnv GIT_PROJECT_ROOT /home/$username/devel
+----------------------------------------------------------------

At this point, isn't this just easier?

Quoted 5 lines

 mkdir ~/public_html/git
 vi ~/public_html/git/.htaccess

 SetEnv GIT_PROJECT_ROOT /home/$username/devel ScriptAlias / /usr/libexec/git-core/git-http-backend/

Yes, that would be perfect. But ScriptAlias is only valid in the "server config" or "virtual host" contexts which is why the symlink/copy executable convolutions might be needed. Can you see a simpler way around it?

Thanks,
Tarmigan

#3 lore raw
In reply to Tarmigan Casebolt

Hi,

Documentation/git-http-backend.txt automatically by the web server. · line 64

Quoted 8 lines · Tarmigan Casebolt
(quoted diff) +0 -0
@@ -60,8 +60,8 @@ automatically by the web server.
 

 EXAMPLES
 --------

Documentation/git-http-backend.txt +2 -2
-All of the following examples map 'http://$hostname/git/foo/bar.git'
-to '/var/www/git/foo/bar.git'.
+Unless otherwise noted, the following examples map
+'http://$hostname/git/foo/bar.git' to '/var/www/git/foo/bar.git'.

This rephrase seems to be unrelated (to providing an example of serving smart http).

Quoted 4 lines
(quoted diff) +0 -0
@@ -144,6 +144,42 @@ ScriptAliasMatch \

 ScriptAlias /git/ /var/www/cgi-bin/gitweb.cgi/
 ----------------------------------------------------------------

Documentation/git-http-backend.txt ScriptAliasMatch \ · line 156

Quoted 10 lines
Documentation/git-http-backend.txt +10 -0
+In the following example, a repository at
+'/home/$username/devel/foo/bar.git' will be accessible at
+'http://$hostname/\~$username/cgi-bin/git/foo/bar.git'
+
+From UserDir on Apache 2.x::
+       One way to configure 'git-http-backend' to execute and serve
+       from a user directory (for example, on a shared hosting
+       provider), is to have a symbolic link that points from the cgi
+       directory to the 'git-http-backend' executable in libexec.  The
+       advantage of the symblic link is that any updates to the

s/symblic/symbolic/.

Quoted 1 line

+       installed version of 'git-http-backend' also update the version

s/update/updates/.

Quoted 3 lines

+       that is run in the userdir.  Depending on the configuration of
+       the server, the symbolic link may be able to point to a global
+       installation of git.  If, for security reasons, the server is

At this point, the user dealing with the "easy" case (ie. the user just symlinks the shared git installation and doesn't have to create symlinks in his own home directory) should have enough configuration details without having to read any further. So, you could tell the user about the symlinks to create and the configuration lines in .htaccess.

It might also be a good idea to start a new paragraph for the "hard" case, for better readability.

Signature · 2 lines
Cheers,
Ray Chuan
author
#4 lore raw
Quoted 7 lines · Tay Ray Chuan

Documentation/git-http-backend.txt automatically by the web server. · line 64

Quoted 4 lines
Documentation/git-http-backend.txt +2 -2
-All of the following examples map 'http://$hostname/git/foo/bar.git'
-to '/var/www/git/foo/bar.git'.
+Unless otherwise noted, the following examples map
+'http://$hostname/git/foo/bar.git' to '/var/www/git/foo/bar.git'.

This rephrase seems to be unrelated (to providing an example of serving smart http).

I think this change is related because previously all the examples provided the same mapping. With the new example with a different mapping, the "_All_ of the following" is no longer true.

Quoted 4 lines
Quoted 4 lines
(quoted diff) +0 -0
@@ -144,6 +144,42 @@ ScriptAliasMatch \

 ScriptAlias /git/ /var/www/cgi-bin/gitweb.cgi/
 ----------------------------------------------------------------

Quoted 13 lines

Documentation/git-http-backend.txt ScriptAliasMatch \ · line 156

Quoted 10 lines
Documentation/git-http-backend.txt +10 -0
+In the following example, a repository at
+'/home/$username/devel/foo/bar.git' will be accessible at
+'http://$hostname/\~$username/cgi-bin/git/foo/bar.git'
+
+From UserDir on Apache 2.x::
+       One way to configure 'git-http-backend' to execute and serve
+       from a user directory (for example, on a shared hosting
+       provider), is to have a symbolic link that points from the cgi
+       directory to the 'git-http-backend' executable in libexec.  The
+       advantage of the symblic link is that any updates to the

s/symblic/symbolic
s/update/updates/.

Thanks.

Quoted 9 lines

At this point, the user dealing with the "easy" case (ie. the user just symlinks the shared git installation and doesn't have to create symlinks in his own home directory) should have enough configuration details without having to read any further. So, you could tell the user about the symlinks to create and the configuration lines in .htaccess.

It might also be a good idea to start a new paragraph for the "hard" case, for better readability.

OK, these suggestions sound good to me. I'll send out an updated patch shortly.

Thanks,
Tarmigan

#5 lore raw

PATCH v2 1/1 Smart-http documentation: add example of how to execute from userdir

Smart-http may be an attactive and easy way for people to setup git hosting on shared servers whose primary web server configuration they do not control. To facilite this, provide an example of how it may be done.

cc Tay Ray Chuan <[email protected]>
cc Shawn O. Pearce <[email protected]>

---
Looking at the
s/update/updates/
suggestion again, I decided not to make that change because I think the original is grammical even if a little bit awkward. The first 'updates' is the noun, so the verb should be 'update' without an 's'.

I also tried rephrasing that sentence completely, but did not end up with something better. Suggestions welcome.

 Documentation/git-http-backend.txt |   31 +++++++++++++++++++++++++++++--
 1 files changed, 29 insertions(+), 2 deletions(-)
Documentation/git-http-backend.txt +29 -2
index 67aec06..fdff2d3 100644
@@ -60,8 +60,8 @@ automatically by the web server.
 
 EXAMPLES
 --------
-All of the following examples map 'http://$hostname/git/foo/bar.git'
-to '/var/www/git/foo/bar.git'.
+Unless otherwise noted, the following examples map
+'http://$hostname/git/foo/bar.git' to '/var/www/git/foo/bar.git'.
 
 Apache 2.x::
 	Ensure mod_cgi, mod_alias, and mod_env are enabled, set
@@ -144,6 +144,33 @@ ScriptAliasMatch \
 ScriptAlias /git/ /var/www/cgi-bin/gitweb.cgi/
 ----------------------------------------------------------------
 
+In the following example, a repository at
+'/home/$username/devel/foo/bar.git' will be accessible at
+'http://$hostname/\~$username/cgi-bin/git/foo/bar.git'
+
+From UserDir on Apache 2.x::
+       One way to configure 'git-http-backend' to execute and serve
+       from a user directory (for example, on a shared hosting
+       provider), is to have a symbolic link named 'git' that points
+       from the cgi directory to the 'git-http-backend' executable in
+       libexec.  The advantage of the symbolic link is that any updates
+       to the installed version of 'git-http-backend' also update the
+       version that is run in the userdir.
++
+----------------------------------------------------------------
+SetHandler cgi-script
+Options +SymLinksIfOwnerMatch
+SetEnv GIT_PROJECT_ROOT /home/$username/devel
+----------------------------------------------------------------
++
+Also add any needed authentication to the .htaccess file as discussed
+in earlier examples.
++
+If the web server does not follow any symbolic links, the
+'git-http-backend' executable may be copied into the cgi-bin directory
+and renamed to 'git' to acheive the same effect, but it will also need
+to be manually updated whenever a new version of 'git-http-backend' is
+installed.
 
 ENVIRONMENT
 -----------
Signature · 1 line
1.6.6.1.g8eede.dirty
#6 lore raw

Hi,

Quoted 5 lines · Tarmigan Casebolt

Looking at the
       s/update/updates/
suggestion again, I decided not to make that change because I think the original is grammical even if a little bit awkward.  The first 'updates' is the noun, so the verb should be 'update' without an 's'.

Indeed.

Quoted 2 lines

I also tried rephrasing that sentence completely, but did not end up with something better. ?Suggestions welcome.

My attempt is found below.

Quoted 1 line

+In the following example, a repository at

I was thinking s/a repository at/the repository/.

Quoted 2 lines

+'/home/$username/devel/foo/bar.git' will be accessible at +'http://$hostname/\~$username/cgi-bin/git/foo/bar.git'

You left out a full-stop for this sentence.

Quoted 8 lines

+From UserDir on Apache 2.x::
+       One way to configure 'git-http-backend' to execute and serve
+       from a user directory (for example, on a shared hosting
+       provider), is to have a symbolic link named 'git' that points
+       from the cgi directory to the 'git-http-backend' executable in
+       libexec.  The advantage of the symbolic link is that any updates
+       to the installed version of 'git-http-backend' also update the
+       version that is run in the userdir.

We could try

The advantage is that this symbolic link always points to the latest installed version; one does not have to make any changes to the symbolic link when the installed 'git-http-backend' is updated.

I thought the corollary (after the ';') was a bit long-winded, but it explains the advantage more clearly.

Signature · 2 lines
Cheers,
Ray Chuan
#7 lore raw

PATCH v3 1/1 Smart-http documentation: add example of how to execute from userdir

Smart-http may be an attactive and easy way for people to setup git hosting on shared servers whose primary web server configuration they do not control. To facilite this, provide an example of how it may be done.

---
 Documentation/git-http-backend.txt |   32 ++++++++++++++++++++++++++++++--
 1 files changed, 30 insertions(+), 2 deletions(-)
Documentation/git-http-backend.txt +30 -2
index 67aec06..0485033 100644
@@ -60,8 +60,8 @@ automatically by the web server.
 
 EXAMPLES
 --------
-All of the following examples map 'http://$hostname/git/foo/bar.git'
-to '/var/www/git/foo/bar.git'.
+Unless otherwise noted, the following examples map
+'http://$hostname/git/foo/bar.git' to '/var/www/git/foo/bar.git'.
 
 Apache 2.x::
 	Ensure mod_cgi, mod_alias, and mod_env are enabled, set
@@ -144,6 +144,34 @@ ScriptAliasMatch \
 ScriptAlias /git/ /var/www/cgi-bin/gitweb.cgi/
 ----------------------------------------------------------------
 
+In the following example, the repository at
+'/home/$username/devel/foo/bar.git' will be accessible at
+'http://$hostname/~$username/cgi-bin/git/foo/bar.git'.
+
+From UserDir on Apache 2.x::
+       One way to configure 'git-http-backend' to execute and serve
+       from a user directory (for example, on a shared hosting
+       provider), is to have a symbolic link named 'git' that points
+       from the cgi directory to the 'git-http-backend' executable in
+       libexec.  The advantage is that this symbolic link always
+       points to the latest installed version; one does not have to
+       make any changes to the symbolic link when the installed
+       'git-http-backend' is updated.
++
+----------------------------------------------------------------
+SetHandler cgi-script
+Options +SymLinksIfOwnerMatch
+SetEnv GIT_PROJECT_ROOT /home/$username/devel
+----------------------------------------------------------------
++
+Also add any needed authentication to the .htaccess file as discussed
+in earlier examples.
++
+If the web server does not follow any symbolic links, the
+'git-http-backend' executable may be copied into the cgi-bin directory
+and renamed to 'git' to acheive the same effect, but it will also need
+to be manually updated whenever a new version of 'git-http-backend' is
+installed.
 
 ENVIRONMENT
 -----------
Signature · 1 line
1.6.6.236.gc56f3
#8 lore raw
Quoted 9 lines · Tarmigan Casebolt

Smart-http may be an attactive and easy way for people to setup git hosting on shared servers whose primary web server configuration they do not control. To facilite this, provide an example of how it may be done.

I still see Cc: here; are people named above (and others commented on earlier versions) happy with this round?

Acked-by on v3 1/1
#13 lore raw
In reply to Tarmigan Casebolt

Hi,

Quoted 9 lines · Tarmigan Casebolt

Smart-http may be an attactive and easy way for people to setup git hosting on shared servers whose primary web server configuration they do not control.  To facilite this, provide an example of how it may be done.

Signature · 2 lines
Cheers,
Ray Chuan
#9 lore raw
In reply to Junio C Hamano
Quoted 7 lines · Junio C Hamano
Quoted 5 lines · Tarmigan Casebolt

Smart-http may be an attactive and easy way for people to setup git hosting on shared servers whose primary web server configuration they do not control. To facilite this, provide an example of how it may be done.

Quoted 7 lines
Quoted 4 lines

I still see Cc: here; are people named above (and others commented on earlier versions) happy with this round?

I don't get why Options +SymLinksIfOwnerMatch is needed here.

If we are linking to the root installed git-http-backend Apache will actually reject the link, because the link owner is likely to be $USER while the target is owned by root.

So I really can't ACK this, the instructions don't jive with my understanding of the Apache configuration.

Signature · 1 line
Shawn.
author
#10 lore raw
Quoted 4 lines · Shawn O. Pearce
Quoted 2 lines · Junio C Hamano

I still see Cc: here; are people named above (and others commented on earlier versions) happy with this round?

Quoted 8 lines

I don't get why Options +SymLinksIfOwnerMatch is needed here.

If we are linking to the root installed git-http-backend Apache will actually reject the link, because the link owner is likely to be $USER while the target is owned by root.

So I really can't ACK this, the instructions don't jive with my understanding of the Apache configuration.

Fair enough.

There seem to be three reasonable ways to run from a userdir (depending on what the global configuration allows):
- symlink to global git installation (if FollowSymLinks)
- symlink to user's git installation (if not FollowSymLink and only SymLinkIfOwnerMatch)
- copy of git-http-backend binary (if no symlinks are followed)

The Options +SymLinksIfOwnerMatch is left over from when there was a more detailed description of the second scenario and should probably be removed now. The user may not have a choice about which of those three can be used because it depends on the global server configuration (which presumably the user does not control) so it's difficult to provide instructions that will work for everyone. The last option is likely to be the most portable, but also does not get updated when the primary http-backend binary is updated.

Enumerating the details of setting up all of these configurations in the man page seems excessive, but it would also be nice to have enough information to still make it easy.

We could do one or more of the following:
- Remove the Options +SymLinksIfOwnerMatch as it is too specific to an unknown configuration and let users figure out how to get symlinks to work for their particular configuration
- Add a note to remind the user about SymLinksIfOwnerMatch or FollowSymLinks
- Emphasize copying git-http-backend binary into the cgi-bin directory as that is likely the most portable across configurations
- Expand all three scenarios in detail

I'm inclined to do the first two with the following patch (cut-n-paste warning) squashed in. I'll send the complete patch as a follow up.

Thanks,
Tarmigan

Documentation/git-http-backend.txt +2 -1
index 0485033..7af1288 100644
@@ -160,13 +160,14 @@ From UserDir on Apache 2.x::
 +
 ----------------------------------------------------------------
 SetHandler cgi-script
-Options +SymLinksIfOwnerMatch
 SetEnv GIT_PROJECT_ROOT /home/$username/devel
 ----------------------------------------------------------------
 +
 Also add any needed authentication to the .htaccess file as discussed
 in earlier examples.
 +
+Depending on the global configuration of the web server, the
+"FollowSymLinks" or "SymLinksIfOwnerMatch" options might be needed.
 If the web server does not follow any symbolic links, the
 'git-http-backend' executable may be copied into the cgi-bin directory
 and renamed to 'git' to acheive the same effect, but it will also need
#11 lore raw

PATCH v4 1/1 Smart-http documentation: add example of how to execute from userdir

Smart-http may be an attactive and easy way for people to setup git hosting on shared servers whose primary web server configuration they do not control. To facilite this, provide an example of how it may be done.

---
 Documentation/git-http-backend.txt |   33 +++++++++++++++++++++++++++++++--
 1 files changed, 31 insertions(+), 2 deletions(-)
Documentation/git-http-backend.txt +31 -2
index 67aec06..7af1288 100644
@@ -60,8 +60,8 @@ automatically by the web server.
 
 EXAMPLES
 --------
-All of the following examples map 'http://$hostname/git/foo/bar.git'
-to '/var/www/git/foo/bar.git'.
+Unless otherwise noted, the following examples map
+'http://$hostname/git/foo/bar.git' to '/var/www/git/foo/bar.git'.
 
 Apache 2.x::
 	Ensure mod_cgi, mod_alias, and mod_env are enabled, set
@@ -144,6 +144,35 @@ ScriptAliasMatch \
 ScriptAlias /git/ /var/www/cgi-bin/gitweb.cgi/
 ----------------------------------------------------------------
 
+In the following example, the repository at
+'/home/$username/devel/foo/bar.git' will be accessible at
+'http://$hostname/~$username/cgi-bin/git/foo/bar.git'.
+
+From UserDir on Apache 2.x::
+       One way to configure 'git-http-backend' to execute and serve
+       from a user directory (for example, on a shared hosting
+       provider), is to have a symbolic link named 'git' that points
+       from the cgi directory to the 'git-http-backend' executable in
+       libexec.  The advantage is that this symbolic link always
+       points to the latest installed version; one does not have to
+       make any changes to the symbolic link when the installed
+       'git-http-backend' is updated.
++
+----------------------------------------------------------------
+SetHandler cgi-script
+SetEnv GIT_PROJECT_ROOT /home/$username/devel
+----------------------------------------------------------------
++
+Also add any needed authentication to the .htaccess file as discussed
+in earlier examples.
++
+Depending on the global configuration of the web server, the
+"FollowSymLinks" or "SymLinksIfOwnerMatch" options might be needed.
+If the web server does not follow any symbolic links, the
+'git-http-backend' executable may be copied into the cgi-bin directory
+and renamed to 'git' to acheive the same effect, but it will also need
+to be manually updated whenever a new version of 'git-http-backend' is
+installed.
 
 ENVIRONMENT
 -----------
Signature · 1 line
1.6.6
#12 lore raw

Documentation/git-http-backend.txt ScriptAliasMatch \ · line 175

Quoted 7 lines · Tarmigan Casebolt
Documentation/git-http-backend.txt +7 -0
+Depending on the global configuration of the web server, the
+"FollowSymLinks" or "SymLinksIfOwnerMatch" options might be needed.
+If the web server does not follow any symbolic links, the
+'git-http-backend' executable may be copied into the cgi-bin directory
+and renamed to 'git' to acheive the same effect, but it will also need
+to be manually updated whenever a new version of 'git-http-backend' is
+installed.

Hmph, has Apache heard of hardlinks? If not, wouldn't this be much simpler?

cat >git <<\EOF
#!/bin/sh
exec /path/to/libexec/git-core/git-http-backend "$@" EOF
chmod +x git