microwave 0.1004.5 → 0.1004.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/chef.rb +0 -1
- data/lib/chef/client.rb +0 -19
- data/lib/chef/config.rb +7 -58
- data/lib/chef/cookbook/cookbook_version_loader.rb +0 -14
- data/lib/chef/cookbook_version.rb +1 -133
- data/lib/chef/environment.rb +0 -36
- data/lib/chef/handler/json_file.rb +1 -1
- data/lib/chef/mixin/recipe_definition_dsl_core.rb +18 -34
- data/lib/chef/mixin/shell_out.rb +1 -0
- data/lib/chef/node.rb +0 -29
- data/lib/chef/provider/execute.rb +1 -0
- data/lib/chef/provider/file.rb +1 -14
- data/lib/chef/resource.rb +1 -1
- data/lib/chef/role.rb +13 -68
- data/lib/chef/run_context.rb +1 -15
- data/lib/chef/tasks/chef_repo.rake +0 -1
- data/lib/chef/version.rb +1 -1
- metadata +24 -17
- data/lib/chef/monkey_patches/string.rb +0 -49
- data/lib/chef/resource_definition.rb +0 -67
- data/lib/chef/resource_definition_list.rb +0 -38
- data/lib/chef/util/windows/net_group.rb +0 -101
- data/lib/chef/util/windows/net_use.rb +0 -121
- data/lib/chef/util/windows/net_user.rb +0 -198
- data/lib/chef/util/windows/volume.rb +0 -59
@@ -1,38 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Adam Jacob (<adam@opscode.com>)
|
3
|
-
# Copyright:: Copyright (c) 2008 Opscode, Inc.
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
require 'chef/mixin/from_file'
|
20
|
-
require 'chef/resource_definition'
|
21
|
-
|
22
|
-
class Chef
|
23
|
-
class ResourceDefinitionList
|
24
|
-
include Chef::Mixin::FromFile
|
25
|
-
|
26
|
-
attr_accessor :defines
|
27
|
-
|
28
|
-
def initialize
|
29
|
-
@defines = Hash.new
|
30
|
-
end
|
31
|
-
|
32
|
-
def define(resource_name, prototype_params=nil, &block)
|
33
|
-
@defines[resource_name] = ResourceDefinition.new
|
34
|
-
@defines[resource_name].define(resource_name, prototype_params, &block)
|
35
|
-
true
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,101 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Doug MacEachern (<dougm@vmware.com>)
|
3
|
-
# Copyright:: Copyright (c) 2010 VMware, Inc.
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
require 'chef/util/windows'
|
20
|
-
|
21
|
-
#wrapper around a subset of the NetGroup* APIs.
|
22
|
-
#nothing Chef specific, but not complete enough to be its own gem, so util for now.
|
23
|
-
class Chef::Util::Windows::NetGroup < Chef::Util::Windows
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
def pack_str(s)
|
28
|
-
[str_to_ptr(s)].pack('L')
|
29
|
-
end
|
30
|
-
|
31
|
-
def modify_members(members, func)
|
32
|
-
buffer = 0.chr * (members.size * PTR_SIZE)
|
33
|
-
members.each_with_index do |member,offset|
|
34
|
-
buffer[offset*PTR_SIZE,PTR_SIZE] = pack_str(multi_to_wide(member))
|
35
|
-
end
|
36
|
-
rc = func.call(nil, @name, 3, buffer, members.size)
|
37
|
-
if rc != NERR_Success
|
38
|
-
raise ArgumentError, get_last_error(rc)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
public
|
43
|
-
|
44
|
-
def initialize(groupname)
|
45
|
-
@name = multi_to_wide(groupname)
|
46
|
-
end
|
47
|
-
|
48
|
-
def local_get_members
|
49
|
-
group_members = []
|
50
|
-
handle = 0.chr * PTR_SIZE
|
51
|
-
rc = ERROR_MORE_DATA
|
52
|
-
|
53
|
-
while rc == ERROR_MORE_DATA
|
54
|
-
ptr = 0.chr * PTR_SIZE
|
55
|
-
nread = 0.chr * PTR_SIZE
|
56
|
-
total = 0.chr * PTR_SIZE
|
57
|
-
|
58
|
-
rc = NetLocalGroupGetMembers.call(nil, @name, 1, ptr, -1,
|
59
|
-
nread, total, handle)
|
60
|
-
if (rc == NERR_Success) || (rc == ERROR_MORE_DATA)
|
61
|
-
ptr = ptr.unpack('L')[0]
|
62
|
-
nread = nread.unpack('i')[0]
|
63
|
-
members = 0.chr * (nread * (PTR_SIZE * 3)) #nread * sizeof(LOCALGROUP_MEMBERS_INFO_1)
|
64
|
-
memcpy(members, ptr, members.size)
|
65
|
-
|
66
|
-
#3 pointer fields in LOCALGROUP_MEMBERS_INFO_1, offset 2*PTR_SIZE is lgrmi1_name
|
67
|
-
nread.times do |i|
|
68
|
-
offset = (i * 3) + 2
|
69
|
-
member = lpwstr_to_s(members, offset)
|
70
|
-
group_members << member
|
71
|
-
end
|
72
|
-
NetApiBufferFree(ptr)
|
73
|
-
else
|
74
|
-
raise ArgumentError, get_last_error(rc)
|
75
|
-
end
|
76
|
-
end
|
77
|
-
group_members
|
78
|
-
end
|
79
|
-
|
80
|
-
def local_add
|
81
|
-
rc = NetLocalGroupAdd.call(nil, 0, pack_str(@name), nil)
|
82
|
-
if rc != NERR_Success
|
83
|
-
raise ArgumentError, get_last_error(rc)
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
def local_set_members(members)
|
88
|
-
modify_members(members, NetLocalGroupSetMembers)
|
89
|
-
end
|
90
|
-
|
91
|
-
def local_add_members(members)
|
92
|
-
modify_members(members, NetLocalGroupAddMembers)
|
93
|
-
end
|
94
|
-
|
95
|
-
def local_delete
|
96
|
-
rc = NetLocalGroupDel.call(nil, @name)
|
97
|
-
if rc != NERR_Success
|
98
|
-
raise ArgumentError, get_last_error(rc)
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
@@ -1,121 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Doug MacEachern (<dougm@vmware.com>)
|
3
|
-
# Copyright:: Copyright (c) 2010 VMware, Inc.
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
#the Win32 Volume APIs do not support mapping network drives. not supported by WMI either.
|
20
|
-
#see also: WNetAddConnection2 and WNetAddConnection3
|
21
|
-
#see also cmd.exe: net use /?
|
22
|
-
|
23
|
-
require 'chef/util/windows'
|
24
|
-
|
25
|
-
class Chef::Util::Windows::NetUse < Chef::Util::Windows
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
USE_NOFORCE = 0
|
30
|
-
USE_FORCE = 1
|
31
|
-
USE_LOTS_OF_FORCE = 2 #every windows API should support this flag
|
32
|
-
|
33
|
-
USE_INFO_2 = [
|
34
|
-
[:local, nil],
|
35
|
-
[:remote, nil],
|
36
|
-
[:password, nil],
|
37
|
-
[:status, 0],
|
38
|
-
[:asg_type, 0],
|
39
|
-
[:refcount, 0],
|
40
|
-
[:usecount, 0],
|
41
|
-
[:username, nil],
|
42
|
-
[:domainname, nil]
|
43
|
-
]
|
44
|
-
|
45
|
-
USE_INFO_2_TEMPLATE =
|
46
|
-
USE_INFO_2.collect { |field| field[1].class == Fixnum ? 'i' : 'L' }.join
|
47
|
-
|
48
|
-
SIZEOF_USE_INFO_2 = #sizeof(USE_INFO_2)
|
49
|
-
USE_INFO_2.inject(0){|sum,item|
|
50
|
-
sum + (item[1].class == Fixnum ? 4 : PTR_SIZE)
|
51
|
-
}
|
52
|
-
|
53
|
-
def use_info_2(args)
|
54
|
-
USE_INFO_2.collect { |field|
|
55
|
-
args.include?(field[0]) ? args[field[0]] : field[1]
|
56
|
-
}
|
57
|
-
end
|
58
|
-
|
59
|
-
def use_info_2_pack(use)
|
60
|
-
use.collect { |v|
|
61
|
-
v.class == Fixnum ? v : str_to_ptr(multi_to_wide(v))
|
62
|
-
}.pack(USE_INFO_2_TEMPLATE)
|
63
|
-
end
|
64
|
-
|
65
|
-
def use_info_2_unpack(buffer)
|
66
|
-
use = Hash.new
|
67
|
-
USE_INFO_2.each_with_index do |field,offset|
|
68
|
-
use[field[0]] = field[1].class == Fixnum ?
|
69
|
-
dword_to_i(buffer, offset) : lpwstr_to_s(buffer, offset)
|
70
|
-
end
|
71
|
-
use
|
72
|
-
end
|
73
|
-
|
74
|
-
public
|
75
|
-
|
76
|
-
def initialize(localname)
|
77
|
-
@localname = localname
|
78
|
-
@name = multi_to_wide(localname)
|
79
|
-
end
|
80
|
-
|
81
|
-
def add(args)
|
82
|
-
if args.class == String
|
83
|
-
remote = args
|
84
|
-
args = Hash.new
|
85
|
-
args[:remote] = remote
|
86
|
-
end
|
87
|
-
args[:local] ||= @localname
|
88
|
-
use = use_info_2(args)
|
89
|
-
buffer = use_info_2_pack(use)
|
90
|
-
rc = NetUseAdd.call(nil, 2, buffer, nil)
|
91
|
-
if rc != NERR_Success
|
92
|
-
raise ArgumentError, get_last_error(rc)
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
def get_info
|
97
|
-
ptr = 0.chr * PTR_SIZE
|
98
|
-
rc = NetUseGetInfo.call(nil, @name, 2, ptr)
|
99
|
-
|
100
|
-
if rc != NERR_Success
|
101
|
-
raise ArgumentError, get_last_error(rc)
|
102
|
-
end
|
103
|
-
|
104
|
-
ptr = ptr.unpack('L')[0]
|
105
|
-
buffer = 0.chr * SIZEOF_USE_INFO_2
|
106
|
-
memcpy(buffer, ptr, buffer.size)
|
107
|
-
NetApiBufferFree(ptr)
|
108
|
-
use_info_2_unpack(buffer)
|
109
|
-
end
|
110
|
-
|
111
|
-
def device
|
112
|
-
get_info()[:remote]
|
113
|
-
end
|
114
|
-
#XXX should we use some FORCE here?
|
115
|
-
def delete
|
116
|
-
rc = NetUseDel.call(nil, @name, USE_NOFORCE)
|
117
|
-
if rc != NERR_Success
|
118
|
-
raise ArgumentError, get_last_error(rc)
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
@@ -1,198 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Doug MacEachern (<dougm@vmware.com>)
|
3
|
-
# Copyright:: Copyright (c) 2010 VMware, Inc.
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
require 'chef/util/windows'
|
20
|
-
|
21
|
-
#wrapper around a subset of the NetUser* APIs.
|
22
|
-
#nothing Chef specific, but not complete enough to be its own gem, so util for now.
|
23
|
-
class Chef::Util::Windows::NetUser < Chef::Util::Windows
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
LogonUser = Windows::API.new('LogonUser', 'SSSLLP', 'I', 'advapi32')
|
28
|
-
|
29
|
-
DOMAIN_GROUP_RID_USERS = 0x00000201
|
30
|
-
|
31
|
-
UF_SCRIPT = 0x000001
|
32
|
-
UF_ACCOUNTDISABLE = 0x000002
|
33
|
-
UF_PASSWD_CANT_CHANGE = 0x000040
|
34
|
-
UF_NORMAL_ACCOUNT = 0x000200
|
35
|
-
UF_DONT_EXPIRE_PASSWD = 0x010000
|
36
|
-
|
37
|
-
#[:symbol_name, default_val]
|
38
|
-
#default_val duals as field type
|
39
|
-
#array index duals as structure offset
|
40
|
-
USER_INFO_3 = [
|
41
|
-
[:name, nil],
|
42
|
-
[:password, nil],
|
43
|
-
[:password_age, 0],
|
44
|
-
[:priv, 0], #"The NetUserAdd and NetUserSetInfo functions ignore this member"
|
45
|
-
[:home_dir, nil],
|
46
|
-
[:comment, nil],
|
47
|
-
[:flags, UF_SCRIPT|UF_DONT_EXPIRE_PASSWD|UF_NORMAL_ACCOUNT],
|
48
|
-
[:script_path, nil],
|
49
|
-
[:auth_flags, 0],
|
50
|
-
[:full_name, nil],
|
51
|
-
[:user_comment, nil],
|
52
|
-
[:parms, nil],
|
53
|
-
[:workstations, nil],
|
54
|
-
[:last_logon, 0],
|
55
|
-
[:last_logoff, 0],
|
56
|
-
[:acct_expires, -1],
|
57
|
-
[:max_storage, -1],
|
58
|
-
[:units_per_week, 0],
|
59
|
-
[:logon_hours, nil],
|
60
|
-
[:bad_pw_count, 0],
|
61
|
-
[:num_logons, 0],
|
62
|
-
[:logon_server, nil],
|
63
|
-
[:country_code, 0],
|
64
|
-
[:code_page, 0],
|
65
|
-
[:user_id, 0],
|
66
|
-
[:primary_group_id, DOMAIN_GROUP_RID_USERS],
|
67
|
-
[:profile, nil],
|
68
|
-
[:home_dir_drive, nil],
|
69
|
-
[:password_expired, 0]
|
70
|
-
]
|
71
|
-
|
72
|
-
USER_INFO_3_TEMPLATE =
|
73
|
-
USER_INFO_3.collect { |field| field[1].class == Fixnum ? 'i' : 'L' }.join
|
74
|
-
|
75
|
-
SIZEOF_USER_INFO_3 = #sizeof(USER_INFO_3)
|
76
|
-
USER_INFO_3.inject(0){|sum,item|
|
77
|
-
sum + (item[1].class == Fixnum ? 4 : PTR_SIZE)
|
78
|
-
}
|
79
|
-
|
80
|
-
def user_info_3(args)
|
81
|
-
USER_INFO_3.collect { |field|
|
82
|
-
args.include?(field[0]) ? args[field[0]] : field[1]
|
83
|
-
}
|
84
|
-
end
|
85
|
-
|
86
|
-
def user_info_3_pack(user)
|
87
|
-
user.collect { |v|
|
88
|
-
v.class == Fixnum ? v : str_to_ptr(multi_to_wide(v))
|
89
|
-
}.pack(USER_INFO_3_TEMPLATE)
|
90
|
-
end
|
91
|
-
|
92
|
-
def user_info_3_unpack(buffer)
|
93
|
-
user = Hash.new
|
94
|
-
USER_INFO_3.each_with_index do |field,offset|
|
95
|
-
user[field[0]] = field[1].class == Fixnum ?
|
96
|
-
dword_to_i(buffer, offset) : lpwstr_to_s(buffer, offset)
|
97
|
-
end
|
98
|
-
user
|
99
|
-
end
|
100
|
-
|
101
|
-
def set_info(args)
|
102
|
-
user = user_info_3(args)
|
103
|
-
buffer = user_info_3_pack(user)
|
104
|
-
rc = NetUserSetInfo.call(nil, @name, 3, buffer, nil)
|
105
|
-
if rc != NERR_Success
|
106
|
-
raise ArgumentError, get_last_error(rc)
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
public
|
111
|
-
|
112
|
-
def initialize(username)
|
113
|
-
@username = username
|
114
|
-
@name = multi_to_wide(username)
|
115
|
-
end
|
116
|
-
|
117
|
-
LOGON32_PROVIDER_DEFAULT = 0
|
118
|
-
LOGON32_LOGON_NETWORK = 3
|
119
|
-
#XXX for an extra painful alternative, see: http://support.microsoft.com/kb/180548
|
120
|
-
def validate_credentials(passwd)
|
121
|
-
token = 0.chr * PTR_SIZE
|
122
|
-
res = LogonUser.call(@username, nil, passwd,
|
123
|
-
LOGON32_LOGON_NETWORK, LOGON32_PROVIDER_DEFAULT, token)
|
124
|
-
if res == 0
|
125
|
-
return false
|
126
|
-
end
|
127
|
-
::Windows::Handle::CloseHandle.call(token.unpack('L')[0])
|
128
|
-
return true
|
129
|
-
end
|
130
|
-
|
131
|
-
def get_info
|
132
|
-
ptr = 0.chr * PTR_SIZE
|
133
|
-
rc = NetUserGetInfo.call(nil, @name, 3, ptr)
|
134
|
-
|
135
|
-
if rc != NERR_Success
|
136
|
-
raise ArgumentError, get_last_error(rc)
|
137
|
-
end
|
138
|
-
|
139
|
-
ptr = ptr.unpack('L')[0]
|
140
|
-
buffer = 0.chr * SIZEOF_USER_INFO_3
|
141
|
-
memcpy(buffer, ptr, buffer.size)
|
142
|
-
NetApiBufferFree(ptr)
|
143
|
-
user_info_3_unpack(buffer)
|
144
|
-
end
|
145
|
-
|
146
|
-
def add(args)
|
147
|
-
user = user_info_3(args)
|
148
|
-
buffer = user_info_3_pack(user)
|
149
|
-
|
150
|
-
rc = NetUserAdd.call(nil, 3, buffer, rc)
|
151
|
-
if rc != NERR_Success
|
152
|
-
raise ArgumentError, get_last_error(rc)
|
153
|
-
end
|
154
|
-
|
155
|
-
#usri3_primary_group_id:
|
156
|
-
#"When you call the NetUserAdd function, this member must be DOMAIN_GROUP_RID_USERS"
|
157
|
-
NetLocalGroupAddMembers(nil, multi_to_wide("Users"), 3, buffer[0,PTR_SIZE], 1)
|
158
|
-
end
|
159
|
-
|
160
|
-
def user_modify(&proc)
|
161
|
-
user = get_info
|
162
|
-
user[:last_logon] = user[:units_per_week] = 0 #ignored as per USER_INFO_3 doc
|
163
|
-
user[:logon_hours] = nil #PBYTE field; \0 == no changes
|
164
|
-
proc.call(user)
|
165
|
-
set_info(user)
|
166
|
-
end
|
167
|
-
|
168
|
-
def update(args)
|
169
|
-
user_modify do |user|
|
170
|
-
args.each do |key,val|
|
171
|
-
user[key] = val
|
172
|
-
end
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
def delete
|
177
|
-
rc = NetUserDel.call(nil, @name)
|
178
|
-
if rc != NERR_Success
|
179
|
-
raise ArgumentError, get_last_error(rc)
|
180
|
-
end
|
181
|
-
end
|
182
|
-
|
183
|
-
def disable_account
|
184
|
-
user_modify do |user|
|
185
|
-
user[:flags] |= UF_ACCOUNTDISABLE
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
|
-
def enable_account
|
190
|
-
user_modify do |user|
|
191
|
-
user[:flags] &= ~UF_ACCOUNTDISABLE
|
192
|
-
end
|
193
|
-
end
|
194
|
-
|
195
|
-
def check_enabled
|
196
|
-
(get_info()[:flags] & UF_ACCOUNTDISABLE) != 0
|
197
|
-
end
|
198
|
-
end
|