diff options
Diffstat (limited to 'lib/gitlab_shell.rb')
-rw-r--r-- | lib/gitlab_shell.rb | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/gitlab_shell.rb b/lib/gitlab_shell.rb index d075048..c26318a 100644 --- a/lib/gitlab_shell.rb +++ b/lib/gitlab_shell.rb @@ -9,9 +9,9 @@ class GitlabShell attr_accessor :key_id, :repo_name, :git_cmd, :repos_path, :repo_name - def initialize - @key_id = /key-[0-9]+/.match(ARGV.join).to_s - @origin_cmd = ENV['SSH_ORIGINAL_COMMAND'] + def initialize(key_id, origin_cmd) + @key_id = key_id + @origin_cmd = origin_cmd @config = GitlabConfig.new @repos_path = @config.repos_path end @@ -26,7 +26,6 @@ class GitlabShell raise DisallowedCommandError unless git_cmds.include?(@git_cmd) - ENV['GL_ID'] = @key_id status = api.check_access(@git_cmd, @repo_name, @key_id, '_any') raise AccessDeniedError, status.message unless status.allowed? @@ -105,7 +104,7 @@ class GitlabShell # This method is not covered by Rspec because it ends the current Ruby process. 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 def api |