chef 0.10.10 → 10.12.0.rc.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +6 -0
- data/distro/common/html/chef-client.8.html +4 -3
- data/distro/common/html/chef-expander.8.html +3 -3
- data/distro/common/html/chef-expanderctl.8.html +3 -3
- data/distro/common/html/chef-server-webui.8.html +3 -3
- data/distro/common/html/chef-server.8.html +3 -3
- data/distro/common/html/chef-solo.8.html +3 -3
- data/distro/common/html/chef-solr.8.html +3 -3
- data/distro/common/html/knife-bootstrap.1.html +3 -3
- data/distro/common/html/knife-client.1.html +3 -3
- data/distro/common/html/knife-configure.1.html +3 -3
- data/distro/common/html/knife-cookbook-site.1.html +3 -3
- data/distro/common/html/knife-cookbook.1.html +3 -3
- data/distro/common/html/knife-data-bag.1.html +3 -3
- data/distro/common/html/knife-environment.1.html +3 -3
- data/distro/common/html/knife-exec.1.html +3 -3
- data/distro/common/html/knife-index.1.html +3 -3
- data/distro/common/html/knife-node.1.html +3 -3
- data/distro/common/html/knife-role.1.html +3 -3
- data/distro/common/html/knife-search.1.html +3 -3
- data/distro/common/html/knife-ssh.1.html +3 -3
- data/distro/common/html/knife-status.1.html +3 -3
- data/distro/common/html/knife-tag.1.html +3 -3
- data/distro/common/html/knife.1.html +3 -3
- data/distro/common/html/shef.1.html +3 -3
- data/distro/common/man/man1/knife-bootstrap.1 +1 -1
- data/distro/common/man/man1/knife-client.1 +1 -1
- data/distro/common/man/man1/knife-configure.1 +1 -1
- data/distro/common/man/man1/knife-cookbook-site.1 +1 -1
- data/distro/common/man/man1/knife-cookbook.1 +1 -1
- data/distro/common/man/man1/knife-data-bag.1 +1 -1
- data/distro/common/man/man1/knife-environment.1 +1 -1
- data/distro/common/man/man1/knife-exec.1 +1 -1
- data/distro/common/man/man1/knife-index.1 +1 -1
- data/distro/common/man/man1/knife-node.1 +1 -1
- data/distro/common/man/man1/knife-role.1 +1 -1
- data/distro/common/man/man1/knife-search.1 +1 -1
- data/distro/common/man/man1/knife-ssh.1 +1 -1
- data/distro/common/man/man1/knife-status.1 +1 -1
- data/distro/common/man/man1/knife-tag.1 +1 -1
- data/distro/common/man/man1/knife.1 +1 -1
- data/distro/common/man/man1/shef.1 +1 -1
- data/distro/common/man/man8/chef-client.8 +5 -1
- data/distro/common/man/man8/chef-expander.8 +1 -1
- data/distro/common/man/man8/chef-expanderctl.8 +1 -1
- data/distro/common/man/man8/chef-server-webui.8 +1 -1
- data/distro/common/man/man8/chef-server.8 +1 -1
- data/distro/common/man/man8/chef-solo.8 +1 -1
- data/distro/common/man/man8/chef-solr.8 +1 -1
- data/distro/common/markdown/man8/chef-client.mkd +2 -0
- data/lib/chef/application/client.rb +1 -1
- data/lib/chef/application/solo.rb +1 -1
- data/lib/chef/application/windows_service.rb +1 -1
- data/lib/chef/config.rb +1 -1
- data/lib/chef/exceptions.rb +3 -0
- data/lib/chef/file_access_control/unix.rb +21 -6
- data/lib/chef/file_access_control/windows.rb +7 -7
- data/lib/chef/knife/ssh.rb +4 -2
- data/lib/chef/mixin/enforce_ownership_and_permissions.rb +1 -1
- data/lib/chef/provider/link.rb +49 -45
- data/lib/chef/provider/mdadm.rb +4 -1
- data/lib/chef/provider/package/rubygems.rb +2 -1
- data/lib/chef/provider/remote_file.rb +17 -1
- data/lib/chef/reserved_names.rb +9 -0
- data/lib/chef/resource/link.rb +1 -17
- data/lib/chef/resource/mdadm.rb +1 -1
- data/lib/chef/resource_platform_map.rb +1 -3
- data/lib/chef/rest.rb +48 -17
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/api.rb +16 -1
- data/lib/chef/win32/api/error.rb +9 -9
- data/lib/chef/win32/api/file.rb +263 -17
- data/lib/chef/win32/api/memory.rb +12 -12
- data/lib/chef/win32/api/process.rb +5 -5
- data/lib/chef/win32/api/psapi.rb +3 -3
- data/lib/chef/win32/api/security.rb +41 -41
- data/lib/chef/win32/api/system.rb +8 -8
- data/lib/chef/win32/api/unicode.rb +6 -6
- data/lib/chef/win32/error.rb +4 -4
- data/lib/chef/win32/file.rb +65 -15
- data/lib/chef/win32/file/info.rb +7 -7
- data/lib/chef/win32/handle.rb +3 -3
- data/lib/chef/win32/memory.rb +8 -8
- data/lib/chef/win32/process.rb +8 -8
- data/lib/chef/win32/security.rb +49 -49
- data/lib/chef/win32/security/ace.rb +11 -11
- data/lib/chef/win32/security/acl.rb +10 -10
- data/lib/chef/win32/security/securable_object.rb +13 -13
- data/lib/chef/win32/security/security_descriptor.rb +12 -12
- data/lib/chef/win32/security/sid.rb +8 -8
- data/lib/chef/win32/security/token.rb +8 -8
- data/lib/chef/win32/unicode.rb +5 -5
- data/lib/chef/win32/version.rb +4 -4
- metadata +374 -370
@@ -19,10 +19,10 @@
|
|
19
19
|
require 'chef/win32/api'
|
20
20
|
|
21
21
|
class Chef
|
22
|
-
module Win32
|
22
|
+
module ReservedNames::Win32
|
23
23
|
module API
|
24
24
|
module Memory
|
25
|
-
extend Chef::Win32::API
|
25
|
+
extend Chef::ReservedNames::Win32::API
|
26
26
|
|
27
27
|
###############################################
|
28
28
|
# Win32 API Constants
|
@@ -56,21 +56,21 @@ HLOCAL WINAPI LocalAlloc(
|
|
56
56
|
__in SIZE_T uBytes
|
57
57
|
);
|
58
58
|
=end
|
59
|
-
|
59
|
+
safe_attach_function :LocalAlloc, [ :UINT, :SIZE_T ], :pointer
|
60
60
|
|
61
61
|
=begin
|
62
62
|
UINT WINAPI LocalFlags(
|
63
63
|
__in HLOCAL hMem
|
64
64
|
);
|
65
65
|
=end
|
66
|
-
|
66
|
+
safe_attach_function :LocalFlags, [ :pointer ], :UINT
|
67
67
|
|
68
68
|
=begin
|
69
69
|
HLOCAL WINAPI LocalFree(
|
70
70
|
__in HLOCAL hMem
|
71
71
|
);
|
72
72
|
=end
|
73
|
-
|
73
|
+
safe_attach_function :LocalFree, [ :pointer ], :pointer
|
74
74
|
|
75
75
|
=begin
|
76
76
|
HLOCAL WINAPI LocalReAlloc(
|
@@ -79,25 +79,25 @@ HLOCAL WINAPI LocalReAlloc(
|
|
79
79
|
__in UINT uFlags
|
80
80
|
);
|
81
81
|
=end
|
82
|
-
|
82
|
+
safe_attach_function :LocalReAlloc, [ :pointer, :SIZE_T, :UINT ], :pointer
|
83
83
|
|
84
84
|
=begin
|
85
85
|
UINT WINAPI LocalSize(
|
86
86
|
__in HLOCAL hMem
|
87
87
|
);
|
88
88
|
=end
|
89
|
-
|
89
|
+
safe_attach_function :LocalSize, [ :pointer ], :SIZE_T
|
90
90
|
|
91
91
|
###############################################
|
92
92
|
# FFI API Bindings
|
93
93
|
###############################################
|
94
94
|
|
95
95
|
ffi_lib FFI::Library::LIBC
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
96
|
+
safe_attach_function :malloc, [:size_t], :pointer
|
97
|
+
safe_attach_function :calloc, [:size_t], :pointer
|
98
|
+
safe_attach_function :realloc, [:pointer, :size_t], :pointer
|
99
|
+
safe_attach_function :free, [:pointer], :void
|
100
|
+
safe_attach_function :memcpy, [:pointer, :pointer, :size_t], :pointer
|
101
101
|
|
102
102
|
end
|
103
103
|
end
|
@@ -19,10 +19,10 @@
|
|
19
19
|
require 'chef/win32/api'
|
20
20
|
|
21
21
|
class Chef
|
22
|
-
module Win32
|
22
|
+
module ReservedNames::Win32
|
23
23
|
module API
|
24
24
|
module Process
|
25
|
-
extend Chef::Win32::API
|
25
|
+
extend Chef::ReservedNames::Win32::API
|
26
26
|
|
27
27
|
###############################################
|
28
28
|
# Win32 API Bindings
|
@@ -30,9 +30,9 @@ class Chef
|
|
30
30
|
|
31
31
|
ffi_lib 'kernel32'
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
safe_attach_function :GetCurrentProcess, [], :HANDLE
|
34
|
+
safe_attach_function :GetProcessHandleCount, [ :HANDLE, :LPDWORD ], :BOOL
|
35
|
+
safe_attach_function :GetProcessId, [ :HANDLE ], :DWORD
|
36
36
|
|
37
37
|
end
|
38
38
|
end
|
data/lib/chef/win32/api/psapi.rb
CHANGED
@@ -19,10 +19,10 @@
|
|
19
19
|
require 'chef/win32/api'
|
20
20
|
|
21
21
|
class Chef
|
22
|
-
module Win32
|
22
|
+
module ReservedNames::Win32
|
23
23
|
module API
|
24
24
|
module PSAPI
|
25
|
-
extend Chef::Win32::API
|
25
|
+
extend Chef::ReservedNames::Win32::API
|
26
26
|
|
27
27
|
###############################################
|
28
28
|
# Win32 API Bindings
|
@@ -43,7 +43,7 @@ class Chef
|
|
43
43
|
|
44
44
|
ffi_lib 'psapi'
|
45
45
|
|
46
|
-
|
46
|
+
safe_attach_function :GetProcessMemoryInfo, [ :HANDLE, :pointer, :DWORD ], :BOOL
|
47
47
|
|
48
48
|
end
|
49
49
|
end
|
@@ -19,10 +19,10 @@
|
|
19
19
|
require 'chef/win32/api'
|
20
20
|
|
21
21
|
class Chef
|
22
|
-
module Win32
|
22
|
+
module ReservedNames::Win32
|
23
23
|
module API
|
24
24
|
module Security
|
25
|
-
extend Chef::Win32::API
|
25
|
+
extend Chef::ReservedNames::Win32::API
|
26
26
|
|
27
27
|
###############################################
|
28
28
|
# Win32 API Constants
|
@@ -295,45 +295,45 @@ class Chef
|
|
295
295
|
|
296
296
|
ffi_lib "advapi32"
|
297
297
|
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
298
|
+
safe_attach_function :AddAce, [ :pointer, :DWORD, :DWORD, :LPVOID, :DWORD ], :BOOL
|
299
|
+
safe_attach_function :AddAccessAllowedAce, [ :pointer, :DWORD, :DWORD, :pointer ], :BOOL
|
300
|
+
safe_attach_function :AddAccessAllowedAceEx, [ :pointer, :DWORD, :DWORD, :DWORD, :pointer ], :BOOL
|
301
|
+
safe_attach_function :AddAccessDeniedAce, [ :pointer, :DWORD, :DWORD, :pointer ], :BOOL
|
302
|
+
safe_attach_function :AddAccessDeniedAceEx, [ :pointer, :DWORD, :DWORD, :DWORD, :pointer ], :BOOL
|
303
|
+
safe_attach_function :AdjustTokenPrivileges, [ :HANDLE, :BOOL, :pointer, :DWORD, :pointer, :PDWORD ], :BOOL
|
304
|
+
safe_attach_function :ConvertSidToStringSidA, [ :pointer, :pointer ], :BOOL
|
305
|
+
safe_attach_function :ConvertStringSidToSidW, [ :pointer, :pointer ], :BOOL
|
306
|
+
safe_attach_function :DeleteAce, [ :pointer, :DWORD ], :BOOL
|
307
|
+
safe_attach_function :EqualSid, [ :pointer, :pointer ], :BOOL
|
308
|
+
safe_attach_function :FreeSid, [ :pointer ], :pointer
|
309
|
+
safe_attach_function :GetAce, [ :pointer, :DWORD, :pointer ], :BOOL
|
310
|
+
safe_attach_function :GetLengthSid, [ :pointer ], :DWORD
|
311
|
+
safe_attach_function :GetNamedSecurityInfoW, [ :LPWSTR, :SE_OBJECT_TYPE, :DWORD, :pointer, :pointer, :pointer, :pointer, :pointer ], :DWORD
|
312
|
+
safe_attach_function :GetSecurityDescriptorControl, [ :pointer, :PWORD, :LPDWORD], :BOOL
|
313
|
+
safe_attach_function :GetSecurityDescriptorDacl, [ :pointer, :LPBOOL, :pointer, :LPBOOL ], :BOOL
|
314
|
+
safe_attach_function :GetSecurityDescriptorGroup, [ :pointer, :pointer, :LPBOOL], :BOOL
|
315
|
+
safe_attach_function :GetSecurityDescriptorOwner, [ :pointer, :pointer, :LPBOOL], :BOOL
|
316
|
+
safe_attach_function :GetSecurityDescriptorSacl, [ :pointer, :LPBOOL, :pointer, :LPBOOL ], :BOOL
|
317
|
+
safe_attach_function :InitializeAcl, [ :pointer, :DWORD, :DWORD ], :BOOL
|
318
|
+
safe_attach_function :InitializeSecurityDescriptor, [ :pointer, :DWORD ], :BOOL
|
319
|
+
safe_attach_function :IsValidAcl, [ :pointer ], :BOOL
|
320
|
+
safe_attach_function :IsValidSecurityDescriptor, [ :pointer ], :BOOL
|
321
|
+
safe_attach_function :IsValidSid, [ :pointer ], :BOOL
|
322
|
+
safe_attach_function :LookupAccountNameW, [ :LPCWSTR, :LPCWSTR, :pointer, :LPDWORD, :LPWSTR, :LPDWORD, :pointer ], :BOOL
|
323
|
+
safe_attach_function :LookupAccountSidW, [ :LPCWSTR, :pointer, :LPWSTR, :LPDWORD, :LPWSTR, :LPDWORD, :pointer ], :BOOL
|
324
|
+
safe_attach_function :LookupPrivilegeNameW, [ :LPCWSTR, :PLUID, :LPWSTR, :LPDWORD ], :BOOL
|
325
|
+
safe_attach_function :LookupPrivilegeDisplayNameW, [ :LPCWSTR, :LPCWSTR, :LPWSTR, :LPDWORD, :LPDWORD ], :BOOL
|
326
|
+
safe_attach_function :LookupPrivilegeValueW, [ :LPCWSTR, :LPCWSTR, :PLUID ], :BOOL
|
327
|
+
safe_attach_function :MakeAbsoluteSD, [ :pointer, :pointer, :LPDWORD, :pointer, :LPDWORD, :pointer, :LPDWORD, :pointer, :LPDWORD, :pointer, :LPDWORD], :BOOL
|
328
|
+
safe_attach_function :OpenProcessToken, [ :HANDLE, :DWORD, :PHANDLE ], :BOOL
|
329
|
+
safe_attach_function :QuerySecurityAccessMask, [ :DWORD, :LPDWORD ], :void
|
330
|
+
safe_attach_function :SetFileSecurityW, [ :LPWSTR, :DWORD, :pointer ], :BOOL
|
331
|
+
safe_attach_function :SetNamedSecurityInfoW, [ :LPWSTR, :SE_OBJECT_TYPE, :DWORD, :pointer, :pointer, :pointer, :pointer ], :DWORD
|
332
|
+
safe_attach_function :SetSecurityAccessMask, [ :DWORD, :LPDWORD ], :void
|
333
|
+
safe_attach_function :SetSecurityDescriptorDacl, [ :pointer, :BOOL, :pointer, :BOOL ], :BOOL
|
334
|
+
safe_attach_function :SetSecurityDescriptorGroup, [ :pointer, :pointer, :BOOL ], :BOOL
|
335
|
+
safe_attach_function :SetSecurityDescriptorOwner, [ :pointer, :pointer, :BOOL ], :BOOL
|
336
|
+
safe_attach_function :SetSecurityDescriptorSacl, [ :pointer, :BOOL, :pointer, :BOOL ], :BOOL
|
337
337
|
|
338
338
|
end
|
339
339
|
end
|
@@ -19,10 +19,10 @@
|
|
19
19
|
require 'chef/win32/api'
|
20
20
|
|
21
21
|
class Chef
|
22
|
-
module Win32
|
22
|
+
module ReservedNames::Win32
|
23
23
|
module API
|
24
24
|
module System
|
25
|
-
extend Chef::Win32::API
|
25
|
+
extend Chef::ReservedNames::Win32::API
|
26
26
|
|
27
27
|
###############################################
|
28
28
|
# Win32 API Constants
|
@@ -153,20 +153,20 @@ BOOL WINAPI CloseHandle(
|
|
153
153
|
__in HANDLE hObject
|
154
154
|
);
|
155
155
|
=end
|
156
|
-
|
156
|
+
safe_attach_function :CloseHandle, [ :HANDLE ], :BOOL
|
157
157
|
|
158
158
|
=begin
|
159
159
|
DWORD WINAPI GetVersion(void);
|
160
160
|
=end
|
161
|
-
|
161
|
+
safe_attach_function :GetVersion, [], :DWORD
|
162
162
|
|
163
163
|
=begin
|
164
164
|
BOOL WINAPI GetVersionEx(
|
165
165
|
__inout LPOSVERSIONINFO lpVersionInfo
|
166
166
|
);
|
167
167
|
=end
|
168
|
-
|
169
|
-
|
168
|
+
safe_attach_function :GetVersionExW, [:pointer], :BOOL
|
169
|
+
safe_attach_function :GetVersionExA, [:pointer], :BOOL
|
170
170
|
|
171
171
|
=begin
|
172
172
|
BOOL WINAPI GetProductInfo(
|
@@ -177,14 +177,14 @@ BOOL WINAPI GetProductInfo(
|
|
177
177
|
__out PDWORD pdwReturnedProductType
|
178
178
|
);
|
179
179
|
=end
|
180
|
-
|
180
|
+
safe_attach_function :GetProductInfo, [:DWORD, :DWORD, :DWORD, :DWORD, :PDWORD], :BOOL
|
181
181
|
|
182
182
|
=begin
|
183
183
|
int WINAPI GetSystemMetrics(
|
184
184
|
__in int nIndex
|
185
185
|
);
|
186
186
|
=end
|
187
|
-
|
187
|
+
safe_attach_function :GetSystemMetrics, [:int], :int
|
188
188
|
|
189
189
|
end
|
190
190
|
end
|
@@ -19,10 +19,10 @@
|
|
19
19
|
require 'chef/win32/api'
|
20
20
|
|
21
21
|
class Chef
|
22
|
-
module Win32
|
22
|
+
module ReservedNames::Win32
|
23
23
|
module API
|
24
24
|
module Unicode
|
25
|
-
extend Chef::Win32::API
|
25
|
+
extend Chef::ReservedNames::Win32::API
|
26
26
|
|
27
27
|
###############################################
|
28
28
|
# Win32 API Constants
|
@@ -101,7 +101,7 @@ BOOL IsTextUnicode(
|
|
101
101
|
__inout LPINT lpiResult
|
102
102
|
);
|
103
103
|
=end
|
104
|
-
|
104
|
+
safe_attach_function :IsTextUnicode, [:pointer, :int, :LPINT], :BOOL
|
105
105
|
|
106
106
|
=begin
|
107
107
|
int MultiByteToWideChar(
|
@@ -113,7 +113,7 @@ int MultiByteToWideChar(
|
|
113
113
|
__in int cchWideChar
|
114
114
|
);
|
115
115
|
=end
|
116
|
-
|
116
|
+
safe_attach_function :MultiByteToWideChar, [:UINT, :DWORD, :LPCSTR, :int, :LPWSTR, :int], :int
|
117
117
|
|
118
118
|
=begin
|
119
119
|
int WideCharToMultiByte(
|
@@ -127,7 +127,7 @@ int WideCharToMultiByte(
|
|
127
127
|
__out LPBOOL lpUsedDefaultChar
|
128
128
|
);
|
129
129
|
=end
|
130
|
-
|
130
|
+
safe_attach_function :WideCharToMultiByte, [:UINT, :DWORD, :LPCWSTR, :int, :LPSTR, :int, :LPCSTR, :LPBOOL], :int
|
131
131
|
|
132
132
|
###############################################
|
133
133
|
# Helpers
|
@@ -139,7 +139,7 @@ int WideCharToMultiByte(
|
|
139
139
|
ustring = (ustring + "").force_encoding('UTF-8') if ustring.respond_to?(:force_encoding) && ustring.encoding.name != "UTF-8"
|
140
140
|
|
141
141
|
# ensure we have the double-null termination Windows Wide likes
|
142
|
-
ustring = ustring
|
142
|
+
ustring = ustring + "\000\000" if ustring[-1].chr != "\000"
|
143
143
|
|
144
144
|
# encode it all as UTF-16LE AKA Windows Wide Character AKA Windows Unicode
|
145
145
|
ustring = begin
|
data/lib/chef/win32/error.rb
CHANGED
@@ -22,10 +22,10 @@ require 'chef/win32/unicode'
|
|
22
22
|
require 'chef/exceptions'
|
23
23
|
|
24
24
|
class Chef
|
25
|
-
module Win32
|
25
|
+
module ReservedNames::Win32
|
26
26
|
class Error
|
27
|
-
include Chef::Win32::API::Error
|
28
|
-
extend Chef::Win32::API::Error
|
27
|
+
include Chef::ReservedNames::Win32::API::Error
|
28
|
+
extend Chef::ReservedNames::Win32::API::Error
|
29
29
|
|
30
30
|
def self.format_message(message_id = 0, args = {})
|
31
31
|
flags = args[:flags] || FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ARGUMENT_ARRAY
|
@@ -42,7 +42,7 @@ class Chef
|
|
42
42
|
begin
|
43
43
|
return buffer.read_pointer.read_wstring(num_chars)
|
44
44
|
ensure
|
45
|
-
Chef::Win32::Memory.local_free(buffer.read_pointer)
|
45
|
+
Chef::ReservedNames::Win32::Memory.local_free(buffer.read_pointer)
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
data/lib/chef/win32/file.rb
CHANGED
@@ -22,10 +22,10 @@ require 'chef/win32/api/security'
|
|
22
22
|
require 'chef/win32/error'
|
23
23
|
|
24
24
|
class Chef
|
25
|
-
module Win32
|
25
|
+
module ReservedNames::Win32
|
26
26
|
class File
|
27
|
-
include Chef::Win32::API::File
|
28
|
-
extend Chef::Win32::API::File
|
27
|
+
include Chef::ReservedNames::Win32::API::File
|
28
|
+
extend Chef::ReservedNames::Win32::API::File
|
29
29
|
|
30
30
|
# Creates a symbolic link called +new_name+ for the file or directory
|
31
31
|
# +old_name+.
|
@@ -40,7 +40,7 @@ class Chef
|
|
40
40
|
old_name = encode_path(old_name)
|
41
41
|
new_name = encode_path(new_name)
|
42
42
|
unless CreateHardLinkW(new_name, old_name, nil)
|
43
|
-
Chef::Win32::Error.raise!
|
43
|
+
Chef::ReservedNames::Win32::Error.raise!
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
@@ -51,14 +51,14 @@ class Chef
|
|
51
51
|
# returns nil as per MRI.
|
52
52
|
#
|
53
53
|
def self.symlink(old_name, new_name)
|
54
|
-
raise Errno::ENOENT, "(#{old_name}, #{new_name})" unless ::File.exist?(old_name)
|
54
|
+
# raise Errno::ENOENT, "(#{old_name}, #{new_name})" unless ::File.exist?(old_name)
|
55
55
|
# TODO do a check for CreateSymbolicLinkW and
|
56
56
|
# raise NotImplemented exception on older Windows
|
57
57
|
flags = ::File.directory?(old_name) ? SYMBOLIC_LINK_FLAG_DIRECTORY : 0
|
58
58
|
old_name = encode_path(old_name)
|
59
59
|
new_name = encode_path(new_name)
|
60
60
|
unless CreateSymbolicLinkW(new_name, old_name, flags)
|
61
|
-
Chef::Win32::Error.raise!
|
61
|
+
Chef::ReservedNames::Win32::Error.raise!
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
@@ -88,23 +88,73 @@ class Chef
|
|
88
88
|
# will raise a NotImplementedError, as per MRI.
|
89
89
|
#
|
90
90
|
def self.readlink(link_name)
|
91
|
-
raise Errno::ENOENT, link_name unless ::File.
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
if
|
98
|
-
Chef::Win32::Error.raise!
|
91
|
+
raise Errno::ENOENT, link_name unless ::File.exists?(link_name)
|
92
|
+
symlink_file_handle(link_name) do |handle|
|
93
|
+
# Go to DeviceIoControl to get the symlink information
|
94
|
+
# http://msdn.microsoft.com/en-us/library/windows/desktop/aa364571(v=vs.85).aspx
|
95
|
+
reparse_buffer = FFI::MemoryPointer.new(MAXIMUM_REPARSE_DATA_BUFFER_SIZE)
|
96
|
+
parsed_size = FFI::Buffer.new(:long).write_long(0)
|
97
|
+
if DeviceIoControl(handle, FSCTL_GET_REPARSE_POINT, nil, 0, reparse_buffer, MAXIMUM_REPARSE_DATA_BUFFER_SIZE, parsed_size, nil) == 0
|
98
|
+
Chef::ReservedNames::Win32::Error.raise!
|
99
99
|
end
|
100
|
-
|
100
|
+
|
101
|
+
# Ensure it's a symbolic link
|
102
|
+
reparse_buffer = REPARSE_DATA_BUFFER.new(reparse_buffer)
|
103
|
+
if reparse_buffer[:ReparseTag] != IO_REPARSE_TAG_SYMLINK
|
104
|
+
raise Errno::EACCES, "#{link_name} is not a symlink"
|
105
|
+
end
|
106
|
+
|
107
|
+
# Return the link destination (strip off \??\ at the beginning, which is a local filesystem thing)
|
108
|
+
link_dest = reparse_buffer.reparse_buffer.substitute_name
|
109
|
+
if link_dest =~ /^\\\?\?\\/
|
110
|
+
link_dest = link_dest[4..-1]
|
111
|
+
end
|
112
|
+
link_dest
|
101
113
|
end
|
102
114
|
end
|
103
115
|
|
116
|
+
# Gets the short form of a path (Administrator -> ADMINI~1)
|
117
|
+
def self.get_short_path_name(path)
|
118
|
+
path = path.to_wstring
|
119
|
+
size = GetShortPathNameW(path, nil, 0)
|
120
|
+
if size == 0
|
121
|
+
Chef::ReservedNames::Win32::Error.raise!
|
122
|
+
end
|
123
|
+
result = FFI::MemoryPointer.new :char, (size+1)*2
|
124
|
+
if GetShortPathNameW(path, result, size+1) == 0
|
125
|
+
Chef::ReservedNames::Win32::Error.raise!
|
126
|
+
end
|
127
|
+
result.read_wstring(size)
|
128
|
+
end
|
129
|
+
|
130
|
+
# Gets the long form of a path (ADMINI~1 -> Administrator)
|
131
|
+
def self.get_long_path_name(path)
|
132
|
+
path = path.to_wstring
|
133
|
+
size = GetLongPathNameW(path, nil, 0)
|
134
|
+
if size == 0
|
135
|
+
Chef::ReservedNames::Win32::Error.raise!
|
136
|
+
end
|
137
|
+
result = FFI::MemoryPointer.new :char, (size+1)*2
|
138
|
+
if GetLongPathNameW(path, result, size+1) == 0
|
139
|
+
Chef::ReservedNames::Win32::Error.raise!
|
140
|
+
end
|
141
|
+
result.read_wstring(size)
|
142
|
+
end
|
143
|
+
|
104
144
|
def self.info(file_name)
|
105
145
|
Info.new(file_name)
|
106
146
|
end
|
107
147
|
|
148
|
+
def self.verify_links_supported!
|
149
|
+
begin
|
150
|
+
CreateSymbolicLinkW(nil)
|
151
|
+
rescue Chef::Exceptions::Win32APIFunctionNotImplemented => e
|
152
|
+
raise e
|
153
|
+
rescue Exception
|
154
|
+
# things are ok.
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
108
158
|
# ::File compat
|
109
159
|
class << self
|
110
160
|
alias :stat :info
|