summaryrefslogtreecommitdiff
path: root/lib/gitlab_shell.rb
diff options
context:
space:
mode:
authorFrançois Bobot <francois.bobot@cea.fr>2013-09-05 15:10:51 +0200
committerFrançois Bobot <francois.bobot@cea.fr>2013-09-16 11:00:19 +0200
commitd64ddc87558bc36d41593772e8399df05b89d5bf (patch)
treed92d5dfeea9b5125e8214f8c5e5d09a2ae48bafb /lib/gitlab_shell.rb
parent2c238b717e86069aca485fae7a733135970b56a2 (diff)
downloadgitlab-shell-d64ddc87558bc36d41593772e8399df05b89d5bf.tar.gz
Execute command directly without using shell
use Shellwords.shellwords for splitting origin_cmd instead of .split(' ')
Diffstat (limited to 'lib/gitlab_shell.rb')
-rw-r--r--lib/gitlab_shell.rb16
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