summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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