summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2013-06-18 10:32:47 -0700
committerelijah <elijah@riseup.net>2013-06-18 10:32:47 -0700
commit5675bd54cf7dc11a234bb305c64c801c4eeaea62 (patch)
treea851c2a882a5a828b117846c360c6138493c75b4
parent6ee70e56e4196a357f7f383e0c95cd656a6a0bc9 (diff)
fix bug with vagrant ssh keys
-rw-r--r--lib/leap_cli/commands/vagrant.rb10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/leap_cli/commands/vagrant.rb b/lib/leap_cli/commands/vagrant.rb
index f7505f2..a60e176 100644
--- a/lib/leap_cli/commands/vagrant.rb
+++ b/lib/leap_cli/commands/vagrant.rb
@@ -65,11 +65,17 @@ module LeapCli; module Commands
public
+ #
+ # returns the path to a vagrant ssh key file.
+ #
+ # if the vagrant.key file is owned by root or ourselves, then
+ # we need to make sure that it owned by us and not world readable.
+ #
def vagrant_ssh_key_file
file_path = File.expand_path('../../../vendor/vagrant_ssh_keys/vagrant.key', File.dirname(__FILE__))
Util.assert_files_exist! file_path
- if File.new(file_path).stat.uid == Process.euid
- # if the vagrant.key file is owned by ourselves, we need to make sure that it is not world readable
+ uid = File.new(file_path).stat.uid
+ if uid == 0 || uid == Process.euid
FileUtils.cp file_path, '/tmp/vagrant.key'
FileUtils.chmod 0600, '/tmp/vagrant.key'
file_path = '/tmp/vagrant.key'