chef 14.1.12-universal-mingw32 → 14.2.0-universal-mingw32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (178) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -6
  3. data/VERSION +1 -1
  4. data/chef.gemspec +2 -3
  5. data/lib/chef/chef_fs/data_handler/data_handler_base.rb +8 -4
  6. data/lib/chef/cookbook/manifest_v0.rb +2 -2
  7. data/lib/chef/cookbook_manifest.rb +3 -2
  8. data/lib/chef/cookbook_version.rb +3 -2
  9. data/lib/chef/guard_interpreter/default_guard_interpreter.rb +2 -2
  10. data/lib/chef/http/auth_credentials.rb +5 -3
  11. data/lib/chef/http/authenticator.rb +6 -3
  12. data/lib/chef/knife.rb +3 -6
  13. data/lib/chef/knife/configure.rb +12 -8
  14. data/lib/chef/knife/raw.rb +6 -1
  15. data/lib/chef/mixin/shell_out.rb +16 -14
  16. data/lib/chef/provider/execute.rb +4 -3
  17. data/lib/chef/provider/git.rb +1 -1
  18. data/lib/chef/provider/package/dnf.rb +5 -5
  19. data/lib/chef/provider/package/windows.rb +7 -0
  20. data/lib/chef/provider/package/yum.rb +7 -7
  21. data/lib/chef/provider/service/freebsd.rb +3 -3
  22. data/lib/chef/provider/service/init.rb +5 -5
  23. data/lib/chef/provider/service/macosx.rb +5 -4
  24. data/lib/chef/provider/service/simple.rb +4 -4
  25. data/lib/chef/provider/service/systemd.rb +13 -13
  26. data/lib/chef/provider/service/upstart.rb +3 -3
  27. data/lib/chef/provider/service/windows.rb +2 -0
  28. data/lib/chef/provider/systemd_unit.rb +4 -4
  29. data/lib/chef/provider/user.rb +18 -1
  30. data/lib/chef/provider/user/aix.rb +40 -8
  31. data/lib/chef/provider/user/dscl.rb +7 -14
  32. data/lib/chef/provider/user/linux.rb +1 -11
  33. data/lib/chef/provider/user/solaris.rb +57 -26
  34. data/lib/chef/provider/user/useradd.rb +4 -1
  35. data/lib/chef/provider/windows_task.rb +1 -0
  36. data/lib/chef/providers.rb +1 -2
  37. data/lib/chef/resource/execute.rb +4 -1
  38. data/lib/chef/resource/gem_package.rb +1 -1
  39. data/lib/chef/resource/hostname.rb +1 -1
  40. data/lib/chef/resource/sysctl.rb +3 -1
  41. data/lib/chef/resource/windows_ad_join.rb +16 -3
  42. data/lib/chef/resource_inspector.rb +13 -0
  43. data/lib/chef/run_context/cookbook_compiler.rb +1 -1
  44. data/lib/chef/server_api.rb +2 -0
  45. data/lib/chef/version.rb +1 -1
  46. data/spec/functional/mixin/shell_out_spec.rb +27 -1
  47. data/spec/functional/resource/execute_spec.rb +2 -2
  48. data/spec/functional/resource/windows_task_spec.rb +1 -1
  49. data/spec/support/shared/functional/securable_resource.rb +1 -1
  50. data/spec/support/shared/unit/execute_resource.rb +1 -1
  51. data/spec/support/shared/unit/provider/useradd_based_user_provider.rb +3 -3
  52. data/spec/unit/chef_fs/data_handler/data_handler_base_spec.rb +65 -0
  53. data/spec/unit/cookbook/manifest_v0_spec.rb +1 -1
  54. data/spec/unit/cookbook_manifest_spec.rb +2 -0
  55. data/spec/unit/dsl/recipe_spec.rb +1 -5
  56. data/spec/unit/http/authenticator_spec.rb +33 -8
  57. data/spec/unit/mixin/shell_out_spec.rb +61 -1
  58. data/spec/unit/provider/apt_update_spec.rb +7 -7
  59. data/spec/unit/provider/execute_spec.rb +16 -15
  60. data/spec/unit/provider/git_spec.rb +3 -3
  61. data/spec/unit/provider/package/windows_spec.rb +12 -0
  62. data/spec/unit/provider/script_spec.rb +2 -2
  63. data/spec/unit/provider/service/arch_service_spec.rb +9 -9
  64. data/spec/unit/provider/service/freebsd_service_spec.rb +6 -6
  65. data/spec/unit/provider/service/init_service_spec.rb +11 -11
  66. data/spec/unit/provider/service/invokercd_service_spec.rb +9 -9
  67. data/spec/unit/provider/service/macosx_spec.rb +11 -11
  68. data/spec/unit/provider/service/openbsd_service_spec.rb +6 -6
  69. data/spec/unit/provider/service/simple_service_spec.rb +4 -4
  70. data/spec/unit/provider/service/systemd_service_spec.rb +16 -16
  71. data/spec/unit/provider/service/upstart_service_spec.rb +12 -12
  72. data/spec/unit/provider/service/windows_spec.rb +5 -0
  73. data/spec/unit/provider/systemd_unit_spec.rb +163 -118
  74. data/spec/unit/provider/user/dscl_spec.rb +2 -9
  75. data/spec/unit/provider/user/solaris_spec.rb +2 -2
  76. data/spec/unit/provider/zypper_repository_spec.rb +3 -3
  77. data/spec/unit/provider_spec.rb +1 -5
  78. data/spec/unit/resource/apt_package_spec.rb +14 -0
  79. data/spec/unit/resource/apt_preference_spec.rb +14 -1
  80. data/spec/unit/resource/apt_repository_spec.rb +12 -3
  81. data/spec/unit/resource/apt_update_spec.rb +9 -0
  82. data/spec/unit/resource/bash_spec.rb +8 -0
  83. data/spec/unit/resource/bff_package_spec.rb +51 -0
  84. data/spec/unit/resource/breakpoint_spec.rb +4 -4
  85. data/spec/unit/resource/build_essential_spec.rb +5 -1
  86. data/spec/unit/resource/cab_package_spec.rb +10 -0
  87. data/spec/unit/resource/chef_gem_spec.rb +14 -0
  88. data/spec/unit/resource/chef_handler_spec.rb +9 -4
  89. data/spec/unit/resource/chocolatey_package_spec.rb +15 -1
  90. data/spec/unit/resource/conditional_spec.rb +3 -3
  91. data/spec/unit/resource/cookbook_file_spec.rb +13 -2
  92. data/spec/unit/resource/cron_spec.rb +2 -7
  93. data/spec/unit/resource/csh_spec.rb +8 -0
  94. data/spec/unit/resource/directory_spec.rb +4 -9
  95. data/spec/unit/resource/dmg_package_spec.rb +8 -4
  96. data/spec/unit/resource/dnf_package_spec.rb +16 -1
  97. data/spec/unit/resource/dpkg_package_spec.rb +18 -0
  98. data/spec/unit/resource/dsc_resource_spec.rb +6 -6
  99. data/spec/unit/resource/dsc_script_spec.rb +39 -39
  100. data/spec/unit/resource/execute_spec.rb +20 -12
  101. data/spec/unit/resource/file_spec.rb +10 -10
  102. data/spec/unit/resource/freebsd_package_spec.rb +16 -0
  103. data/spec/unit/resource/gem_package_spec.rb +27 -0
  104. data/spec/unit/resource/git_spec.rb +17 -2
  105. data/spec/unit/resource/group_spec.rb +18 -17
  106. data/spec/unit/resource/homebrew_cask_spec.rb +9 -4
  107. data/spec/unit/resource/homebrew_package_spec.rb +14 -0
  108. data/spec/unit/resource/homebrew_tap_spec.rb +8 -3
  109. data/spec/unit/resource/hostname_spec.rb +10 -6
  110. data/spec/unit/resource/http_request_spec.rb +14 -0
  111. data/spec/unit/resource/ips_package_spec.rb +15 -3
  112. data/spec/unit/resource/ksh_spec.rb +8 -0
  113. data/spec/unit/resource/launchd_spec.rb +11 -5
  114. data/spec/unit/resource/link_spec.rb +6 -11
  115. data/spec/unit/resource/log_spec.rb +8 -8
  116. data/spec/unit/resource/macos_user_defaults_spec.rb +5 -1
  117. data/spec/unit/resource/macports_package_spec.rb +19 -0
  118. data/spec/unit/resource/mdadm_spec.rb +7 -3
  119. data/spec/unit/resource/mount_spec.rb +15 -18
  120. data/spec/unit/resource/msu_package_spec.rb +10 -0
  121. data/spec/unit/resource/ohai_hint_spec.rb +9 -8
  122. data/spec/unit/resource/ohai_spec.rb +11 -3
  123. data/spec/unit/resource/openbsd_package_spec.rb +14 -0
  124. data/spec/unit/resource/openssl_dhparam.rb +10 -5
  125. data/spec/unit/resource/openssl_rsa_private_key_spec.rb +10 -5
  126. data/spec/unit/resource/openssl_rsa_public_key_spec.rb +9 -5
  127. data/spec/unit/resource/osx_profile_spec.rb +7 -4
  128. data/spec/unit/resource/package_spec.rb +14 -0
  129. data/spec/unit/resource/pacman_package_spec.rb +17 -3
  130. data/spec/unit/resource/paludis_package_spec.rb +36 -0
  131. data/spec/unit/resource/perl_spec.rb +8 -0
  132. data/spec/unit/resource/portage_package_spec.rb +14 -0
  133. data/spec/unit/resource/powershell_package_spec.rb +14 -0
  134. data/spec/unit/resource/python_spec.rb +8 -0
  135. data/spec/unit/resource/reboot_spec.rb +5 -3
  136. data/spec/unit/resource/registry_key_spec.rb +12 -1
  137. data/spec/unit/resource/remote_directory_spec.rb +11 -1
  138. data/spec/unit/resource/remote_file_spec.rb +19 -0
  139. data/spec/unit/resource/rhsm_errata_level_spec.rb +7 -3
  140. data/spec/unit/resource/rhsm_errata_spec.rb +8 -4
  141. data/spec/unit/resource/rhsm_register_spec.rb +6 -1
  142. data/spec/unit/resource/rhsm_repo_spec.rb +9 -4
  143. data/spec/unit/resource/rhsm_subscription_spec.rb +9 -4
  144. data/spec/unit/resource/route_spec.rb +4 -9
  145. data/spec/unit/resource/rpm_package_spec.rb +14 -0
  146. data/spec/unit/resource/ruby_block_spec.rb +12 -8
  147. data/spec/unit/resource/ruby_spec.rb +8 -0
  148. data/spec/unit/resource/scm_spec.rb +16 -8
  149. data/spec/unit/resource/script_spec.rb +8 -0
  150. data/spec/unit/resource/service_spec.rb +15 -0
  151. data/spec/unit/resource/smartos_package_spec.rb +18 -4
  152. data/spec/unit/resource/solaris_package_spec.rb +14 -0
  153. data/spec/unit/resource/subversion_spec.rb +14 -8
  154. data/spec/unit/resource/sudo_spec.rb +11 -4
  155. data/spec/unit/resource/swap_file_spec.rb +4 -5
  156. data/spec/unit/resource/sysctl_spec.rb +8 -10
  157. data/spec/unit/resource/systemd_unit_spec.rb +14 -12
  158. data/spec/unit/resource/template_spec.rb +19 -0
  159. data/spec/unit/resource/{windows_ad_join.rb → windows_ad_join_spec.rb} +12 -6
  160. data/spec/unit/resource/windows_auto_run_spec.rb +9 -9
  161. data/spec/unit/resource/windows_env_spec.rb +8 -16
  162. data/spec/unit/resource/windows_feature.rb +27 -8
  163. data/spec/unit/resource/windows_feature_dism.rb +30 -9
  164. data/spec/unit/resource/windows_feature_powershell.rb +7 -7
  165. data/spec/unit/resource/windows_font_spec.rb +3 -4
  166. data/spec/unit/resource/windows_package_spec.rb +12 -2
  167. data/spec/unit/resource/windows_pagefile_spec.rb +12 -8
  168. data/spec/unit/resource/windows_path_spec.rb +4 -5
  169. data/spec/unit/resource/windows_printer_port_spec.rb +20 -3
  170. data/spec/unit/resource/windows_printer_spec.rb +12 -5
  171. data/spec/unit/resource/windows_service_spec.rb +24 -1
  172. data/spec/unit/resource/windows_shortcut_spec.rb +4 -5
  173. data/spec/unit/resource/yum_repository_spec.rb +48 -2
  174. data/spec/unit/resource/zypper_package_spec.rb +51 -0
  175. data/spec/unit/resource/zypper_repository_spec.rb +56 -11
  176. data/spec/unit/resource_spec.rb +1 -5
  177. metadata +21 -12
  178. data/spec/functional/resource/user/useradd_spec.rb +0 -709
@@ -83,7 +83,7 @@ class Chef
83
83
  if new_resource.start_command
84
84
  super
85
85
  else
86
- shell_out_with_systems_locale!("#{init_command} faststart")
86
+ shell_out!("#{init_command} faststart", default_env: false)
87
87
  end
88
88
  end
89
89
 
@@ -91,7 +91,7 @@ class Chef
91
91
  if new_resource.stop_command
92
92
  super
93
93
  else
94
- shell_out_with_systems_locale!("#{init_command} faststop")
94
+ shell_out!("#{init_command} faststop", default_env: false)
95
95
  end
96
96
  end
97
97
 
@@ -99,7 +99,7 @@ class Chef
99
99
  if new_resource.restart_command
100
100
  super
101
101
  elsif supports[:restart]
102
- shell_out_with_systems_locale!("#{init_command} fastrestart")
102
+ shell_out!("#{init_command} fastrestart", default_env: false)
103
103
  else
104
104
  stop_service
105
105
  sleep 1
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: AJ Christensen (<aj@hjksolutions.com>)
3
- # Copyright:: Copyright 2008-2016, Chef Software, Inc.
3
+ # Copyright:: Copyright 2008-2018, Chef Software Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -56,7 +56,7 @@ class Chef
56
56
  if @new_resource.start_command
