cheffish 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a849241ed53a1895729159021b5850c05daa8c55
4
- data.tar.gz: c0d56677f2fd295cc75f7698fad5a36ad7c4ca65
3
+ metadata.gz: c768248960ee1fe2711d0207f64fe5490d2954f7
4
+ data.tar.gz: 4afe8736f72242618444b6cccfc7445332951551
5
5
  SHA512:
6
- metadata.gz: d94928862e7662c9f80fb21fdeb5562e3461094acf49a8acafb19c6c808ebd3252ac16976ddd340e509ef8ddb562ad2d0b8d9550cfa2f28b9f9100e760c3d26a
7
- data.tar.gz: a8820984c90aa4d4d9db3a828e9bb2c2b12d96fab2b4b0aac9ba4ad18c16293c6bf0467decdff8dafe0ea4a4987e9a5f224778d0482bbd9104d1b82fb15bf278
6
+ metadata.gz: 40cd6c19536b07623598b3e65cf6a5ddb710484c034dcc024f57905f03c1fb19f475bcc6dd93834b6e4adaee0e25efcd8376451c42fee8edd10140518e2b2e8c
7
+ data.tar.gz: 7f88593e7f4fb9b7473cb24a7ff9a4242a7f497778785cfc608e695c84e4f21624a88ea71adea2ba86cf957adba1c3aa72c83c70d8fe631f4499c7adef84f4c2
@@ -49,7 +49,7 @@ class Chef::Provider::PrivateKey < Chef::Provider::LWRPBase
49
49
  (new_resource.regenerate_if_different &&
50
50
  (current_resource.size != new_resource.size ||
51
51
  current_resource.type != new_resource.type))
52
- action = (current_resource.path == :none || ::File.exists?(current_resource.path)) ? "overwrite" : "create"
52
+ action = (Array(current_resource.action) == [ :delete ]) ? "create" : "overwrite"
53
53
  converge_by "#{action} #{new_resource.type} private key #{new_resource.path} (#{new_resource.size} bits#{new_resource.pass_phrase ? ", #{new_resource.cipher} password" : ""})" do
54
54
  case new_resource.type
55
55
  when :rsa
@@ -80,6 +80,11 @@ class Chef::Provider::PrivateKey < Chef::Provider::LWRPBase
80
80
  converge_by "change format of #{new_resource.type} private key #{new_resource.path} from #{current_resource.format} to #{new_resource.format}" do
81
81
  write_private_key(current_private_key)
82
82
  end
83
+ elsif (@current_file_mode & 0077) != 0
84
+ new_mode = @current_file_mode & 07700
85
+ converge_by "change mode of private key #{new_resource.path} to #{new_mode.to_s(8)}" do
86
+ ::File.chmod(new_mode, new_resource.path)
87
+ end
83
88
  end
84
89
  end
85
90
  end
@@ -109,8 +114,10 @@ class Chef::Provider::PrivateKey < Chef::Provider::LWRPBase
109
114
  end
110
115
 
111
116
  def write_private_key(key)
112
- IO.write(new_resource.path, encode_private_key(key))
113
- # TODO permissions on file?
117
+ ::File.open(new_resource.path, 'w') do |file|
118
+ file.chmod(0600)
119
+ file.write(encode_private_key(key))
120
+ end
114
121
  end
115
122
 
116
123
  def new_source_key
@@ -148,6 +155,7 @@ class Chef::Provider::PrivateKey < Chef::Provider::LWRPBase
148
155
  resource.pass_phrase key_format[:pass_phrase]
149
156
  resource.cipher key_format[:cipher]
150
157
  end
158
+ @current_file_mode = ::File.stat(new_resource.path).mode
151
159
  rescue
152
160
  # If there's an error reading, we assume format and type are wrong and don't futz with them
153
161
  end
@@ -1,4 +1,4 @@
1
1
  module Cheffish
2
- VERSION = '0.2.1'
2
+ VERSION = '0.2.2'
3
3
  end
4
4
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cheffish
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Keiser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-11 00:00:00.000000000 Z
11
+ date: 2014-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef