summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab_shell.rb11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/gitlab_shell.rb b/lib/gitlab_shell.rb
index 6edb748..b2ddcc8 100644
--- a/lib/gitlab_shell.rb
+++ b/lib/gitlab_shell.rb
@@ -3,6 +3,8 @@ require 'shellwords'
require_relative 'gitlab_net'
class GitlabShell
+ DisallowedCommandError = Class.new(StandardError)
+
attr_accessor :key_id, :repo_name, :git_cmd, :repos_path, :repo_name
def initialize
@@ -28,19 +30,22 @@ class GitlabShell
$stderr.puts "Access denied."
end
else
- message = "gitlab-shell: Attempt to execute disallowed command <#{@origin_cmd}> by #{log_username}."
- $logger.warn message
- puts 'Not allowed command'
+ raise DisallowedCommandError
end
else
puts "Welcome to GitLab, #{username}!"
end
+ rescue DisallowedCommandError => ex
+ message = "gitlab-shell: Attempt to execute disallowed command <#{@origin_cmd}> by #{log_username}."
+ $logger.warn message
+ puts 'Not allowed command'
end
protected
def parse_cmd
args = Shellwords.shellwords(@origin_cmd)
+ raise DisallowedCommandError unless args.count == 2
@git_cmd = args[0]
@repo_name = escape_path(args[1])
end