Generate .htaccess files to prevent access to repositories that
authorMagnus Hagander <magnus@hagander.net>
Wed, 31 Dec 2008 16:11:36 +0000 (17:11 +0100)
committerMagnus Hagander <magnus@hagander.net>
Wed, 31 Dec 2008 16:11:36 +0000 (17:11 +0100)
don't have the anonymous flag set.

gitdump.py

index f5f6965dbb7808db38e116730e5127731bbc77e5..14f9f4e1d3bf2f18d88a0d3f8f6b06b37254673d 100644 (file)
@@ -59,12 +59,20 @@ class AuthorizedKeysDumper:
                                df.close()
 
                        anonfile = "%s/repos/%s/git-daemon-export-ok" % (self.conf.get("paths", "githome"), name)
+                       htafile = "%s/repos/%s/.htaccess" % (self.conf.get("paths", "githome"), name)
                        if anon:
                                if not os.path.isfile(anonfile):
                                        open(anonfile, "w").close()
+                               if os.path.isfile(htafile):
+                                       os.remove(htafile)
                        else:
                                if os.path.isfile(anonfile):
                                        os.remove(anonfile)
+                               if not os.path.isfile(htafile):
+                                       hf = open(htafile, "w")
+                                       hf.write("order allow,deny\ndeny from all\noptions -indexes\n")
+                                       hf.close()
+
                f.close()
                os.chmod("%s.tmp" % self.conf.get("paths", "gitweblist"), 0644)
                os.rename("%s.tmp" % self.conf.get("paths", "gitweblist"), self.conf.get("paths", "gitweblist"))