lib/shexy.rb in shexy-0.3 vs lib/shexy.rb in shexy-0.3.1

- old
+ new

@@ -31,11 +31,11 @@ # Shexy.copy_to 'test@test-host', '/home/rubiojr/my-uber-file', '/tmp/' # module Shexy - VERSION = '0.3' + VERSION = '0.3.1' [:user, :password, :key, :cmd, :host].each do |n| instance_eval %{ def #{n}; Thread.current[:shexy_#{n}]; end def #{n}=(v); Thread.current[:shexy_#{n}] = v; end @@ -240,14 +240,15 @@ def self.permit_root_login(value) value = value.to_s unless value =~ /^(yes|no|without-password)$/ raise ArgumentError.new "Argument should be yes|no|without-password" end + using_sudo = Shexy.sudo? - Shexy.use_sudo + Shexy.use_sudo unless Shexy.user == 'root' out, err = batch do script <<-EOH - sed -i 's/^#\?PermitRootLogin.*$/PermitRootLogin\ #{value}/' /etc/ssh/sshd_config + sed -i 's/^#\\?PermitRootLogin.*$/PermitRootLogin\\ #{value}/' /etc/ssh/sshd_config test -f /etc/init.d/ssh && /etc/init.d/ssh restart test -f /etc/init.d/sshd && /etc/init.d/sshd restart EOH end Shexy.use_sudo(false) unless using_sudo