Commit d9a4e805f7f080a37e9c1ef0d2bb304769b75fb7
- Date: Fri Apr 18 22:23:15 +0000 2008
- Committer: Johan Sørensen (johan@johansorensen.com)
- Author: Johan Sørensen (johan@johansorensen.com)
- Commit SHA1: d9a4e805f7f080a37e9c1ef0d2bb304769b75fb7
- Tree SHA1: 6971e1b8ba95a3c0f446bcbf461831ba49320e81
only allow git-upload-pack the the command
Commit diff
| |   |
| 10 | 10 | require File.dirname(__FILE__)+'/../config/environment' |
| 11 | 11 | |
| 12 | 12 | Rails.configuration.log_level = :info # Disable debug |
| 13 | | ActiveRecord::Base.logger = nil |
| 14 | 13 | ActiveRecord::Base.allow_concurrency = true |
| 15 | | ActiveRecord::Base.clear_active_connections! |
| 16 | 14 | |
| 17 | 15 | BASE_PATH = File.expand_path(GitoriousConfig['repository_base_path']) |
| 18 | 16 | |
| 17 | TIMEOUT = 30 |
| 19 | 18 | MAX_CHILDREN = 30 |
| 20 | 19 | $children_reaped = 0 |
| 21 | 20 | $children_active = 0 |
| … | … | |
| 23 | 23 | class Daemon |
| 24 | 24 | include Daemonize |
| 25 | 25 | |
| 26 | | SERVICE_REGEXP = /(\w{4})(git-[\w-]+)\s(.+)\x0host=([\w\.\-]+)/.freeze |
| 26 | SERVICE_REGEXP = /(\w{4})(git\-upload\-pack)\s(.+)\x0host=([\w\.\-]+)/.freeze |
| 27 | 27 | |
| 28 | 28 | def initialize(options) |
| 29 | 29 | @options = options |
| … | … | |
| 56 | 56 | $children_active += 1 |
| 57 | 57 | |
| 58 | 58 | line = session.recv(1000) |
| 59 | | timeout = 30 |
| 59 | |
| 60 | 60 | if line =~ SERVICE_REGEXP |
| 61 | 61 | code = $1 |
| 62 | 62 | service = $2 |
| … | … | |
| 78 | 78 | end |
| 79 | 79 | |
| 80 | 80 | Dir.chdir(path) do |
| 81 | | cmd = "git-upload-pack --strict --timeout=#{timeout} ." |
| 81 | cmd = "git-upload-pack --strict --timeout=#{TIMEOUT} ." |
| 82 | 82 | |
| 83 | 83 | fork do |
| 84 | 84 | repository = nil |
| … | … | |
| 107 | 107 | else |
| 108 | 108 | log(pid, "Cannot find repository: #{path}") |
| 109 | 109 | end |
| 110 | | |
| 110 | |
| 111 | 111 | exec(cmd) |
| 112 | # FIXME; we don't ever get here since we exec(), so reaped count may be incorrect |
| 112 | 113 | $children_reaped += 1 |
| 113 | 114 | exit! |
| 114 | 115 | end |
| toggle raw diff |
--- a/script/git-daemon
+++ b/script/git-daemon
@@ -10,12 +10,11 @@ ENV["RAILS_ENV"] ||= "production"
require File.dirname(__FILE__)+'/../config/environment'
Rails.configuration.log_level = :info # Disable debug
-ActiveRecord::Base.logger = nil
ActiveRecord::Base.allow_concurrency = true
-ActiveRecord::Base.clear_active_connections!
BASE_PATH = File.expand_path(GitoriousConfig['repository_base_path'])
+TIMEOUT = 30
MAX_CHILDREN = 30
$children_reaped = 0
$children_active = 0
@@ -24,7 +23,7 @@ module Git
class Daemon
include Daemonize
- SERVICE_REGEXP = /(\w{4})(git-[\w-]+)\s(.+)\x0host=([\w\.\-]+)/.freeze
+ SERVICE_REGEXP = /(\w{4})(git\-upload\-pack)\s(.+)\x0host=([\w\.\-]+)/.freeze
def initialize(options)
@options = options
@@ -57,7 +56,7 @@ module Git
$children_active += 1
line = session.recv(1000)
- timeout = 30
+
if line =~ SERVICE_REGEXP
code = $1
service = $2
@@ -79,7 +78,7 @@ module Git
end
Dir.chdir(path) do
- cmd = "git-upload-pack --strict --timeout=#{timeout} ."
+ cmd = "git-upload-pack --strict --timeout=#{TIMEOUT} ."
fork do
repository = nil
@@ -108,8 +107,9 @@ module Git
else
log(pid, "Cannot find repository: #{path}")
end
-
+
exec(cmd)
+ # FIXME; we don't ever get here since we exec(), so reaped count may be incorrect
$children_reaped += 1
exit!
end |