Commit 849d8fdc authored by GitLab's avatar GitLab

Enable git-annex validate access

parent 60ea5770
...@@ -238,4 +238,9 @@ class GitlabProjects ...@@ -238,4 +238,9 @@ class GitlabProjects
$logger.info "Update head in project #{project_name} to <#{new_head}>." $logger.info "Update head in project #{project_name} to <#{new_head}>."
true true
end end
def git_init_annex
cmd = %W(git --git-dir=#{full_path} annex init "GitLab")
system(*cmd)
end
end end
...@@ -20,12 +20,11 @@ class GitlabShell ...@@ -20,12 +20,11 @@ class GitlabShell
if git_cmds.include?(@git_cmd) if git_cmds.include?(@git_cmd)
ENV['GL_ID'] = @key_id ENV['GL_ID'] = @key_id
ENV['HOME'] ='/var/opt/gitlab'
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# TODO: Fix validation for git-annex-shell !!!! # TODO: Fix validation for git-annex-shell !!!!
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if true #validate_access if validate_access
process_cmd process_cmd
else else
message = "gitlab-shell: Access denied for git command <#{@origin_cmd}> by #{log_username}." message = "gitlab-shell: Access denied for git command <#{@origin_cmd}> by #{log_username}."
...@@ -60,7 +59,7 @@ class GitlabShell ...@@ -60,7 +59,7 @@ class GitlabShell
@git_cmd = args.first @git_cmd = args.first
if @git_cmd == 'git-annex-shell' if @git_cmd == 'git-annex-shell'
@repo_name = escape_path(args[2].gsub("\/~\/", '')) @repo_name = escape_path(args[2].gsub("\/~\/", ''))
else else
@repo_name = escape_path(args.last) @repo_name = escape_path(args.last)
end end
...@@ -73,10 +72,10 @@ class GitlabShell ...@@ -73,10 +72,10 @@ class GitlabShell
def process_cmd def process_cmd
repo_full_path = File.join(repos_path, repo_name) repo_full_path = File.join(repos_path, repo_name)
$logger.info "gitlab-shell: executing git command <#{@git_cmd} #{repo_full_path}> for #{log_username}." $logger.info "gitlab-shell: executing git command <#{@git_cmd} #{repo_full_path}> for #{log_username}."
if @git_cmd == 'git-annex-shell' if @git_cmd == 'git-annex-shell'
args = Shellwords.shellwords(@origin_cmd) args = Shellwords.shellwords(@origin_cmd)
parsed_args = parsed_args =
args.map do |arg| args.map do |arg|
if arg =~ /\A\/~\/.*\.git\Z/ if arg =~ /\A\/~\/.*\.git\Z/
repo_full_path repo_full_path
...@@ -86,7 +85,7 @@ class GitlabShell ...@@ -86,7 +85,7 @@ class GitlabShell
end end
exec_cmd(*parsed_args) exec_cmd(*parsed_args)
else else
exec_cmd(@git_cmd, repo_full_path) exec_cmd(@git_cmd, repo_full_path)
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment