mirror of
https://github.com/capistrano/capistrano
synced 2023-03-27 23:21:18 -04:00
Fix cap shell to properly recognize sudo prompt (closes #9637)
git-svn-id: http://svn.rubyonrails.org/rails/tools/capistrano@7696 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
3a2df2deb9
commit
78c801dc74
3 changed files with 11 additions and 23 deletions
|
@ -1,5 +1,7 @@
|
||||||
*SVN*
|
*SVN*
|
||||||
|
|
||||||
|
* Fix cap shell to properly recognize sudo prompt [Mark Imbriaco, barnaby, Jamis Buck]
|
||||||
|
|
||||||
* Git SCM module [Garry Dolley, Geoffrey Grosenbach, Scott Chacon]
|
* Git SCM module [Garry Dolley, Geoffrey Grosenbach, Scott Chacon]
|
||||||
|
|
||||||
* Use the --password switch for subversion by default, but add :scm_prefer_prompt variable (defaults to false) [Jamis Buck]
|
* Use the --password switch for subversion by default, but add :scm_prefer_prompt variable (defaults to false) [Jamis Buck]
|
||||||
|
|
|
@ -124,8 +124,6 @@ module Capistrano
|
||||||
options
|
options
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
# Returns the prompt text to use with sudo
|
# Returns the prompt text to use with sudo
|
||||||
def sudo_prompt
|
def sudo_prompt
|
||||||
fetch(:sudo_prompt, "sudo password: ")
|
fetch(:sudo_prompt, "sudo password: ")
|
||||||
|
|
|
@ -166,24 +166,12 @@ HELP
|
||||||
|
|
||||||
# Execute a command on the given list of servers.
|
# Execute a command on the given list of servers.
|
||||||
def exec_command(command, servers)
|
def exec_command(command, servers)
|
||||||
processor = Proc.new do |ch, stream, out|
|
command = command.gsub(/\bsudo\b/, "sudo -p '#{configuration.sudo_prompt}'")
|
||||||
# TODO: more robust prompt detection
|
processor = configuration.sudo_behavior_callback(Configuration.default_io_proc)
|
||||||
out.each do |line|
|
|
||||||
if stream == :out
|
|
||||||
if out =~ /Password:\s*/i
|
|
||||||
ch.send_data "#{configuration[:password]}\n"
|
|
||||||
else
|
|
||||||
puts "[#{ch[:server]}] #{line.chomp}"
|
|
||||||
end
|
|
||||||
elsif stream == :err
|
|
||||||
puts "[#{ch[:server]} ERR] #{line.chomp}"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
previous = trap("INT") { cmd.stop! }
|
|
||||||
sessions = servers.map { |server| configuration.sessions[server] }
|
sessions = servers.map { |server| configuration.sessions[server] }
|
||||||
Command.process(command, sessions, :logger => configuration.logger, &Capistrano::Configuration.default_io_proc)
|
cmd = Command.new(command, sessions, :logger => configuration.logger, &processor)
|
||||||
|
previous = trap("INT") { cmd.stop! }
|
||||||
|
cmd.process!
|
||||||
rescue Capistrano::Error => error
|
rescue Capistrano::Error => error
|
||||||
warn "error: #{error.message}"
|
warn "error: #{error.message}"
|
||||||
ensure
|
ensure
|
||||||
|
|
Loading…
Reference in a new issue