Merge pull request #435 from brandon-rhodes/fix-umask
Avoid `Timed out` error when umask is 027 or 077
This commit is contained in:
commit
8b93206c18
1 changed files with 18 additions and 5 deletions
|
@ -13,11 +13,24 @@ module Vagrant
|
||||||
|
|
||||||
def run(*command)
|
def run(*command)
|
||||||
options = command.last.is_a?(Hash) ? command.last : {}
|
options = command.last.is_a?(Hash) ? command.last : {}
|
||||||
if @wrapper_path && !options[:no_wrapper]
|
|
||||||
command.unshift @wrapper_path
|
# Avoid running LXC commands with a restrictive umask.
|
||||||
execute *(['sudo'] + command)
|
# Otherwise disasters occur, like the container root directory
|
||||||
else
|
# having permissions `rwxr-x---` which prevents the `vagrant`
|
||||||
execute *(['sudo', '/usr/bin/env'] + command)
|
# 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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue