]> git.ipfire.org Git - ipfire.org.git/blobdiff - source/dlhandler.py
Only let source code be downloaded by our own robot.
[ipfire.org.git] / source / dlhandler.py
index 14cc5b75504a45c90eb20e8a295fbbcf109b3bf1..cda2f8328e48a0e4bd4827ce7da3f8ca09948639 100644 (file)
@@ -23,12 +23,22 @@ import os
 import cgi
 from git import *
 
+def give_403():
+       print "Status: 403 Forbidden"
+       print "Pragma: no-cache"
+       print "Cache-control: no-cache"
+       print "Connection: close"
+       print
+       print
+       os._exit(0)
+
 def give_404():
        print "Status: 404 Not found"
        print "Pragma: no-cache"
        print "Cache-control: no-cache"
        print "Connection: close"
        print
+       print
        os._exit(0)
 
 def give_302():
@@ -155,13 +165,15 @@ class PatchObject(SourceObject):
 path = cgi.FieldStorage().getfirst('path')
 ver = cgi.FieldStorage().getfirst('ver')
 
+if not os.environ["HTTP_USER_AGENT"].startswith("IPFireSourceGrabber"):
+       give_403()
+
 if not path:
        give_302()
 
 if not ver:
        ver = "3.x"
 
-
 # At first, we assume that the requested object is a plain file:
 try:
        object = FileObject(path=path, version=ver)