Commit 2a3b15ee authored by ash's avatar ash

Add log messages for gitlab_keys.

parent e5f4130a
require 'open3' require 'open3'
require_relative 'gitlab_config' require_relative 'gitlab_config'
require_relative 'gitlab_logger'
class GitlabKeys class GitlabKeys
attr_accessor :auth_file, :key attr_accessor :auth_file, :key
...@@ -17,6 +18,7 @@ class GitlabKeys ...@@ -17,6 +18,7 @@ class GitlabKeys
when 'add-key'; add_key when 'add-key'; add_key
when 'rm-key'; rm_key when 'rm-key'; rm_key
else else
$logger.error "Attempt to execute invalid command #{@command.inspect}."
puts 'not allowed' puts 'not allowed'
false false
end end
...@@ -25,12 +27,14 @@ class GitlabKeys ...@@ -25,12 +27,14 @@ class GitlabKeys
protected protected
def add_key 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 = "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}" cmd = "echo \'#{cmd}\' >> #{auth_file}"
system(cmd) system(cmd)
end end
def rm_key def rm_key
$logger.info "Removing key #{@key_id}"
cmd = "sed -i '/shell #{@key_id}\"/d' #{auth_file}" cmd = "sed -i '/shell #{@key_id}\"/d' #{auth_file}"
system(cmd) system(cmd)
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment