Sophie

Sophie

distrib > Fedora > 14 > x86_64 > media > updates > by-pkgid > ba9fe7781d529b2e7b31d8489f5e0b8e > files > 29

gitolite-1.5.3-2.fc14.noarch.rpm

<h1>avoiding the shell on the server</h1>

<p>Gitolite now tries to prevent gitolite-admin push privileges from being used
to obtain a shell on the server.  This was not always the case (older gitolite
did not make this distinction), but I've been moving towards this for a while
now, and, while there could still be holes in that separation, they will be
fixed as and when found.</p>

<p>Thus, settings that have security implications can be set only from the rc
file, which needs to be edited directly on the server.  And adding a new hook
requires adding it to the <em>gitolite</em> clone and running easy install again, or
gl-setup, if you used the server-side install method, both of which require
shell access.</p>

<p>While this is great for my main target (corporate environments), some people
don't like it.  They want to do all of this from the <em>gitolite-admin</em> repo,
because the security concern mentioned above does not bother them.  They don't
want to log on to the server to make a change in the rc file or don't want to
run easy install to propagate a new set of hooks.  In addition, they may want
all of these animals versioned in the "gitolite-admin" repo itself, which
certainly makes sense.</p>

<p>So here's how you might do that.</p>

<p>First, arrange to have all your special files added to the gitolite-admin
repo.  The best option is to keep all of this in a single subdirectory (let's
call it "local" in our example).  So your <code>~/.gitolite.rc</code> might go into
<code>local/gitolite.rc</code>, and all your local hooks into <code>local/hooks</code> etc.  Add
them, commit, and push.</p>

<p>Note: do not create any top level directory called "conf", "contrib", "doc",
"hooks", or "src" -- those names are used by gitolite itself.</p>

<p>Second, create a <code>post-update.secondary</code> hook and place it in the <em>gitolite</em>
clone's <code>hooks/common</code> directory, containing the following code:</p>

<pre><code>#!/bin/bash

GL_ADMINDIR=` cd;perl -e 'do ".gitolite.rc"; print $GL_ADMINDIR'`

cp    $GL_ADMINDIR/local/gitolite.rc    $HOME/.gitolite.rc
cp -a $GL_ADMINDIR/local/hooks/*        $GL_ADMINDIR/hooks/common
$HOME/gitolite-install/src/gl-install -q
</code></pre>

<p>Now run easy-install (or gl-setup) once, and you're done.</p>

<p>All future changes to the rc file can be done via local/gitolite.rc in the
admin repo, and hooks can be added to local/hooks.</p>

<p><strong>Warning</strong>: Nothing in gitolite <em>removes</em> hooks, so if you delete (or even
rename) a script, it still stays on the server -- you'll have to delete them
manually from the server.</p>

<hr />

<p>So what's this actually doing?</p>

<p>Well, first, note that <code>$GL_ADMINDIR</code> contains files from both gitolite
itself, as well as from the gitolite-admin repo.  "conf/VERSION", "src",
"doc", and "hooks" come from gitolite itself, while the other 2 files in
"conf", and all of "keydir" come from the gitolite-admin repo.  ("logs"
doesn't come from anywhere).</p>

<p>In addition, any other files in the "master" branch of the gitolite-admin repo
get checked out here, which in this case would mean the entire "local/"
hierarchy you created above.</p>

<p>Now, since the "hooks/common" directory is coming from gitolite itself,
clearly this is where the internal "install" routine expects to find new or
updated hooks to propagate.  So you just copy your local hooks (in the
"local/hooks" directory) to "hooks/common" and run the installer again.  Done!</p>