Skip to content
This repository has been archived by the owner on Nov 24, 2022. It is now read-only.

Commit

Permalink
Merge pull request #435 from brandon-rhodes/fix-umask
Browse files Browse the repository at this point in the history
Avoid `Timed out` error when umask is 027 or 077
  • Loading branch information
Virgil Dupras committed Dec 12, 2017
2 parents e4c566e + 43aa9bf commit 8b93206
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions lib/vagrant-lxc/sudo_wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,24 @@ def initialize(wrapper_path = nil)

def run(*command)
options = command.last.is_a?(Hash) ? command.last : {}
if @wrapper_path && !options[:no_wrapper]
command.unshift @wrapper_path
execute *(['sudo'] + command)
else
execute *(['sudo', '/usr/bin/env'] + command)

# Avoid running LXC commands with a restrictive umask.
# Otherwise disasters occur, like the container root directory
# having permissions `rwxr-x---` which prevents the `vagrant`
# user from accessing its own home directory; among other
# problems, SSH cannot then read `authorized_keys`!
old_mask = File.umask
File.umask(old_mask & 022) # allow all `r` and `x` bits

begin
if @wrapper_path && !options[:no_wrapper]
command.unshift @wrapper_path
execute *(['sudo'] + command)
else
execute *(['sudo', '/usr/bin/env'] + command)
end
ensure
File.umask(old_mask)
end
end

Expand Down

0 comments on commit 8b93206

Please sign in to comment.