Skip to content

Commit

Permalink
host and user handlers use sudo when not root
Browse files Browse the repository at this point in the history
  • Loading branch information
delano committed Jun 28, 2010
1 parent 33397bc commit 53bbdcd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
6 changes: 3 additions & 3 deletions lib/rudy/routines/handlers/disks.rb
Expand Up @@ -189,7 +189,7 @@ def mount(rbox, disk, index)

li "Mounting at #{disk.path}... "

if rbox.user.to_s == 'root'
if rbox.root?
rbox.mkdir(:p, disk.path)
rbox.mount(:t, disk.fstype, disk.device, disk.path)
else
Expand Down Expand Up @@ -217,7 +217,7 @@ def umount(rbox, disk, index)
li "Unmounting #{disk.path}... "

unless rbox.nil? || rbox.stash.windows?
if rbox.user.to_s == 'root'
if rbox.root?
rbox.umount(disk.path)
else
rbox.sudo :umount, disk.path
Expand Down Expand Up @@ -255,7 +255,7 @@ def format(rbox, disk, index)
else
li $/
args = [:t, disk.fstype, :F, disk.device]
if rbox.user.to_s == 'root'
if rbox.root?
rbox.rudy_mkfs *args
else
rbox.sudo 'mkfs', *args
Expand Down
6 changes: 1 addition & 5 deletions lib/rudy/routines/handlers/host.rb
Expand Up @@ -98,12 +98,8 @@ def set_hostname(rset)
rset.batch(type) do |hn|
unless self.stash.os == :windows
if hn != :default
original_user = rset.user
rset.switch_user 'root'
rset.add_key ::Rudy::Huxtable.user_keypairpath('root')
hn = self.stash.name if hn == :rudy
self.quietly { hostname(hn) }
rset.switch_user original_user
root? ? hostname(hn) : sudo(:hostname, hn)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rudy/routines/handlers/user.rb
Expand Up @@ -32,7 +32,7 @@ def adduser(user, robj)
# adduser can prompt for info which we don't want.
# useradd does not prompt (on Debian/Ubuntu at least).
# We need to specify bash b/c the default is /bin/sh
robj.useradd(args)
robj.root? ? robj.useradd(args) : robj.sudo( :useradd, args)
end

def authorize(user, robj)
Expand Down

0 comments on commit 53bbdcd

Please sign in to comment.