34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/giticious/cli/main.rb', line 34
def gitserve(user)
abort unless user
abort if ENV["SSH_ORIGINAL_COMMAND"].nil?
command_match = ENV["SSH_ORIGINAL_COMMAND"].match(/(git\-upload\-pack|git\-receive\-pack) \'([A-Za-z0-9\-_\.]+)\.git\'/)
abort "Project not found / Command invalid" if command_match.nil?
action = command_match[1]
repo = command_match[2]
perms = Giticious::Service::Repository.new.permissions_for(repo, user)
abort "You have no access to #{repo}" if perms == false
command = "#{command_match[1]} 'repositories/#{command_match[2]}.git'"
abort "Read access denied" unless perms.perm_read
if action == "git-receive-pack"
abort "Write access denied" unless perms.perm_write
end
Kernel.exec "git", "shell", "-c", command
end
|