57
57
  super
58
58
  else
59
- shell_out_with_systems_locale!("#{default_init_command} start")
59
+ shell_out!("#{default_init_command} start", default_env: false)
60
60
  end
61
61
  end
62
62
 
@@ -64,7 +64,7 @@ class Chef
64
64
  if @new_resource.stop_command
65
65
  super
66
66
  else
67
- shell_out_with_systems_locale!("#{default_init_command} stop")
67
+ shell_out!("#{default_init_command} stop", default_env: false)
68
68
  end
69
69
  end
70
70
 
@@ -72,7 +72,7 @@ class Chef
72
72
  if @new_resource.restart_command
73
73
  super
74
74
  elsif supports[:restart]
75
- shell_out_with_systems_locale!("#{default_init_command} restart")
75
+ shell_out!("#{default_init_command} restart", default_env: false)
76
76
  else
77
77
  stop_service
78
78
  sleep 1
@@ -84,7 +84,7 @@ class Chef
84
84
  if @new_resource.reload_command
85
85
  super
86
86
  elsif supports[:reload]
87
- shell_out_with_systems_locale!("#{default_init_command} reload")
87
+ shell_out!("#{default_init_command} reload", default_env: false)
88
88
  end
89
89
  end
90
90
  end
@@ -174,9 +174,9 @@ class Chef
174
174
 
