summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordanielsdeleo <dan@opscode.com>2012-09-07 12:31:51 -0700
committerdanielsdeleo <dan@opscode.com>2012-09-07 12:31:51 -0700
commit6bc43ba1e140ec84424ebe3f38a7599c22add3f6 (patch)
tree96824e5ad6ae3d73ccb22e95f910c0f6eb4e47b2
parent722bc99041b03aaf98c099ee46e14f724cc33018 (diff)
downloadchef-useradd-manage-home-fix.tar.gz
[TICKET NUMBER] all useradd options must come before argumentsuseradd-manage-home-fix
fixes an issue where useradd chokes on `useradd SOME_OPTS username -m`
-rw-r--r--chef/lib/chef/provider/user/useradd.rb6
-rw-r--r--chef/spec/unit/provider/user/useradd_spec.rb4
2 files changed, 6 insertions, 4 deletions
diff --git a/chef/lib/chef/provider/user/useradd.rb b/chef/lib/chef/provider/user/useradd.rb
index 3903eac203..573da62af1 100644
--- a/chef/lib/chef/provider/user/useradd.rb
+++ b/chef/lib/chef/provider/user/useradd.rb
@@ -34,8 +34,10 @@ class Chef
end
def manage_user
- command = compile_command("usermod") { |u| u << universal_options }
- command << " -m" if managing_home_dir?
+ command = compile_command("usermod") do |u|
+ u << " -m" if managing_home_dir?
+ u << universal_options
+ end
run_command(:command => command)
end
diff --git a/chef/spec/unit/provider/user/useradd_spec.rb b/chef/spec/unit/provider/user/useradd_spec.rb
index 00584d43eb..4af9f740d3 100644
--- a/chef/spec/unit/provider/user/useradd_spec.rb
+++ b/chef/spec/unit/provider/user/useradd_spec.rb
@@ -199,13 +199,13 @@ describe Chef::Provider::User::Useradd do
end
it "runs usermod with the computed command options" do
- @provider.should_receive(:run_command).with({ :command => "usermod -g '23' -d '/Users/mud' adam -m" }).and_return(true)
+ @provider.should_receive(:run_command).with({ :command => "usermod -m -g '23' -d '/Users/mud' adam" }).and_return(true)
@provider.manage_user
end
it "does not set the -r option to usermod" do
@new_resource.system(true)
- @provider.should_receive(:run_command).with({ :command => "usermod -g '23' -d '/Users/mud' adam -m" }).and_return(true)
+ @provider.should_receive(:run_command).with({ :command => "usermod -m -g '23' -d '/Users/mud' adam" }).and_return(true)
@provider.manage_user
end