Commit b5757b74 authored by Douwe Maan's avatar Douwe Maan

GitlabShell doesn't need to set GL_ID at all.

parent e8403e8b
...@@ -5,6 +5,9 @@ unless ENV['SSH_CONNECTION'] ...@@ -5,6 +5,9 @@ unless ENV['SSH_CONNECTION']
exit exit
end end
key_id = /key-[0-9]+/.match(ARGV.join).to_s
original_cmd = ENV['SSH_ORIGINAL_COMMAND']
require_relative '../lib/gitlab_init' require_relative '../lib/gitlab_init'
# #
...@@ -14,7 +17,7 @@ require_relative '../lib/gitlab_init' ...@@ -14,7 +17,7 @@ require_relative '../lib/gitlab_init'
# #
require File.join(ROOT_PATH, 'lib', 'gitlab_shell') require File.join(ROOT_PATH, 'lib', 'gitlab_shell')
if GitlabShell.new.exec if GitlabShell.new(key_id, original_cmd).exec
exit 0 exit 0
else else
exit 1 exit 1
......
...@@ -9,9 +9,9 @@ class GitlabShell ...@@ -9,9 +9,9 @@ class GitlabShell
attr_accessor :key_id, :repo_name, :git_cmd, :repos_path, :repo_name attr_accessor :key_id, :repo_name, :git_cmd, :repos_path, :repo_name
def initialize def initialize(key_id, origin_cmd)
@key_id = /key-[0-9]+/.match(ARGV.join).to_s @key_id = key_id
@origin_cmd = ENV['SSH_ORIGINAL_COMMAND'] @origin_cmd = origin_cmd
@config = GitlabConfig.new @config = GitlabConfig.new
@repos_path = @config.repos_path @repos_path = @config.repos_path
end end
...@@ -26,7 +26,6 @@ class GitlabShell ...@@ -26,7 +26,6 @@ class GitlabShell
raise DisallowedCommandError unless git_cmds.include?(@git_cmd) raise DisallowedCommandError unless git_cmds.include?(@git_cmd)
ENV['GL_ID'] = @key_id
status = api.check_access(@git_cmd, @repo_name, @key_id, '_any') status = api.check_access(@git_cmd, @repo_name, @key_id, '_any')
raise AccessDeniedError, status.message unless status.allowed? raise AccessDeniedError, status.message unless status.allowed?
...@@ -105,7 +104,7 @@ class GitlabShell ...@@ -105,7 +104,7 @@ class GitlabShell
# This method is not covered by Rspec because it ends the current Ruby process. # This method is not covered by Rspec because it ends the current Ruby process.
def exec_cmd(*args) def exec_cmd(*args)
Kernel::exec({ 'PATH' => ENV['PATH'], 'LD_LIBRARY_PATH' => ENV['LD_LIBRARY_PATH'], 'GL_ID' => ENV['GL_ID'] }, *args, unsetenv_others: true) Kernel::exec({ 'PATH' => ENV['PATH'], 'LD_LIBRARY_PATH' => ENV['LD_LIBRARY_PATH'], 'GL_ID' => @key_id }, *args, unsetenv_others: true)
end end
def api def api
......
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