]> gitweb.fluxo.info Git - leap/leap_cli.git/commitdiff
make typed passwords invisible again (use --echo to make them visible)
authorelijah <elijah@riseup.net>
Mon, 29 Oct 2012 20:17:34 +0000 (13:17 -0700)
committerelijah <elijah@riseup.net>
Mon, 29 Oct 2012 20:17:34 +0000 (13:17 -0700)
lib/leap_cli/commands/node.rb
lib/leap_cli/commands/util.rb

index b9640a8ca2749dce6bd42ff7eeece1d53ce5c5cd..57c826e128dc6561acc0d1ac12cbe79e62058842 100644 (file)
@@ -16,12 +16,13 @@ module LeapCli; module Commands
   desc 'Bootstraps a node, setting up ssh keys and installing prerequisites'
   arg_name '<node-name>', :optional => false, :multiple => false
   command :'init-node' do |c|
+    c.switch 'echo', :desc => 'if set, passwords are visible as you type them (default is hidden)', :negatable => false
     c.action do |global_options,options,args|
       node = get_node_from_args(args)
       ping_node(node)
       save_public_host_key(node)
       update_compiled_ssh_configs
-      ssh_connect(node, :bootstrap => true) do |ssh|
+      ssh_connect(node, :bootstrap => true, :echo => options[:echo]) do |ssh|
         ssh.install_authorized_keys
         ssh.install_prerequisites
       end
index aa888e04efa2bf280154ec1448bcdc20a6a85742..d9e69232d54ce8073d087061d8de674bc80bdc06 100644 (file)
@@ -67,8 +67,13 @@ module LeapCli; module Commands
     #
     if options[:bootstrap] && node_list.size == 1
       hostname = node_list.values.first.name
-      cap.set(:password) { ask("SSH password for #{user}@#{hostname}> ") } # only called if needed
-      # this can be used instead to hide echo -- Capistrano::CLI.password_prompt
+
+      # the 'password' block is only called if key auth fails
+      if options[:echo]
+        cap.set(:password) { ask "Root SSH password for #{user}@#{hostname}> " }
+      else
+        cap.set(:password) { Capistrano::CLI.password_prompt " * Typed password will be hidden (use --echo to make it visible)\nRoot SSH password for #{user}@#{hostname}> " }
+      end
     end
 
     node_list.each do |name, node|
@@ -98,9 +103,9 @@ module LeapCli; module Commands
   # http://railsware.com/blog/2011/11/02/advanced-server-definitions-in-capistrano/
   #
   def node_options(node)
-    password_proc = Proc.new {Capistrano::CLI.password_prompt "Root SSH password for #{node.name}"}  # only called if needed
+    #password_proc = Proc.new {Capistrano::CLI.password_prompt "Root SSH password for #{node.name}"}  # only called if needed
     {
-      :password => password_proc,
+      #:password => password_proc,
       :ssh_options => {
         :host_key_alias => node.name,
         :host_name => node.ip_address,
@@ -113,7 +118,7 @@ module LeapCli; module Commands
     # load once the library files
     @capistrano_enabled ||= begin
       require 'capistrano'
-      #require 'capistrano/cli'
+      require 'capistrano/cli'
       require 'leap_cli/remote/plugin'
       Capistrano.plugin :leap, LeapCli::Remote::Plugin
       true