diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-10-31 06:23:32 -0700 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-10-31 06:23:32 -0700 |
commit | db79c32e62c9db69e63154d0abced6b8bac56c3d (patch) | |
tree | 5620ce96dbc43ed2a6b04207a8fb01a25c29b83b /lib/gitlab_shell.rb | |
parent | be2f82b0af3c9aea1bac1e27217acbf77b4c88aa (diff) | |
parent | d64ddc87558bc36d41593772e8399df05b89d5bf (diff) | |
download | gitlab-shell-db79c32e62c9db69e63154d0abced6b8bac56c3d.tar.gz |
Merge pull request #87 from bobot/master
Execute command directly without using shell
Diffstat (limited to 'lib/gitlab_shell.rb')
-rw-r--r-- | lib/gitlab_shell.rb | 16 |
1 files changed, 8 insertions, 8 deletions
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 |