summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2016-10-06 10:43:50 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2016-10-06 10:43:50 -0700
commitcbc56072a96efae05df8c954762c767075bfe3b4 (patch)
treee77d28e37c08af3e8a1debbef68daed171d4b063
parent4e3c825d55b678413e8219ab13a99cfb12fedaf7 (diff)
downloadchef-lcg/manage-home-consistency.tar.gz
fix manage_home provider inconsistencylcg/manage-home-consistency
on freebsd and mac we're now telling people to use `manage_home` instead of `supports[:manage_home]` but it doesn't actually work. fixes that so that it works now. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
-rw-r--r--lib/chef/provider/user.rb10
-rw-r--r--lib/chef/provider/user/dscl.rb4
-rw-r--r--lib/chef/provider/user/linux.rb18
-rw-r--r--lib/chef/provider/user/pw.rb4
-rw-r--r--lib/chef/provider/user/useradd.rb6
5 files changed, 19 insertions, 23 deletions
diff --git a/lib/chef/provider/user.rb b/lib/chef/provider/user.rb
index 2bc4cc10bc..f6b088d333 100644
--- a/lib/chef/provider/user.rb
+++ b/lib/chef/provider/user.rb
@@ -210,6 +210,16 @@ class Chef
def check_lock
raise NotImplementedError
end
+
+ def non_unique?
+ # XXX: THIS GOES AWAY IN CHEF-13 AND BECOMES JUST new_resource.non_unique
+ new_resource.non_unique || new_resource.supports[:non_unique]
+ end
+
+ def managing_home_dir?
+ # XXX: THIS GOES AWAY IN CHEF-13 AND BECOMES JUST new_resource.manage_home
+ new_resource.manage_home || new_resource.supports[:manage_home]
+ end
end
end
end
diff --git a/lib/chef/provider/user/dscl.rb b/lib/chef/provider/user/dscl.rb
index 821fa8e8a7..01203c0d9f 100644
--- a/lib/chef/provider/user/dscl.rb
+++ b/lib/chef/provider/user/dscl.rb
@@ -292,7 +292,7 @@ user password using shadow hash.")
return
end
- if new_resource.supports[:manage_home]
+ if managing_home_dir?
validate_home_dir_specification!
if (current_resource.home == new_resource.home) && !new_home_exists?
@@ -438,7 +438,7 @@ user password using shadow hash.")
# and deleting home directory if needed.
#
def remove_user
- if new_resource.supports[:manage_home]
+ if managing_home_dir?
# Remove home directory
FileUtils.rm_rf(current_resource.home)
end
diff --git a/lib/chef/provider/user/linux.rb b/lib/chef/provider/user/linux.rb
index 4a2491d806..968cf771e4 100644
--- a/lib/chef/provider/user/linux.rb
+++ b/lib/chef/provider/user/linux.rb
@@ -52,14 +52,14 @@ class Chef
opts << "-s" << new_resource.shell if should_set?(:shell)
opts << "-u" << new_resource.uid if should_set?(:uid)
opts << "-d" << new_resource.home if updating_home?
- opts << "-o" if non_unique
+ opts << "-o" if non_unique?
opts
end
def usermod_options
opts = []
if updating_home?
- if manage_home
+ if managing_home_dir?
opts << "-m"
end
end
@@ -69,7 +69,7 @@ class Chef
def useradd_options
opts = []
opts << "-r" if new_resource.system
- if manage_home
+ if managing_home_dir?
opts << "-m"
else
opts << "-M"
@@ -79,7 +79,7 @@ class Chef
def userdel_options
opts = []
- opts << "-r" if manage_home
+ opts << "-r" if managing_home_dir?
opts << "-f" if new_resource.force
opts
end
@@ -122,16 +122,6 @@ class Chef
# FIXME: should probably go on the current_resource
@locked
end
-
- def non_unique
- # XXX: THIS GOES AWAY IN CHEF-13 AND BECOMES JUST new_resource.non_unique
- new_resource.non_unique || new_resource.supports[:non_unique]
- end
-
- def manage_home
- # XXX: THIS GOES AWAY IN CHEF-13 AND BECOMES JUST new_resource.manage_home
- new_resource.manage_home || new_resource.supports[:manage_home]
- end
end
end
end
diff --git a/lib/chef/provider/user/pw.rb b/lib/chef/provider/user/pw.rb
index a1d7671c28..b210374eb9 100644
--- a/lib/chef/provider/user/pw.rb
+++ b/lib/chef/provider/user/pw.rb
@@ -46,7 +46,7 @@ class Chef
def remove_user
command = "pw userdel #{@new_resource.username}"
- command << " -r" if @new_resource.supports[:manage_home]
+ command << " -r" if managing_home_dir?
run_command(:command => command)
end
@@ -87,7 +87,7 @@ class Chef
end
end
end
- if @new_resource.supports[:manage_home]
+ if managing_home_dir?
Chef::Log.debug("#{@new_resource} is managing the users home directory")
opts << " -m"
end
diff --git a/lib/chef/provider/user/useradd.rb b/lib/chef/provider/user/useradd.rb
index 68b62812a7..35a106b0b6 100644
--- a/lib/chef/provider/user/useradd.rb
+++ b/lib/chef/provider/user/useradd.rb
@@ -124,7 +124,7 @@ class Chef
Chef::Log.debug("#{new_resource} setting home to #{new_resource.home}")
end
end
- opts << "-o" if new_resource.non_unique
+ opts << "-o" if non_unique?
opts
end
end
@@ -154,10 +154,6 @@ class Chef
new_resource.home && Pathname.new(@current_resource.home).cleanpath != Pathname.new(new_resource.home).cleanpath
end
- def managing_home_dir?
- new_resource.manage_home || new_resource.supports[:manage_home]
- end
-
end
end
end