From 0922c3b0217e1723e1dfc968a7c8de2860361369 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Mon, 7 Jul 2008 10:46:16 -0500 Subject: Fixed #1399 - the ldap user provider knows it can manage passwords. Signed-off-by: Luke Kanies --- lib/puppet/provider/user/ldap.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/puppet') diff --git a/lib/puppet/provider/user/ldap.rb b/lib/puppet/provider/user/ldap.rb index 0d149ac9a..57f926da8 100644 --- a/lib/puppet/provider/user/ldap.rb +++ b/lib/puppet/provider/user/ldap.rb @@ -14,6 +14,8 @@ Puppet::Type.type(:user).provide :ldap, :parent => Puppet::Provider::Ldap do confine :feature => :ldap, :false => (Puppet[:ldapuser] == "") + has_feature :manages_passwords + manages(:posixAccount, :person).at("ou=People").named_by(:uid).and.maps :name => :uid, :password => :userPassword, :comment => :cn, -- cgit From c751e4eef508ab3cf9466dcb45479fced5d3e4be Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Mon, 7 Jul 2008 14:58:28 -0500 Subject: Fixed #1272 - ldap group names will be converted to GIDs. Note that this only looks up ldap groups, at this point; if you want to set an ldap user's primary group to a local group, you have to specify the GID. Signed-off-by: Luke Kanies --- lib/puppet/provider/group/ldap.rb | 9 +++++++++ lib/puppet/provider/user/ldap.rb | 14 ++++++++++++++ 2 files changed, 23 insertions(+) (limited to 'lib/puppet') diff --git a/lib/puppet/provider/group/ldap.rb b/lib/puppet/provider/group/ldap.rb index a4870fc68..37a7e7343 100644 --- a/lib/puppet/provider/group/ldap.rb +++ b/lib/puppet/provider/group/ldap.rb @@ -36,4 +36,13 @@ Puppet::Type.type(:group).provide :ldap, :parent => Puppet::Provider::Ldap do largest + 1 end + # Convert a group name to an id. + def self.name2id(group) + return nil unless result = manager.search("cn=%s" % group) and result.length > 0 + + # Only use the first result. + group = result[0] + gid = group[:gid][0] + return gid + end end diff --git a/lib/puppet/provider/user/ldap.rb b/lib/puppet/provider/user/ldap.rb index 0d149ac9a..da1edc520 100644 --- a/lib/puppet/provider/user/ldap.rb +++ b/lib/puppet/provider/user/ldap.rb @@ -45,6 +45,15 @@ Puppet::Type.type(:user).provide :ldap, :parent => Puppet::Provider::Ldap do largest + 1 end + # Convert our gid to a group name, if necessary. + def gid=(value) + unless [Fixnum, Bignum].include?(value.class) + value = group2id(value) + end + + @property_hash[:gid] = value + end + # Find all groups this user is a member of in ldap. def groups # We want to cache the current result, so we know if we @@ -101,6 +110,11 @@ Puppet::Type.type(:user).provide :ldap, :parent => Puppet::Provider::Ldap do end end + # Convert a gropu name to an id. + def group2id(group) + Puppet::Type.type(:group).provider(:ldap).name2id(group) + end + private def group_manager -- cgit From 71f4b02f1d3fab7ad10c6961405b0e94721e4031 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Mon, 7 Jul 2008 16:34:53 -0500 Subject: Importing Sam Quigley's work to enhance gem support for sources. --- lib/puppet/provider/package/gem.rb | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'lib/puppet') diff --git a/lib/puppet/provider/package/gem.rb b/lib/puppet/provider/package/gem.rb index bb09bc5b0..277fc68cc 100755 --- a/lib/puppet/provider/package/gem.rb +++ b/lib/puppet/provider/package/gem.rb @@ -1,9 +1,12 @@ require 'puppet/provider/package' +require 'uri' # Ruby gems support. Puppet::Type.type(:package).provide :gem, :parent => Puppet::Provider::Package do - desc "Ruby Gem support. By default uses remote gems, but you can specify - the path to a local gem via ``source``." + desc "Ruby Gem support. If a URL is passed via ``source``, then that URL is used as the + remote gem repository; if a source is present but is not a valid URL, it will be + interpreted as the path to a local gem file. If source is not present at all, + the gem will be installed from the default gem repositories." has_feature :versionable @@ -65,7 +68,7 @@ Puppet::Type.type(:package).provide :gem, :parent => Puppet::Provider::Package d end def install(useversion = true) - command = ["install"] + command = [command(:gemcmd), "install"] if (! @resource.should(:ensure).is_a? Symbol) and useversion command << "-v" << @resource.should(:ensure) end @@ -73,12 +76,25 @@ Puppet::Type.type(:package).provide :gem, :parent => Puppet::Provider::Package d command << "--include-dependencies" if source = @resource[:source] - command << source + scheme = URI.parse(blah).scheme rescue nil # the URI scheme if there is one, nil otherwise + + if scheme.nil? + # no URI scheme => interpret the source as a local file + command << source + elsif scheme.downcase == "file" + command << source.path + elsif scheme.downcase == "puppet" + # we don't support puppet:// URLs (yet) + raise Puppet::Error.new("puppet:// URLs are not supported as gem sources") + else + # interpret it as a gem repository + command << "--source" << "#{source}" << @resource[:name] + end else command << @resource[:name] end - output = gemcmd(*command) + output = execute(command) # Apparently some stupid gem versions don't exit non-0 on failure if output.include?("ERROR") self.fail "Could not install: %s" % output.chomp -- cgit From 21d49578376b4adcf29e08b50cc14457bc4dcb26 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Mon, 7 Jul 2008 16:42:12 -0500 Subject: Correct whitespace Signed-off-by: Luke Kanies --- lib/puppet/provider/package/gem.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'lib/puppet') diff --git a/lib/puppet/provider/package/gem.rb b/lib/puppet/provider/package/gem.rb index 277fc68cc..373af431e 100755 --- a/lib/puppet/provider/package/gem.rb +++ b/lib/puppet/provider/package/gem.rb @@ -79,16 +79,16 @@ Puppet::Type.type(:package).provide :gem, :parent => Puppet::Provider::Package d scheme = URI.parse(blah).scheme rescue nil # the URI scheme if there is one, nil otherwise if scheme.nil? - # no URI scheme => interpret the source as a local file - command << source + # no URI scheme => interpret the source as a local file + command << source elsif scheme.downcase == "file" - command << source.path + command << source.path elsif scheme.downcase == "puppet" - # we don't support puppet:// URLs (yet) - raise Puppet::Error.new("puppet:// URLs are not supported as gem sources") + # we don't support puppet:// URLs (yet) + raise Puppet::Error.new("puppet:// URLs are not supported as gem sources") else - # interpret it as a gem repository - command << "--source" << "#{source}" << @resource[:name] + # interpret it as a gem repository + command << "--source" << "#{source}" << @resource[:name] end else command << @resource[:name] -- cgit From 667fac18cc3682374de991bb740ae834d8c17bee Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Mon, 7 Jul 2008 17:11:59 -0500 Subject: Fixed #1226 - Gems can now specify source repositories. Added tests for the bit that's changed here (and caught a couple of bugs in the original patch). This is all a modification of Sam Quigley's work. Signed-off-by: Luke Kanies --- lib/puppet/provider/package/gem.rb | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) (limited to 'lib/puppet') diff --git a/lib/puppet/provider/package/gem.rb b/lib/puppet/provider/package/gem.rb index 373af431e..133243c86 100755 --- a/lib/puppet/provider/package/gem.rb +++ b/lib/puppet/provider/package/gem.rb @@ -69,29 +69,34 @@ Puppet::Type.type(:package).provide :gem, :parent => Puppet::Provider::Package d def install(useversion = true) command = [command(:gemcmd), "install"] - if (! @resource.should(:ensure).is_a? Symbol) and useversion - command << "-v" << @resource.should(:ensure) + if (! resource[:ensure].is_a? Symbol) and useversion + command << "-v" << resource[:ensure] end # Always include dependencies command << "--include-dependencies" - if source = @resource[:source] - scheme = URI.parse(blah).scheme rescue nil # the URI scheme if there is one, nil otherwise - - if scheme.nil? + if source = resource[:source] + begin + uri = URI.parse(source) + rescue => detail + fail "Invalid source '%s': %s" % [uri, detail] + end + + case uri.scheme + when nil: # no URI scheme => interpret the source as a local file command << source - elsif scheme.downcase == "file" - command << source.path - elsif scheme.downcase == "puppet" + when /file/i + command << uri.path + when 'puppet' # we don't support puppet:// URLs (yet) raise Puppet::Error.new("puppet:// URLs are not supported as gem sources") - else + else # interpret it as a gem repository - command << "--source" << "#{source}" << @resource[:name] + command << "--source" << "#{source}" << resource[:name] end else - command << @resource[:name] + command << resource[:name] end output = execute(command) @@ -103,17 +108,17 @@ Puppet::Type.type(:package).provide :gem, :parent => Puppet::Provider::Package d def latest # This always gets the latest version available. - hash = self.class.gemlist(:justme => @resource[:name]) + hash = self.class.gemlist(:justme => resource[:name]) return hash[:ensure] end def query - self.class.gemlist(:justme => @resource[:name], :local => true) + self.class.gemlist(:justme => resource[:name], :local => true) end def uninstall - gemcmd "uninstall", "-x", "-a", @resource[:name] + gemcmd "uninstall", "-x", "-a", resource[:name] end def update -- cgit From 6ff9246e44dfd58e4e9e26047487ebb061bfc041 Mon Sep 17 00:00:00 2001 From: James Turnbull Date: Tue, 8 Jul 2008 09:03:47 +1000 Subject: Fixed #1396 - Added sha1 function from DavidS to core --- lib/puppet/parser/ast/function.rb | 2 +- lib/puppet/parser/functions.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'lib/puppet') diff --git a/lib/puppet/parser/ast/function.rb b/lib/puppet/parser/ast/function.rb index 63d7c7abf..eb36fa906 100644 --- a/lib/puppet/parser/ast/function.rb +++ b/lib/puppet/parser/ast/function.rb @@ -42,7 +42,7 @@ class Puppet::Parser::AST raise Puppet::DevError, "Invalid function type %s" % @ftype.inspect end - # Lastly, check the arity + # Lastly, check the parity end end end diff --git a/lib/puppet/parser/functions.rb b/lib/puppet/parser/functions.rb index 8decb8227..51903e919 100644 --- a/lib/puppet/parser/functions.rb +++ b/lib/puppet/parser/functions.rb @@ -317,6 +317,14 @@ module Functions end output end + + newfunction(:sha1, :type => :rvalue, + :doc => "Returns a SHA1 hash value from a provided string.") do |args| + require 'sha1' + + Digest::SHA1.hexdigest(args[0]) + end + end end -- cgit