From d64ddc87558bc36d41593772e8399df05b89d5bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Bobot?= Date: Thu, 5 Sep 2013 15:10:51 +0200 Subject: Execute command directly without using shell use Shellwords.shellwords for splitting origin_cmd instead of .split(' ') --- lib/gitlab_shell.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/gitlab_shell.rb b/lib/gitlab_shell.rb index 01ef4a1..67ffb26 100644 --- a/lib/gitlab_shell.rb +++ b/lib/gitlab_shell.rb @@ -1,4 +1,5 @@ require 'open3' +require 'shellwords' require_relative 'gitlab_net' @@ -40,9 +41,9 @@ class GitlabShell protected def parse_cmd - args = @origin_cmd.split(' ') - @git_cmd = args.shift - @repo_name = args.shift + args = Shellwords.shellwords(@origin_cmd) + @git_cmd = args[0] + @repo_name = args[1] end def git_cmds @@ -51,17 +52,16 @@ class GitlabShell def process_cmd repo_full_path = File.join(repos_path, repo_name) - cmd = "#{@git_cmd} #{repo_full_path}" - $logger.info "gitlab-shell: executing git command <#{cmd}> for #{log_username}." - exec_cmd(cmd) + $logger.info "gitlab-shell: executing git command <#{@git_cmd} #{repo_full_path}> for #{log_username}." + exec_cmd(@git_cmd,repo_full_path) end def validate_access api.allowed?(@git_cmd, @repo_name, @key_id, '_any') end - def exec_cmd args - Kernel::exec args + def exec_cmd *args + Kernel::exec *args end def api -- cgit v1.2.1