From 7818abd6a89a882cabb3d2a14a572308d9e959ff Mon Sep 17 00:00:00 2001 From: elijah Date: Tue, 21 Jun 2016 17:38:00 -0700 Subject: minor ruby linting --- lib/leap_cli/macros/haproxy.rb | 2 +- lib/leap_cli/macros/keys.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/leap_cli/macros') diff --git a/lib/leap_cli/macros/haproxy.rb b/lib/leap_cli/macros/haproxy.rb index 602ae726..3fef24c4 100644 --- a/lib/leap_cli/macros/haproxy.rb +++ b/lib/leap_cli/macros/haproxy.rb @@ -26,7 +26,7 @@ module LeapCli # create a simple map for node name -> local stunnel accept port accept_ports = stunnel_clients.inject({}) do |hsh, stunnel_entry| - name = stunnel_entry.first.sub /_[0-9]+$/, '' + name = stunnel_entry.first.sub(/_[0-9]+$/, '') hsh[name] = stunnel_entry.last['accept_port'] hsh end diff --git a/lib/leap_cli/macros/keys.rb b/lib/leap_cli/macros/keys.rb index e7a75cfb..9dd9b34f 100644 --- a/lib/leap_cli/macros/keys.rb +++ b/lib/leap_cli/macros/keys.rb @@ -56,7 +56,7 @@ module LeapCli require 'base64' require 'openssl' path = Path.find_file([path_name, self.name]) - if path && File.exists?(path) + if path && File.exist?(path) public_key_str = File.readlines(path).grep(/^[^-]/).join public_key = Base64.decode64(public_key_str) public_key = public_key.slice(22..-1) # Tor ignores the 22 byte SPKI header -- cgit v1.2.3 From 2d6bfce47b3f50d2b058b938ad9b42a7cd2e3142 Mon Sep 17 00:00:00 2001 From: elijah Date: Wed, 20 Jul 2016 12:22:31 -0700 Subject: minor (improve readability of deploy message by showing correct rsync paths) --- lib/leap_cli/macros/files.rb | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'lib/leap_cli/macros') diff --git a/lib/leap_cli/macros/files.rb b/lib/leap_cli/macros/files.rb index 04c94edf..602fdddb 100644 --- a/lib/leap_cli/macros/files.rb +++ b/lib/leap_cli/macros/files.rb @@ -79,19 +79,26 @@ module LeapCli # # file_path(:dkim_priv_key) {generate_dkim_key} # - # notes: + # Notes: # - # * argument 'path' is relative to Path.provider/files or - # Path.provider_base/files - # * the path returned by this method is absolute - # * the path stored for use later by rsync is relative to Path.provider - # * if the path does not exist locally, but exists in provider_base, + # * Argument 'path' must be relative to Path.provider/files or + # Path.provider_base/files. It is OK for the path to be prefixed with + # with 'files/', this prefix will be ignored. + # + # * The path returned by this method is an absolute path on the server. + # + # * The path stored for use later by rsync is relative to the local + # Path.provider. It should always be prefixed with 'files/' + # + # * If the path does not exist locally, but exists in provider_base, # then the default file from provider_base is copied locally. this # is required for rsync to work correctly. # + # NOTE: this is an aweful way to do this. It would be better + # to rsync twice. + # def remote_file_path(path, options={}, &block) local_path = local_file_path(path, options, &block) - return nil if local_path.nil? # if file is under Path.provider_base, we must copy the default file to @@ -110,9 +117,11 @@ module LeapCli end relative_path = Path.relative_path(local_path) - relative_path.sub!(/^files\//, '') # remove "files/" prefix @node.file_paths << relative_path - return File.join(Leap::Platform.files_dir, relative_path) + return File.join( + Leap::Platform.files_dir, + relative_path.sub(/^files\//, '') + ) end # deprecated -- cgit v1.2.3 From ad9415a5e2885e940e99a07a9d6cdb2b1600e1bd Mon Sep 17 00:00:00 2001 From: elijah Date: Tue, 4 Oct 2016 11:06:13 -0700 Subject: [bug] fix Tor hidden service key generation --- lib/leap_cli/macros/keys.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib/leap_cli/macros') diff --git a/lib/leap_cli/macros/keys.rb b/lib/leap_cli/macros/keys.rb index 9dd9b34f..9cc01fe7 100644 --- a/lib/leap_cli/macros/keys.rb +++ b/lib/leap_cli/macros/keys.rb @@ -29,7 +29,7 @@ module LeapCli # generating key if it is missing # def tor_public_key_path(path_name, key_type) - file_path(path_name) { generate_tor_key(key_type) } + remote_file_path(path_name) { generate_tor_key(key_type) } end # @@ -37,7 +37,7 @@ module LeapCli # generating key if it is missing # def tor_private_key_path(path_name, key_type) - file_path(path_name) { generate_tor_key(key_type) } + remote_file_path(path_name) { generate_tor_key(key_type) } end # @@ -55,7 +55,7 @@ module LeapCli require 'base32' require 'base64' require 'openssl' - path = Path.find_file([path_name, self.name]) + path = Path.named_path([path_name, self.name]) if path && File.exist?(path) public_key_str = File.readlines(path).grep(/^[^-]/).join public_key = Base64.decode64(public_key_str) @@ -63,7 +63,7 @@ module LeapCli sha1sum = Digest::SHA1.new.digest(public_key) Base32.encode(sha1sum.slice(0,10)).downcase else - LeapCli.log :warning, 'Tor public key file "%s" does not exist' % tor_public_key_path + LeapCli.log :warning, 'Tor public key file "%s" does not exist' % path end end -- cgit v1.2.3