summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Cooper <josh@puppetlabs.com>2011-08-18 10:35:50 -0700
committerJosh Cooper <josh@puppetlabs.com>2011-08-22 15:07:16 -0700
commit47058abc0c5647d59b0dd21181e67dbfdd908292 (patch)
tree762271d9f93ffb9fb81553f3f7c418a19f55f026
parent2ac87905708ddbc44d212e10e34d72cad09e3271 (diff)
downloadpuppet-47058abc0c5647d59b0dd21181e67dbfdd908292.tar.gz
puppet-47058abc0c5647d59b0dd21181e67dbfdd908292.tar.xz
puppet-47058abc0c5647d59b0dd21181e67dbfdd908292.zip
(#8662) Skip user and group resources when applying settings on Windows
When running as root, puppet will generate a catalog from its settings to create the various directories, e.g. var, ssl. If mkusers is true and a setting implements owner and/or group methods, then puppet will automatically add user and group resources to the catalog (provided the user name is not root and the group names are not root or wheel). This functionality will not be supported on Windows, and so this step is skipped.
-rw-r--r--lib/puppet/util/settings.rb1
-rwxr-xr-xspec/unit/util/settings_spec.rb19
2 files changed, 20 insertions, 0 deletions
diff --git a/lib/puppet/util/settings.rb b/lib/puppet/util/settings.rb
index caaf61b7b..3039a7b0a 100644
--- a/lib/puppet/util/settings.rb
+++ b/lib/puppet/util/settings.rb
@@ -780,6 +780,7 @@ if @config.include?(:run_mode)
# Create the transportable objects for users and groups.
def add_user_resources(catalog, sections)
return unless Puppet.features.root?
+ return if Puppet.features.microsoft_windows?
return unless self[:mkusers]
@config.each do |name, setting|
diff --git a/spec/unit/util/settings_spec.rb b/spec/unit/util/settings_spec.rb
index 76f229c0f..69c117f28 100755
--- a/spec/unit/util/settings_spec.rb
+++ b/spec/unit/util/settings_spec.rb
@@ -720,9 +720,28 @@ describe Puppet::Util::Settings do
@settings.to_catalog
end
+ describe "on Microsoft Windows" do
+ before :each do
+ Puppet.features.stubs(:root?).returns true
+ Puppet.features.stubs(:microsoft_windows?).returns true
+
+ @settings.setdefaults :foo, :mkusers => [true, "e"], :user => ["suser", "doc"], :group => ["sgroup", "doc"]
+ @settings.setdefaults :other, :otherdir => {:default => "/otherdir", :desc => "a", :owner => "service", :group => "service"}
+
+ @catalog = @settings.to_catalog
+ end
+
+ it "it should not add users and groups to the catalog" do
+ @catalog.resource(:user, "suser").should be_nil
+ @catalog.resource(:group, "sgroup").should be_nil
+ end
+ end
+
describe "when adding users and groups to the catalog" do
before do
Puppet.features.stubs(:root?).returns true
+ Puppet.features.stubs(:microsoft_windows?).returns false
+
@settings.setdefaults :foo, :mkusers => [true, "e"], :user => ["suser", "doc"], :group => ["sgroup", "doc"]
@settings.setdefaults :other, :otherdir => {:default => "/otherdir", :desc => "a", :owner => "service", :group => "service"}