summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Wolfe <jes5199@gmail.com>2010-10-18 12:01:29 -0700
committerJesse Wolfe <jes5199@gmail.com>2010-10-18 12:01:29 -0700
commit19ae3dffa4e52e752149ce90ebf83f9055c2313b (patch)
treef5cf31b9d5c45a199dbb9795482efb08e3c8afb7
parent2d13fdaac56bd5cd57444cc4447081649e18f487 (diff)
parente3fc5b95d133aee1ae3dc188e6c47e88786dfc6e (diff)
downloadpuppet-19ae3dffa4e52e752149ce90ebf83f9055c2313b.tar.gz
puppet-19ae3dffa4e52e752149ce90ebf83f9055c2313b.tar.xz
puppet-19ae3dffa4e52e752149ce90ebf83f9055c2313b.zip
Merge commit '2.6.3rc1' into next
-rw-r--r--CHANGELOG7
-rw-r--r--lib/puppet.rb2
-rw-r--r--lib/puppet/external/pson/pure/generator.rb17
-rw-r--r--lib/puppet/provider/nameservice.rb4
-rw-r--r--lib/puppet/provider/user/user_role_add.rb10
-rw-r--r--lib/puppet/provider/user/useradd.rb11
-rw-r--r--spec/unit/provider/user/user_role_add_spec.rb2
-rwxr-xr-xspec/unit/provider/user/useradd_spec.rb42
-rwxr-xr-xspec/unit/util/pson_spec.rb (renamed from spec/unit/util/json_spec.rb)17
9 files changed, 87 insertions, 25 deletions
diff --git a/CHANGELOG b/CHANGELOG
index f0c596ee5..1a28fd8e6 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,5 +1,12 @@
+2.6.3rc1
+========
+3c56705 Fix for #4832 -- Making PSON handle arbitrary binary data
+e232770 Minimal fix for #4975 -- only call chage when managing password age rules
+a090e86 Fix for #4963 -- Use correct commands for password expiry on solaris
+
2.6.2
=====
+295c3be Updated CHANGELOG for 2.6.2
1d719be Fix for #4945 -- explicitly check os to supress man page installation
55417bc Reversion of 021d534482dd8edb863cb77d668ac3525362a0a6
a6e2bea Fixed #4919 - added parenths to fix error message:
diff --git a/lib/puppet.rb b/lib/puppet.rb
index 0a90cf50c..78fb5138b 100644
--- a/lib/puppet.rb
+++ b/lib/puppet.rb
@@ -24,7 +24,7 @@ require 'puppet/util/run_mode'
# it's also a place to find top-level commands like 'debug'
module Puppet
- PUPPETVERSION = '2.6.2'
+ PUPPETVERSION = '2.6.3'
def Puppet.version
PUPPETVERSION
diff --git a/lib/puppet/external/pson/pure/generator.rb b/lib/puppet/external/pson/pure/generator.rb
index ef8b36d31..4180be57d 100644
--- a/lib/puppet/external/pson/pure/generator.rb
+++ b/lib/puppet/external/pson/pure/generator.rb
@@ -63,22 +63,15 @@ module PSON
end
else
def utf8_to_pson(string) # :nodoc:
- string = string.gsub(/["\\\x0-\x1f]/) { MAP[$MATCH] }
- string.gsub!(/(
- (?:
+ string.
+ gsub(/["\\\x0-\x1f]/n) { MAP[$MATCH] }.
+ gsub(/((?:
[\xc2-\xdf][\x80-\xbf] |
[\xe0-\xef][\x80-\xbf]{2} |
[\xf0-\xf4][\x80-\xbf]{3}
- )+ |
- [\x80-\xc1\xf5-\xff] # invalid
- )/nx) { |c|
- c.size == 1 and raise GeneratorError, "invalid utf8 byte: '#{c}'"
- s = PSON::UTF8toUTF16.iconv(c).unpack('H*')[0]
- s.gsub!(/.{4}/n, '\\\\u\&')
+ )+)/nx) { |c|
+ PSON::UTF8toUTF16.iconv(c).unpack('H*')[0].gsub(/.{4}/n, '\\\\u\&')
}
- string
- rescue Iconv::Failure => e
- raise GeneratorError, "Caught #{e.class}: #{e}"
end
end
module_function :utf8_to_pson
diff --git a/lib/puppet/provider/nameservice.rb b/lib/puppet/provider/nameservice.rb
index 9830fab54..d57052bd9 100644
--- a/lib/puppet/provider/nameservice.rb
+++ b/lib/puppet/provider/nameservice.rb
@@ -165,7 +165,9 @@ class Puppet::Provider::NameService < Puppet::Provider
begin
execute(self.addcmd)
- execute(self.passcmd) if self.feature? :manages_password_age
+ if feature?(:manages_password_age) && (cmd = passcmd)
+ execute(cmd)
+ end
rescue Puppet::ExecutionFailure => detail
raise Puppet::Error, "Could not create #{@resource.class.name} #{@resource.name}: #{detail}"
end
diff --git a/lib/puppet/provider/user/user_role_add.rb b/lib/puppet/provider/user/user_role_add.rb
index 7e7ad78e5..caca1ef88 100644
--- a/lib/puppet/provider/user/user_role_add.rb
+++ b/lib/puppet/provider/user/user_role_add.rb
@@ -6,15 +6,15 @@ Puppet::Type.type(:user).provide :user_role_add, :parent => :useradd, :source =>
defaultfor :operatingsystem => :solaris
- commands :add => "useradd", :delete => "userdel", :modify => "usermod", :password => "chage", :role_add => "roleadd", :role_delete => "roledel", :role_modify => "rolemod"
+ commands :add => "useradd", :delete => "userdel", :modify => "usermod", :password => "passwd", :role_add => "roleadd", :role_delete => "roledel", :role_modify => "rolemod"
options :home, :flag => "-d", :method => :dir
options :comment, :method => :gecos
options :groups, :flag => "-G"
options :roles, :flag => "-R"
options :auths, :flag => "-A"
options :profiles, :flag => "-P"
- options :password_min_age, :flag => "-m"
- options :password_max_age, :flag => "-M"
+ options :password_min_age, :flag => "-n"
+ options :password_max_age, :flag => "-x"
verify :gid, "GID must be an integer" do |value|
value.is_a? Integer
@@ -81,7 +81,9 @@ Puppet::Type.type(:user).provide :user_role_add, :parent => :useradd, :source =>
run(transition("normal"), "transition role to")
else
run(addcmd, "create")
- run(passcmd, "change password policy for")
+ if cmd = passcmd
+ run(cmd, "change password policy for")
+ end
end
# added to handle case when password is specified
self.password = @resource[:password] if @resource[:password]
diff --git a/lib/puppet/provider/user/useradd.rb b/lib/puppet/provider/user/useradd.rb
index 9a62db464..5a163f35a 100644
--- a/lib/puppet/provider/user/useradd.rb
+++ b/lib/puppet/provider/user/useradd.rb
@@ -70,13 +70,12 @@ Puppet::Type.type(:user).provide :useradd, :parent => Puppet::Provider::NameServ
end
def passcmd
- cmd = [command(:password)]
- [:password_min_age, :password_max_age].each do |property|
- if value = @resource.should(property)
- cmd << flag(property) << value
- end
+ age_limits = [:password_min_age, :password_max_age].select { |property| @resource.should(property) }
+ if age_limits.empty?
+ nil
+ else
+ [command(:password),age_limits.collect { |property| [flag(property), @resource.should(property)]}, @resource[:name]].flatten
end
- cmd << @resource[:name]
end
def min_age
diff --git a/spec/unit/provider/user/user_role_add_spec.rb b/spec/unit/provider/user/user_role_add_spec.rb
index b3244f19d..9cf649267 100644
--- a/spec/unit/provider/user/user_role_add_spec.rb
+++ b/spec/unit/provider/user/user_role_add_spec.rb
@@ -72,7 +72,7 @@ describe provider_class do
@provider = provider_class.new(@resource)
@provider.stubs(:user_attributes)
@provider.stubs(:execute)
- @provider.expects(:execute).with { |cmd, *args| args == ["-m", 5, "-M", 10, "myuser"] }
+ @provider.expects(:execute).with { |cmd, *args| args == ["-n", 5, "-x", 10, "myuser"] }
@provider.create
end
end
diff --git a/spec/unit/provider/user/useradd_spec.rb b/spec/unit/provider/user/useradd_spec.rb
index 26367c584..9ebba596c 100755
--- a/spec/unit/provider/user/useradd_spec.rb
+++ b/spec/unit/provider/user/useradd_spec.rb
@@ -131,4 +131,46 @@ describe provider_class do
@provider.addcmd.must == ["useradd", "-G", "somegroup", "-o", "-m", "someuser"]
end
end
+
+ describe "when calling passcmd" do
+ before do
+ @resource.stubs(:allowdupe?).returns true
+ @resource.stubs(:managehome?).returns true
+ end
+
+ it "should call command with :pass" do
+ @provider.expects(:command).with(:password)
+ @provider.passcmd
+ end
+
+ it "should return nil if neither min nor max is set" do
+ @resource.stubs(:should).with(:password_min_age).returns nil
+ @resource.stubs(:should).with(:password_max_age).returns nil
+ @provider.passcmd.must == nil
+ end
+
+ it "should return a chage command array with -m <value> and the user name if password_min_age is set" do
+ @provider.stubs(:command).with(:password).returns("chage")
+ @resource.stubs(:[]).with(:name).returns("someuser")
+ @resource.stubs(:should).with(:password_min_age).returns 123
+ @resource.stubs(:should).with(:password_max_age).returns nil
+ @provider.passcmd.must == ['chage','-m',123,'someuser']
+ end
+
+ it "should return a chage command array with -M <value> if password_max_age is set" do
+ @provider.stubs(:command).with(:password).returns("chage")
+ @resource.stubs(:[]).with(:name).returns("someuser")
+ @resource.stubs(:should).with(:password_min_age).returns nil
+ @resource.stubs(:should).with(:password_max_age).returns 999
+ @provider.passcmd.must == ['chage','-M',999,'someuser']
+ end
+
+ it "should return a chage command array with -M <value> -m <value> if both password_min_age and password_max_age are set" do
+ @provider.stubs(:command).with(:password).returns("chage")
+ @resource.stubs(:[]).with(:name).returns("someuser")
+ @resource.stubs(:should).with(:password_min_age).returns 123
+ @resource.stubs(:should).with(:password_max_age).returns 999
+ @provider.passcmd.must == ['chage','-m',123,'-M',999,'someuser']
+ end
+ end
end
diff --git a/spec/unit/util/json_spec.rb b/spec/unit/util/pson_spec.rb
index 4f6cea997..d02d28517 100755
--- a/spec/unit/util/json_spec.rb
+++ b/spec/unit/util/pson_spec.rb
@@ -18,4 +18,21 @@ describe Puppet::Util::Pson do
pson.expects(:from_pson).with("mydata")
pson.pson_create("type" => "foo", "data" => "mydata")
end
+
+
+ {
+ 'foo' => '"foo"',
+ 1 => '1',
+ "\x80" => "\"\x80\"",
+ [] => '[]'
+ }.each { |str,pson|
+ it "should be able to encode #{str.inspect}" do
+ str.to_pson.should == pson
+ end
+ }
+
+ it "should be able to handle arbitrary binary data" do
+ bin_string = (1..20000).collect { |i| ((17*i+13*i*i) % 255).chr }.join
+ PSON.parse(%Q{{ "type": "foo", "data": #{bin_string.to_pson} }})["data"].should == bin_string
+ end
end