Permalink
Browse files

Have gitwrap support multiple top-level repositories.

Still no support for explicit permissions checking, though, and that's
by design to keep things simple.
  • Loading branch information...
1 parent ad8d6c4 commit 6667771f886748e52a3bbbe259fa3d87b1ba1609 @mhagander committed Sep 3, 2010
Showing with 12 additions and 5 deletions.
  1. +3 −1 README.rst
  2. +9 −4 gitwrap.py
View
@@ -129,7 +129,7 @@ a file called ``gitwrap.ini`` with contents like this: ::
[paths]
logfile=/some/where/gitwrap.log
- gitrepo=/some/where/repository.git
+ repobase=/some/where
Make sure the git user has permissions on these directories.
@@ -140,6 +140,8 @@ for the git user: ::
One row for each committer.
+The script will only allow access to repositories in the top level directory, and only
+those that already exist. All users will be granted access to all repositories.
anonymous mirror push script
============================
View
@@ -14,7 +14,7 @@
#
# [paths]
# logfile=/some/where/gitwrap.log
-# gitrepo=/some/where/repository.git
+# repobase=/some/where/
#
import sys
@@ -50,7 +50,7 @@ class PgGit(object):
def __init__(self, cfg):
self.cfg = cfg
self.logger = Logger(cfg)
- self.path = "%s" % cfg.get('paths', 'gitrepo')
+ self.repobase = cfg.get('paths', 'repobase')
def parse_commandline(self):
if len(sys.argv) != 2:
@@ -75,8 +75,13 @@ def parse_command(self):
if not args.startswith("'/"):
raise InternalException("Expected git path to start with slash!")
- if not self.path.endswith(args[2:].rstrip("'")):
- raise InternalException("Incorrect repository path")
+ self.path = os.path.normpath("%s/%s" % (self.repobase, args[2:].rstrip("'")))
+ if not self.path.startswith(self.repobase):
+ raise InternalException("Attempt to escape root directory")
+ if not self.path.endswith(".git"):
+ raise InternalException("Repository paths must end in .git")
+ if not os.path.isdir(self.path):
+ raise InternalException("Repository does not exist")
def run_command(self):
self.logger.log("Running \"git shell %s %s\"" % (self.command, "'%s'" % self.path))

0 comments on commit 6667771

Please sign in to comment.