summaryrefslogtreecommitdiff
path: root/lib/chef/provider/user/linux.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chef/provider/user/linux.rb')
-rw-r--r--lib/chef/provider/user/linux.rb29
1 files changed, 13 insertions, 16 deletions
diff --git a/lib/chef/provider/user/linux.rb b/lib/chef/provider/user/linux.rb
index 968cf771e4..445421ad38 100644
--- a/lib/chef/provider/user/linux.rb
+++ b/lib/chef/provider/user/linux.rb
@@ -24,23 +24,23 @@ class Chef
provides :user, os: "linux"
def create_user
- shell_out!(*clean_array("useradd", universal_options, useradd_options, new_resource.username))
+ shell_out_compact!("useradd", universal_options, useradd_options, new_resource.username)
end
def manage_user
- shell_out!(*clean_array("usermod", universal_options, usermod_options, new_resource.username))
+ shell_out_compact!("usermod", universal_options, usermod_options, new_resource.username)
end
def remove_user
- shell_out!(*clean_array("userdel", userdel_options, new_resource.username))
+ shell_out_compact!("userdel", userdel_options, new_resource.username)
end
def lock_user
- shell_out!(*clean_array("usermod", "-L", new_resource.username))
+ shell_out_compact!("usermod", "-L", new_resource.username)
end
def unlock_user
- shell_out!(*clean_array("usermod", "-U", new_resource.username))
+ shell_out_compact!("usermod", "-U", new_resource.username)
end
# common to usermod and useradd
@@ -69,11 +69,11 @@ class Chef
def useradd_options
opts = []
opts << "-r" if new_resource.system
- if managing_home_dir?
- opts << "-m"
- else
- opts << "-M"
- end
+ opts << if managing_home_dir?
+ "-m"
+ else
+ "-M"
+ end
opts
end
@@ -97,15 +97,12 @@ class Chef
def check_lock
# there's an old bug in rhel (https://bugzilla.redhat.com/show_bug.cgi?id=578534)
# which means that both 0 and 1 can be success.
- passwd_s = shell_out("passwd", "-S", new_resource.username, returns: [ 0, 1 ])
+ passwd_s = shell_out_compact("passwd", "-S", new_resource.username, returns: [ 0, 1 ])
# checking "does not exist" has to come before exit code handling since centos and ubuntu differ in exit codes
if passwd_s.stderr =~ /does not exist/
- if whyrun_mode?
- return false
- else
- raise Chef::Exceptions::User, "User #{new_resource.username} does not exist when checking lock status for #{new_resource}"
- end
+ return false if whyrun_mode?
+ raise Chef::Exceptions::User, "User #{new_resource.username} does not exist when checking lock status for #{new_resource}"
end
# now raise if we didn't get a 0 or 1 (see above)