Skip to content

Commit

Permalink
Added :as option to sudo so you can specify who a command should be e…
Browse files Browse the repository at this point in the history
…xecuted as

git-svn-id: http://svn.rubyonrails.org/rails/tools/capistrano@5145 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
jamis committed Sep 18, 2006
1 parent d1d0c92 commit ff265a2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
@@ -1,3 +1,7 @@
*SVN*

* Added :as option to sudo, so you can specify who the command is executed as [Mark Imbriaco]

*1.2.0* (September 14, 2006)

* Add experimental 'shell' task [Jamis Buck]
Expand Down
5 changes: 3 additions & 2 deletions lib/capistrano/actor.rb
Expand Up @@ -277,9 +277,10 @@ def sudo(command, options={}, &block)
# in order to prevent _each host_ from prompting when the password was
# wrong, let's track which host prompted first and only allow subsequent
# prompts from that host.
prompt_host = nil
prompt_host = nil
user = options[:as].nil? ? '' : "-u #{options[:as]}"

run "#{sudo_command} #{command}", options do |ch, stream, out|
run "#{sudo_command} #{user} #{command}", options do |ch, stream, out|
if out =~ /^Password:/
ch.send_data "#{password}\n"
elsif out =~ /try again/
Expand Down

0 comments on commit ff265a2

Please sign in to comment.