summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoah Kantrowitz <noah@coderanger.net>2016-10-05 10:16:06 +1100
committerNoah Kantrowitz <noah@coderanger.net>2016-10-05 10:16:06 +1100
commiteb87f52643cd29a2ac528a0c0f3322a0b06f75cc (patch)
treeac00bc036fd3f339b0b258e940ea0d13ec69d2a4
parent00592d7b8ffe80896e6aef341247f980b7f49d1d (diff)
downloadchef-eb87f52643cd29a2ac528a0c0f3322a0b06f75cc.tar.gz
Fix solaris handling for -m/-M behavior. Fixes #5403.
Signed-off-by: Noah Kantrowitz <noah@coderanger.net>
-rw-r--r--lib/chef/provider/user/solaris.rb6
-rw-r--r--spec/unit/provider/user/solaris_spec.rb10
2 files changed, 13 insertions, 3 deletions
diff --git a/lib/chef/provider/user/solaris.rb b/lib/chef/provider/user/solaris.rb
index 3012fcec23..04567e6bca 100644
--- a/lib/chef/provider/user/solaris.rb
+++ b/lib/chef/provider/user/solaris.rb
@@ -74,7 +74,9 @@ class Chef
private
# Override the version from {#Useradd} because Solaris doesn't support
- # system users and therefore has no `-r` option.
+ # system users and therefore has no `-r` option. This also inverts the
+ # logic for manage_home as Solaris defaults to no-manage-home and only
+ # offers `-m`.
#
# @since 12.15
# @api private
@@ -82,7 +84,7 @@ class Chef
# @return [Array<String>]
def useradd_options
opts = []
- opts << "-M" unless managing_home_dir?
+ opts << "-m" if managing_home_dir?
opts
end
diff --git a/spec/unit/provider/user/solaris_spec.rb b/spec/unit/provider/user/solaris_spec.rb
index d6c0b886fc..8a5e654a0d 100644
--- a/spec/unit/provider/user/solaris_spec.rb
+++ b/spec/unit/provider/user/solaris_spec.rb
@@ -84,7 +84,15 @@ describe Chef::Provider::User::Solaris do
context "with a system user" do
before { new_resource.system(true) }
it "should not pass -r" do
- expect(provider).to receive(:shell_out!).with("useradd", "-M", "adam")
+ expect(provider).to receive(:shell_out!).with("useradd", "adam")
+ provider.create_user
+ end
+ end
+
+ context "with manage_home" do
+ before { new_resource.manage_home(true) }
+ it "should not pass -r" do
+ expect(provider).to receive(:shell_out!).with("useradd", "-m", "adam")
provider.create_user
end
end