diff options
author | Noah Kantrowitz <noah@coderanger.net> | 2016-10-06 10:22:17 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-06 10:22:17 +1100 |
commit | 9984b107e32cd5c4565c17e9ea8dd5bbe0da6bd7 (patch) | |
tree | fd5c50f7260bbf502f109ed14fb54b51349017fa | |
parent | 9d8fb38b27d6d2e22376e2b518d6b784c3e4e078 (diff) | |
parent | eb87f52643cd29a2ac528a0c0f3322a0b06f75cc (diff) | |
download | chef-9984b107e32cd5c4565c17e9ea8dd5bbe0da6bd7.tar.gz |
Merge pull request #5408 from coderanger/solaris-m
Fix solaris handling for useradd -m/-M behavior
-rw-r--r-- | lib/chef/provider/user/solaris.rb | 6 | ||||
-rw-r--r-- | spec/unit/provider/user/solaris_spec.rb | 10 |
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 |