diff options
| author | danielsdeleo <dan@opscode.com> | 2012-12-19 11:12:34 -0800 |
|---|---|---|
| committer | danielsdeleo <dan@opscode.com> | 2012-12-19 11:12:34 -0800 |
| commit | ebe554b95186ec344988156e67cf8c196cce5270 (patch) | |
| tree | 518e1663998e8a1b7a6d0e29a57abb05ac47f54e /lib/chef/api_client/registration.rb | |
| parent | e29286ac133b7dbde2a1d7abb3bc4dfbdfd82572 (diff) | |
| download | chef-ebe554b95186ec344988156e67cf8c196cce5270.tar.gz | |
[CHEF-3689] no File::NOFOLLOW on windows
Diffstat (limited to 'lib/chef/api_client/registration.rb')
| -rw-r--r-- | lib/chef/api_client/registration.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/chef/api_client/registration.rb b/lib/chef/api_client/registration.rb index 354267f733..f44c326d5d 100644 --- a/lib/chef/api_client/registration.rb +++ b/lib/chef/api_client/registration.rb @@ -73,7 +73,7 @@ class Chef end def write_key - ::File.open(destination, File::CREAT|File::TRUNC|File::RDWR|File::NOFOLLOW, 0600) do |f| + ::File.open(destination, file_flags, 0600) do |f| f.print(private_key) end rescue IOError => e @@ -112,6 +112,13 @@ class Chef Chef::Config[:validation_client_name], Chef::Config[:validation_key]) end + + def file_flags + base_flags = File::CREAT|File::TRUNC|File::RDWR + # Windows doesn't have symlinks, so it doesn't have NOFOLLOW + base_flags |= File::NOFOLLOW if defined?(File::NOFOLLOW) + base_flags + end end end end |