175
175
  def shell_out_as_user(cmd)
176
176
  if @console_user
177
- shell_out_with_systems_locale("#{@base_user_cmd} '#{cmd}'")
177
+ shell_out("#{@base_user_cmd} '#{cmd}'", default_env: false)
178
178
  else
179
- shell_out_with_systems_locale(cmd)
179
+ shell_out(cmd, default_env: false)
180
180
 
181
181
  end
182
182
  end
@@ -224,8 +224,9 @@ class Chef
224
224
 
225
225
  # plist files can come in XML or Binary formats. this command
226
226
  # will make sure we get XML every time.
227
- plist_xml = shell_out_with_systems_locale!(
228
- "plutil -convert xml1 -o - #{@plist}"
227
+ plist_xml = shell_out!(
228
+ "plutil -convert xml1 -o - #{@plist}",
229
+ default_env: false
229
230
  ).stdout
230
231
 
231
232
  plist_doc = REXML::Document.new(plist_xml)
@@ -83,16 +83,16 @@ class Chef
83
83
  end
84
84
 
85
85
  def start_service
86
- shell_out_with_systems_locale!(@new_resource.start_command)
86
+ shell_out!(@new_resource.start_command, default_env: false)
87
87
  end
88
88
 
89
89
  def stop_service
90
- shell_out_with_systems_locale!(@new_resource.stop_command)
90
+ shell_out!(@new_resource.stop_command, default_env: false)
91
91
  end
92
92
 
93
93
  def restart_service
94
94
  if @new_resource.restart_command
95
- shell_out_with_systems_locale!(@new_resource.restart_command)
95
+ shell_out!(@new_resource.restart_command, default_env: false)
96
96
  else
97
97
  stop_service
98
98
  sleep 1
@@ -101,7 +101,7 @@ class Chef
101
101
  end
102
102
 
103
103
  def reload_service
104
- shell_out_with_systems_locale!(@new_resource.reload_command)
104
+ shell_out!(@new_resource.reload_command, default_env: false)
105
105
  end
106
106
 
107
107
  protected
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # Author:: Stephen Haynes (<sh@nomitor.com>)
3
3
  # Author:: Davide Cavalca (<dcavalca@fb.com>)
4
- # Copyright:: Copyright 2011-2016, Chef Software Inc.
4
+ # Copyright:: Copyright 2011-2018, Chef Software Inc.
5
5
  # License:: Apache License, Version 2.0
6
6
  #
7
7
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -77,7 +77,7 @@ class Chef::Provider::Service::Systemd < Chef::Provider::Service::Simple
77
77
 
78
78
  def get_systemctl_options_args
79
79
  if new_resource.user
80
- uid = Etc.getpwuid(new_resource.user).uid
80
+ uid = Etc.getpwnam(new_resource.user).uid
81
81
  options = {
82
82
  :environment => {
83
83
  "DBUS_SESSION_BUS_ADDRESS" => "unix:path=/run/user/#{uid}/bus",
@@ -101,7 +101,7 @@ class Chef::Provider::Service::Systemd < Chef::Provider::Service::Simple
101
101
  super
102
102
  else
103
103
  options, args = get_systemctl_options_args
104
- shell_out_with_systems_locale!("#{systemctl_path} #{args} start #{Shellwords.escape(new_resource.service_name)}", options)
104
+ shell_out!("#{systemctl_path} #{args} start #{Shellwords.escape(new_resource.service_name)}", default_env: false, **options)
105
105
  end
106
106
  end
107
107
  end
@@ -114,7 +114,7 @@ class Chef::Provider::Service::Systemd < Chef::Provider::Service::Simple
114
114
  super
115
115
  else
116
116
  options, args = get_systemctl_options_args
117
- shell_out_with_systems_locale!("#{systemctl_path} #{args} stop #{Shellwords.escape(new_resource.service_name)}", options)
117
+ shell_out!("#{systemctl_path} #{args} stop #{Shellwords.escape(new_resource.service_name)}", default_env: false, **options)
118
118
  end
119
119
  end
120
120
  end
@@ -124,7 +124,7 @@ class Chef::Provider::Service::Systemd < Chef::Provider::Service::Simple
124
124
  super
125
125
  else
126
126
  options, args = get_systemctl_options_args
127
- shell_out_with_systems_locale!("#{systemctl_path} #{args} restart #{Shellwords.escape(new_resource.service_name)}", options)
127
+ shell_out!("#{systemctl_path} #{args} restart #{Shellwords.escape(new_resource.service_name)}", default_env: false, **options)
128
128
  end
129
129
  end
130
130
 
@@ -134,7 +134,7 @@ class Chef::Provider::Service::Systemd < Chef::Provider::Service::Simple
134
134
  else
135
135
  if current_resource.running
136
136
  options, args = get_systemctl_options_args
137
- shell_out_with_systems_locale!("#{systemctl_path} #{args} reload #{Shellwords.escape(new_resource.service_name)}", options)
137
+ shell_out!("#{systemctl_path} #{args} reload #{Shellwords.escape(new_resource.service_name)}", default_env: false, **options)
138
138
  else
139
139
  start_service
140
140
  end
@@ -143,37 +143,37 @@ class Chef::Provider::Service::Systemd < Chef::Provider::Service::Simple
143
143
 
144
144
  def enable_service
145
145
  options, args = get_systemctl_options_args
146
- shell_out!("#{systemctl_path} #{args} enable #{Shellwords.escape(new_resource.service_name)}", options)
146
+ shell_out!("#{systemctl_path} #{args} enable #{Shellwords.escape(new_resource.service_name)}", **options)
147
147
  end
148
148
 
149
149
  def disable_service
150
150
  options, args = get_systemctl_options_args
151
- shell_out!("#{systemctl_path} #{args} disable #{Shellwords.escape(new_resource.service_name)}", options)
151
+ shell_out!("#{systemctl_path} #{args} disable #{Shellwords.escape(new_resource.service_name)}", **options)
152
152
  end
153
153
 
154
154
  def mask_service
155
155
  options, args = get_systemctl_options_args
156
- shell_out!("#{systemctl_path} #{args} mask #{Shellwords.escape(new_resource.service_name)}", options)
156
+ shell_out!("#{systemctl_path} #{args} mask #{Shellwords.escape(new_resource.service_name)}", **options)
157
157
  end
158
158
 
159
159
  def unmask_service
160
160
  options, args = get_systemctl_options_args
161
- shell_out!("#{systemctl_path} #{args} unmask #{Shellwords.escape(new_resource.service_name)}", options)
161
+ shell_out!("#{systemctl_path} #{args} unmask #{Shellwords.escape(new_resource.service_name)}", **options)
162
162
  end
163
163
 
164
164
  def is_active?
165
165
  options, args = get_systemctl_options_args
166
- shell_out("#{systemctl_path} #{args} is-active #{Shellwords.escape(new_resource.service_name)} --quiet", options).exitstatus == 0
166
+ shell_out("#{systemctl_path} #{args} is-active #{Shellwords.escape(new_resource.service_name)} --quiet", **options).exitstatus == 0
167
167
  end
168
168
 
169
169
  def is_enabled?
170
170
  options, args = get_systemctl_options_args
171
- shell_out("#{systemctl_path} #{args} is-enabled #{Shellwords.escape(new_resource.service_name)} --quiet", options).exitstatus == 0
171
+ shell_out("#{systemctl_path} #{args} is-enabled #{Shellwords.escape(new_resource.service_name)} --quiet", **options).exitstatus == 0
172
172
  end
173
173
 
174
174
  def is_masked?
175
175
  options, args = get_systemctl_options_args
176
- s = shell_out("#{systemctl_path} #{args} is-enabled #{Shellwords.escape(new_resource.service_name)}", options)
176
+ s = shell_out("#{systemctl_path} #{args} is-enabled #{Shellwords.escape(new_resource.service_name)}", **options)
177
177
  s.exitstatus != 0 && s.stdout.include?("masked")
178
178
  end
179
179
 
@@ -169,7 +169,7 @@ class Chef
169
169
  if @new_resource.start_command
170
170
  super
171
171
  else
172
- shell_out_with_systems_locale!("/sbin/start #{@job}")
172
+ shell_out!("/sbin/start #{@job}", default_env: false)
173
173
  end
174
174
  end
175
175
 
@@ -185,7 +185,7 @@ class Chef
185
185
  if @new_resource.stop_command
186
186
  super
187
187
  else
188
- shell_out_with_systems_locale!("/sbin/stop #{@job}")
188
+ shell_out!("/sbin/stop #{@job}", default_env: false)
189
189
  end
190
190
  end
191
191
 
@@ -217,7 +217,7 @@ class Chef
217
217
  super
218
218
  else
219
219
  # upstart >= 0.6.3-4 supports reload (HUP)
220
- shell_out_with_systems_locale!("/sbin/reload #{@job}")
220
+ shell_out!("/sbin/reload #{@job}", default_env: false)
221
221
  end
222
222
 
223
223
  @upstart_service_running = true
@@ -273,6 +273,8 @@ class Chef::Provider::Service::Windows < Chef::Provider::Service
273
273
  logger.trace("#{@new_resource} startup_type already #{startup_type} - nothing to do")
274
274
  end
275
275
 
276
+ converge_delayed_start
277
+
276
278
  # Avoid changing enabled from true/false for now
277
279
  @new_resource.enabled(nil)
278
280
  end
@@ -219,15 +219,15 @@ class Chef
219
219
  end
220
220
 
221
221
  def daemon_reload
222
- shell_out_with_systems_locale!("#{systemctl_path} daemon-reload")
222
+ shell_out!("#{systemctl_cmd} daemon-reload", **systemctl_opts, default_env: false)
223
223
  end
224
224
 
225
225
  def systemctl_execute!(action, unit)
226
- shell_out_with_systems_locale!("#{systemctl_cmd} #{action} #{Shellwords.escape(unit)}", systemctl_opts)
226
+ shell_out!("#{systemctl_cmd} #{action} #{Shellwords.escape(unit)}", **systemctl_opts, default_env: false)
227
227
  end
228
228
 
229
229
  def systemctl_execute(action, unit)
230
- shell_out("#{systemctl_cmd} #{action} #{Shellwords.escape(unit)}", systemctl_opts)
230
+ shell_out("#{systemctl_cmd} #{action} #{Shellwords.escape(unit)}", **systemctl_opts)
231
231
  end
232
232
 
233
233
  def systemctl_cmd
@@ -245,7 +245,7 @@ class Chef
245
245
  def systemctl_opts
246
246
  @systemctl_opts ||=
247
247
  if new_resource.user
248
- uid = Etc.getpwuid(new_resource.user).uid
248
+ uid = Etc.getpwnam(new_resource.user).uid
249
249
  {
250
250
  :user => new_resource.user,
251
251
  :environment => {
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Adam Jacob (<adam@chef.io>)
3
- # Copyright:: Copyright 2008-2017, Chef Software Inc.
3
+ # Copyright:: Copyright 2008-2018, Chef Software Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -199,6 +199,23 @@ class Chef
199
199
  def check_lock
200
200
  raise NotImplementedError
201
201
  end
202
+
203
+ private
204
+
205
+ #
206
+ # helpers for subclasses
207
+ #
208
+
209
+ def should_set?(sym)
210
+ current_resource.send(sym).to_s != new_resource.send(sym).to_s && new_resource.send(sym)
211
+ end
212
+
213
+ def updating_home?
214
+ return false if new_resource.home.nil?
215
+ return true if current_resource.home.nil?
216
+ # Pathname#cleanpath matches more edge conditions than File.expand_path()
217
+ new_resource.home && Pathname.new(current_resource.home).cleanpath != Pathname.new(new_resource.home).cleanpath
218
+ end
202
219
  end
203
220
  end
204
221
  end
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright:: Copyright 2012-2016, Chef Software Inc.
2
+ # Copyright:: Copyright 2012-2018, Chef Software Inc.
3
3
  # License:: Apache License, Version 2.0
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,35 +14,57 @@
14
14
  # See the License for the specific language governing permissions and
15
15
  # limitations under the License.
16
16
 
17
- require "chef/provider/user/useradd"
17
+ require "chef/provider/user"
18
18
 
19
19
  class Chef
20
20
  class Provider
21
21
  class User
22
- class Aix < Chef::Provider::User::Useradd
22
+ class Aix < Chef::Provider::User
23
23
  provides :user, os: "aix"
24
24
  provides :aix_user
25
25
 
26
- UNIVERSAL_OPTIONS = [[:comment, "-c"], [:gid, "-g"], [:shell, "-s"], [:uid, "-u"]].freeze
27
-
28
26
  def create_user
29
- super
27
+ shell_out_compact!("useradd", universal_options, useradd_options, new_resource.username)
30
28
  add_password
31
29
  end
32
30
 
33
31
  def manage_user
34
32
  add_password
35
33
  manage_home
36
- super
34
+ return if universal_options.empty? && usermod_options.empty?
35
+ shell_out_compact!("usermod", universal_options, usermod_options, new_resource.username)
36
+ end
37
+
38
+ def remove_user
39
+ shell_out_compact!("userdel", userdel_options, new_resource.username)
37
40
  end
38
41
 
39
42
  # Aix does not support -r like other unix, sytem account is created by adding to 'system' group
40
43
  def useradd_options
41
44
  opts = []
42
45
  opts << "-g" << "system" if new_resource.system
46
+ if updating_home?
47
+ if new_resource.manage_home
48
+ logger.trace("#{new_resource} managing the users home directory")
49
+ opts << "-m"
50
+ else
51
+ logger.trace("#{new_resource} setting home to #{new_resource.home}")
52
+ end
53
+ end
54
+ opts
55
+ end
56
+
57
+ def userdel_options
58
+ opts = []
59
+ opts << "-r" if new_resource.manage_home
60
+ opts << "-f" if new_resource.force
43
61
  opts
44
62
  end
45
63
 
64
+ def usermod_options
65
+ []
66
+ end
67
+
46
68
  def check_lock
47
69
  lock_info = shell_out_compact!("lsuser", "-a", "account_locked", new_resource.username)
48
70
  if whyrun_mode? && passwd_s.stdout.empty? && lock_info.stderr.match(/does not exist/)
@@ -70,6 +92,17 @@ class Chef
70
92
  shell_out_compact!("chuser", "account_locked=false", new_resource.username)
71
93
  end
72
94
 
95
+ def universal_options
96
+ opts = []
97
+ opts << "-c" << new_resource.comment if should_set?(:comment)
98
+ opts << "-g" << new_resource.gid if should_set?(:gid)
99
+ opts << "-s" << new_resource.shell if should_set?(:shell)
100
+ opts << "-u" << new_resource.uid if should_set?(:uid)
101
+ opts << "-d" << new_resource.home if updating_home?
102
+ opts << "-o" if new_resource.non_unique
103
+ opts
104
+ end
105
+
73
106
  private
74
107
 
75
108
  def add_password
@@ -83,7 +116,6 @@ class Chef
83
116
  def manage_home
84
117
  return unless updating_home? && new_resource.manage_home
85
118
  # -m option does not work on aix, so move dir.
86
- universal_options.delete("-m")
87
119
  if ::File.directory?(current_resource.home)
88
120
  logger.trace("Changing users home directory from #{current_resource.home} to #{new_resource.home}")
89
121
  FileUtils.mv current_resource.home, new_resource.home
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Dreamcat4 (<dreamcat4@gmail.com>)
3
- # Copyright:: Copyright 2009-2017, Chef Software Inc.
3
+ # Copyright:: Copyright 2009-2018, Chef Software Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -214,7 +214,7 @@ user password using shadow hash.")
214
214
  #
215
215
  # Sets the user id for the user using dscl.
216
216
  # If a `uid` is not specified, it finds the next available one starting
217
- # from 200 if `system` is set, 500 otherwise.
217
+ # from 200 if `system` is set, 501 otherwise.
218
218
  #
219
219
  def dscl_set_uid
220
220
  # XXX: mutates the new resource
@@ -229,11 +229,11 @@ user password using shadow hash.")
229
229
 
230
230
  #
231
231
  # Find the next available uid on the system. starting with 200 if `system` is set,
232
- # 500 otherwise.
232
+ # 501 otherwise.
233
233
  #
234
234
  def get_free_uid(search_limit = 1000)
235
235
  uid = nil
236
- base_uid = new_resource.system ? 200 : 500
236
+ base_uid = new_resource.system ? 200 : 501
237
237
  next_uid_guess = base_uid
238
238
  users_uids = run_dscl("list", "/Users", "uid")
239
239
  while next_uid_guess < search_limit + base_uid
@@ -326,10 +326,7 @@ user password using shadow hash.")
326
326
  end
327
327
 
328
328
  def ditto_home
329
- skel = "/System/Library/User Template/English.lproj"
330
- raise(Chef::Exceptions::User, "can't find skel at: #{skel}") unless ::File.exist?(skel)
331
- shell_out_compact!("ditto", skel, new_resource.home)
332
- ::FileUtils.chown_R(new_resource.username, new_resource.gid.to_s, new_resource.home)
329
+ shell_out_compact!("/usr/sbin/createhomedir", "-c", "-u", "#{new_resource.username}")
333
330
  end
334
331
 
335
332
  def move_home
@@ -657,9 +654,7 @@ user password using shadow hash.")
657
654
  end
658
655
 
659
656
  def run_dscl(*args)
660
- argdup = args.dup
661
- cmd = argdup.shift
662
- result = shell_out_compact("dscl", ".", "-#{cmd}", argdup)
657
+ result = shell_out_compact("dscl", ".", "-#{args[0]}", args[1..-1])
663
658
  return "" if ( args.first =~ /^delete/ ) && ( result.exitstatus != 0 )
664
659
  raise(Chef::Exceptions::DsclCommandFailed, "dscl error: #{result.inspect}") unless result.exitstatus == 0
665
660
  raise(Chef::Exceptions::DsclCommandFailed, "dscl error: #{result.inspect}") if result.stdout =~ /No such key: /
@@ -667,9 +662,7 @@ user password using shadow hash.")
667
662
  end
668
663
 
669
664
  def run_plutil(*args)
670
- argdup = args.dup
671
- cmd = argdup.shift
672
- result = shell_out_compact("plutil", "-#{cmd}", argdup)
665
+ result = shell_out_compact("plutil", "-#{args[0]}", args[1..-1])
673
666
  raise(Chef::Exceptions::PlistUtilCommandFailed, "plutil error: #{result.inspect}") unless result.exitstatus == 0
674
667
  if result.stdout.encoding == Encoding::ASCII_8BIT
675
668
  result.stdout.encode("utf-8", "binary", undef: :replace, invalid: :replace, replace: "?")