--- a/components/puppet/files/solaris/lib/puppet/provider/ldap/solaris.rb Thu Jan 09 03:35:51 2014 -0800
+++ b/components/puppet/files/solaris/lib/puppet/provider/ldap/solaris.rb Fri Jan 31 14:12:10 2014 -0700
@@ -20,7 +20,7 @@
#
#
-# Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
#
Puppet::Type.type(:ldap).provide(:ldap) do
@@ -29,8 +29,12 @@
defaultfor :osfamily => :solaris, :kernelrelease => ['5.11', '5.12']
commands :svccfg => '/usr/sbin/svccfg', :svcprop => '/usr/bin/svcprop'
- class << self; attr_accessor :ldap_fmri end
- @@ldap_fmri = "svc:/network/ldap/client"
+ Ldap_fmri = "svc:/network/ldap/client"
+
+ def initialize(resource)
+ super
+ @refresh_needed = false
+ end
def self.instances
if Process.euid != 0
@@ -39,7 +43,7 @@
props = {}
validprops = Puppet::Type.type(:ldap).validproperties
- svcprop("-p", "config", @@ldap_fmri).split("\n").collect do |line|
+ svcprop("-p", "config", Ldap_fmri).each_line.collect do |line|
data = line.split()
fullprop = data[0]
type = data[1]
@@ -50,16 +54,15 @@
end
pg, prop = fullprop.split("/")
+ props[prop] = value if validprops.include? prop.to_sym
+ end
+ begin
+ props[:bind_passwd] = svcprop("-p", "cred/bind_passwd",
+ "svc:/network/ldap/client").strip
+ rescue
+ end
- # handle the domainname differently as it's not in validprops
- if prop == "profile"
- props[:name] = value
- else
- props[prop] = value if validprops.include? prop.to_sym
- end
- end
- props[:bind_passwd] = svcprop("-p", "cred/bind_passwd",
- "svc:/network/ldap/client").strip
+ props[:name] = "current"
return Array new(props)
end
@@ -68,7 +71,7 @@
pg = Puppet::Type.type(:ldap).propertybyname(field).pg
define_method(field) do
begin
- svcprop("-p", pg + "/" + field.to_s, @@ldap_fmri).strip()
+ svcprop("-p", pg + "/" + field.to_s, Ldap_fmri).strip()
rescue
# if the property isn't set, don't raise an error
nil
@@ -80,24 +83,39 @@
if should.is_a? Array
should.collect! { |value| value.to_s }
- # the first entry needs the open paren and the last entry
- # needs the close paren
- should[0] = "(" + should[0]
- should[-1] = should[-1] + ")"
-
- svccfg("-s", @@ldap_fmri, "setprop",
- pg + "/" + field.to_s, "=", should)
+ # in Solaris 11, the list of values needs to be single
+ # argument to svccfg.
+ values = ""
+ for entry in should
+ values += "\"#{entry}\" "
+ end
+ values = "(" + values + ")"
+ svccfg("-s", Ldap_fmri, "setprop",
+ pg + "/" + field.to_s, "=", values)
else
- svccfg("-s", @@ldap_fmri, "setprop",
- pg + "/" + field.to_s, "=", should.to_s)
+ # Puppet seems to get confused about when to pass an empty
+ # string or "\"\"". Catch either condition to handle
+ # passing values to SMF correctly
+ if should.to_s.empty? or should.to_s == '""'
+ value = should.to_s
+ else
+ value = "\"" + should.to_s + "\""
+ end
+ svccfg("-s", Ldap_fmri, "setprop",
+ pg + "/" + field.to_s, "=", value)
end
- svccfg("-s", @@ldap_fmri, "refresh")
+ @refresh_needed = true
rescue => detail
raise Puppet::Error,
"Unable to set #{field.to_s} to #{should.inspect}\n"
"#{detail}\n"
end
end
+ end
+ def flush
+ if @refresh_needed == true
+ svccfg("-s", Ldap_fmri, "refresh")
+ end
end
end