Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 7696

Show
Ignore:
Timestamp:
09/30/07 15:23:17 (9 months ago)
Author:
minam
Message:

Fix cap shell to properly recognize sudo prompt (closes #9637)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • tools/capistrano/CHANGELOG

    r7695 r7696  
    11*SVN* 
     2 
     3* Fix cap shell to properly recognize sudo prompt [Mark Imbriaco, barnaby, Jamis Buck] 
    24 
    35* Git SCM module [Garry Dolley, Geoffrey Grosenbach, Scott Chacon] 
  • tools/capistrano/lib/capistrano/configuration/actions/invocation.rb

    r7392 r7696  
    125125        end 
    126126 
    127         private 
    128  
    129           # Returns the prompt text to use with sudo 
    130           def sudo_prompt 
    131             fetch(:sudo_prompt, "sudo password: ") 
    132           end 
     127        # Returns the prompt text to use with sudo 
     128        def sudo_prompt 
     129          fetch(:sudo_prompt, "sudo password: ") 
     130        end 
    133131      end 
    134132    end 
  • tools/capistrano/lib/capistrano/shell.rb

    r7205 r7696  
    167167      # Execute a command on the given list of servers. 
    168168      def exec_command(command, servers) 
    169         processor = Proc.new do |ch, stream, out| 
    170           # TODO: more robust prompt detection 
    171           out.each do |line| 
    172             if stream == :out 
    173               if out =~ /Password:\s*/i 
    174                 ch.send_data "#{configuration[:password]}\n" 
    175               else 
    176                 puts "[#{ch[:server]}] #{line.chomp}" 
    177               end 
    178             elsif stream == :err 
    179               puts "[#{ch[:server]} ERR] #{line.chomp}" 
    180             end 
    181           end 
    182         end 
    183  
     169        command = command.gsub(/\bsudo\b/, "sudo -p '#{configuration.sudo_prompt}'") 
     170        processor = configuration.sudo_behavior_callback(Configuration.default_io_proc) 
     171        sessions = servers.map { |server| configuration.sessions[server] } 
     172        cmd = Command.new(command, sessions, :logger => configuration.logger, &processor) 
    184173        previous = trap("INT") { cmd.stop! } 
    185         sessions = servers.map { |server| configuration.sessions[server] } 
    186         Command.process(command, sessions, :logger => configuration.logger, &Capistrano::Configuration.default_io_proc) 
     174        cmd.process! 
    187175      rescue Capistrano::Error => error 
    188176        warn "error: #{error.message}"