summaryrefslogtreecommitdiff
path: root/lib/gitlab_keys.rb
diff options
context:
space:
mode:
authorash <smashwilson@gmail.com>2013-05-16 23:31:00 +0000
committerash <smashwilson@gmail.com>2013-05-17 00:33:10 +0000
commit2a3b15ee6d98bd2888028f2b92408217edb38e99 (patch)
tree9ae0ef9e369bf7d395756ffdd5c1414d966086f8 /lib/gitlab_keys.rb
parente5f4130aeaeb6ba16d42032c8e574c147ca9d51d (diff)
downloadgitlab-shell-2a3b15ee6d98bd2888028f2b92408217edb38e99.tar.gz
Add log messages for gitlab_keys.
Diffstat (limited to 'lib/gitlab_keys.rb')
-rw-r--r--lib/gitlab_keys.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/gitlab_keys.rb b/lib/gitlab_keys.rb
index 7e6362a..b64cbde 100644
--- a/lib/gitlab_keys.rb
+++ b/lib/gitlab_keys.rb
@@ -1,6 +1,7 @@
require 'open3'
require_relative 'gitlab_config'
+require_relative 'gitlab_logger'
class GitlabKeys
attr_accessor :auth_file, :key
@@ -17,6 +18,7 @@ class GitlabKeys
when 'add-key'; add_key
when 'rm-key'; rm_key
else
+ $logger.error "Attempt to execute invalid command #{@command.inspect}."
puts 'not allowed'
false
end
@@ -25,12 +27,14 @@ class GitlabKeys
protected
def add_key
+ $logger.info "Adding key #{@key_id} => #{@key.inspect}"
cmd = "command=\"#{ROOT_PATH}/bin/gitlab-shell #{@key_id}\",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty #{@key}"
cmd = "echo \'#{cmd}\' >> #{auth_file}"
system(cmd)
end
def rm_key
+ $logger.info "Removing key #{@key_id}"
cmd = "sed -i '/shell #{@key_id}\"/d' #{auth_file}"
system(cmd)
end