summaryrefslogtreecommitdiff
path: root/lib/chef/provider/user
diff options
context:
space:
mode:
authorBryan McLellan <btm@opscode.com>2012-11-16 09:50:50 -0800
committerBryan McLellan <btm@opscode.com>2013-11-06 09:13:46 -0800
commit78356de11f928bd673ac9e76328092ab74049c9d (patch)
treeb995d19b68532c7dfe156cac61f52acf3ebd27e6 /lib/chef/provider/user
parentce4cb2562af999347e26fa290d2d1ddf8deafd92 (diff)
downloadchef-78356de11f928bd673ac9e76328092ab74049c9d.tar.gz
CHEF-3582: Fix #check_lock under why-run
We assume in whyrun mode that a non-existant user would be created before we attempt to lock it, so we return false from #check_lock when user does not exist and we are in why_run mode. Conflicts: chef/lib/chef/provider/user/useradd.rb
Diffstat (limited to 'lib/chef/provider/user')
-rw-r--r--lib/chef/provider/user/useradd.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/chef/provider/user/useradd.rb b/lib/chef/provider/user/useradd.rb
index 1789a4e5ff..409da10e53 100644
--- a/lib/chef/provider/user/useradd.rb
+++ b/lib/chef/provider/user/useradd.rb
@@ -57,6 +57,13 @@ class Chef
# we can get an exit code of 1 even when it's successful on
# rhel/centos (redhat bug 578534). See additional error checks below.
passwd_s = shell_out!("passwd", "-S", new_resource.username, :returns => [0,1])
+ if whyrun_mode? && passwd_s.stdout.empty? && passwd_s.stderr.match(/does not exist/)
+ # if we're in whyrun mode and the user is not yet created we assume it would be
+ return false
+ end
+
+ raise Chef::Exceptions::User, "Cannot determine if #{@new_resource} is locked!" if passwd_s.stdout.empty?
+
status_line = passwd_s.stdout.split(' ')
case status_line[1]
when /^P/