summaryrefslogtreecommitdiff
path: root/lib/chef/provider/user
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2016-08-19 15:32:19 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2016-08-19 15:34:23 -0700
commitf769d7eba17b3f5aa9e0561126bd9f6801c1bac2 (patch)
tree801dcc6f208510b9b7329e2bfcbc2ccbc055e09d /lib/chef/provider/user
parent0447477abd41488674f609cfa59c2bdf35ed6d03 (diff)
downloadchef-f769d7eba17b3f5aa9e0561126bd9f6801c1bac2.tar.gz
user provider manage_home behavior and refactor
split out the user provider into 1:1 resources. fix the behavior of the linux user provider to implement manage_home behavior correctly. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'lib/chef/provider/user')
-rw-r--r--lib/chef/provider/user/aix.rb5
-rw-r--r--lib/chef/provider/user/dscl.rb1
-rw-r--r--lib/chef/provider/user/linux.rb33
-rw-r--r--lib/chef/provider/user/pw.rb3
-rw-r--r--lib/chef/provider/user/solaris.rb3
-rw-r--r--lib/chef/provider/user/useradd.rb9
-rw-r--r--lib/chef/provider/user/windows.rb2
7 files changed, 48 insertions, 8 deletions
diff --git a/lib/chef/provider/user/aix.rb b/lib/chef/provider/user/aix.rb
index befb6ac3fd..8ac229ae4d 100644
--- a/lib/chef/provider/user/aix.rb
+++ b/lib/chef/provider/user/aix.rb
@@ -14,11 +14,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+require "chef/provider/user/useradd"
+
class Chef
class Provider
class User
class Aix < Chef::Provider::User::Useradd
- provides :user, platform: %w{aix}
+ provides :user, os: "aix"
+ provides :aix_user
UNIVERSAL_OPTIONS = [[:comment, "-c"], [:gid, "-g"], [:shell, "-s"], [:uid, "-u"]]
diff --git a/lib/chef/provider/user/dscl.rb b/lib/chef/provider/user/dscl.rb
index e933bf9dc0..821fa8e8a7 100644
--- a/lib/chef/provider/user/dscl.rb
+++ b/lib/chef/provider/user/dscl.rb
@@ -48,6 +48,7 @@ class Chef
attr_accessor :authentication_authority
attr_accessor :password_shadow_conversion_algorithm
+ provides :dscl_user
provides :user, os: "darwin"
def define_resource_requirements
diff --git a/lib/chef/provider/user/linux.rb b/lib/chef/provider/user/linux.rb
new file mode 100644
index 0000000000..ca331311f1
--- /dev/null
+++ b/lib/chef/provider/user/linux.rb
@@ -0,0 +1,33 @@
+#
+# Copyright:: Copyright 2016, Chef Software Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+require "chef/provider/user/useradd"
+
+class Chef
+ class Provider
+ class User
+ class Linux < Chef::Provider::User::Useradd
+ # MAJOR XXX: the implementation of "linux" is the base class and all needs to be moved here
+ provides :linux_user
+ provides :user, os: "linux"
+
+ def managing_home_dir?
+ new_resource.manage_home # linux always 'supports' manage_home
+ end
+ end
+ end
+ end
+end
diff --git a/lib/chef/provider/user/pw.rb b/lib/chef/provider/user/pw.rb
index 949a21790b..a1d7671c28 100644
--- a/lib/chef/provider/user/pw.rb
+++ b/lib/chef/provider/user/pw.rb
@@ -22,7 +22,8 @@ class Chef
class Provider
class User
class Pw < Chef::Provider::User
- provides :user, platform: %w{freebsd}
+ provides :pw_user
+ provides :user, os: "freebsd"
def load_current_resource
super
diff --git a/lib/chef/provider/user/solaris.rb b/lib/chef/provider/user/solaris.rb
index 83ee8346a9..8d3df9e68b 100644
--- a/lib/chef/provider/user/solaris.rb
+++ b/lib/chef/provider/user/solaris.rb
@@ -24,7 +24,8 @@ class Chef
class Provider
class User
class Solaris < Chef::Provider::User::Useradd
- provides :user, platform: %w{omnios solaris2}
+ provides :solaris_user
+ provides :user, os: %w{omnios solaris2}
UNIVERSAL_OPTIONS = [[:comment, "-c"], [:gid, "-g"], [:shell, "-s"], [:uid, "-u"]]
attr_writer :password_file
diff --git a/lib/chef/provider/user/useradd.rb b/lib/chef/provider/user/useradd.rb
index 3fef8d3642..68b62812a7 100644
--- a/lib/chef/provider/user/useradd.rb
+++ b/lib/chef/provider/user/useradd.rb
@@ -23,7 +23,7 @@ class Chef
class Provider
class User
class Useradd < Chef::Provider::User
- provides :user
+ # MAJOR XXX: this should become the base class of all Useradd providers instead of the linux implementation
UNIVERSAL_OPTIONS = [[:comment, "-c"], [:gid, "-g"], [:password, "-p"], [:shell, "-s"], [:uid, "-u"]]
@@ -116,15 +116,15 @@ class Chef
update_options(field, option, opts)
end
if updating_home?
+ opts << "-d" << new_resource.home
if managing_home_dir?
Chef::Log.debug("#{new_resource} managing the users home directory")
- opts << "-d" << new_resource.home << "-m"
+ opts << "-m"
else
Chef::Log.debug("#{new_resource} setting home to #{new_resource.home}")
- opts << "-d" << new_resource.home
end
end
- opts << "-o" if new_resource.non_unique || new_resource.supports[:non_unique]
+ opts << "-o" if new_resource.non_unique
opts
end
end
@@ -141,6 +141,7 @@ class Chef
def useradd_options
opts = []
opts << "-r" if new_resource.system
+ opts << "-M" unless managing_home_dir?
opts
end
diff --git a/lib/chef/provider/user/windows.rb b/lib/chef/provider/user/windows.rb
index 9545b1fd59..b086a1e32b 100644
--- a/lib/chef/provider/user/windows.rb
+++ b/lib/chef/provider/user/windows.rb
@@ -26,7 +26,7 @@ class Chef
class Provider
class User
class Windows < Chef::Provider::User
-
+ provides :windows_user
provides :user, os: "windows"
def initialize(new_resource, run_context)