This is an automated email from the ASF dual-hosted git repository.
sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git
The following commit(s) were added to refs/heads/master by this push:
new 5842336e Fetch rwhosts from ldap misc file
5842336e is described below
commit 5842336e6668e1f5452cb0448e560ddab5d480ba
Author: Sebb <[email protected]>
AuthorDate: Thu Oct 3 22:01:24 2024 +0100
Fetch rwhosts from ldap misc file
---
lib/whimsy/asf/ldap.rb | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/lib/whimsy/asf/ldap.rb b/lib/whimsy/asf/ldap.rb
index 081e2a6f..0e41194b 100644
--- a/lib/whimsy/asf/ldap.rb
+++ b/lib/whimsy/asf/ldap.rb
@@ -52,6 +52,7 @@ module ASF
CONNECT_LOCK = Mutex.new
LDAP_CREDS = ASF::Config.get(:ldap_creds)
+ LDAP_MISC = '/usr/local/etc/asfldapmisc.yml'
# connect to LDAP
def self.connect(hosts = nil)
@@ -151,7 +152,26 @@ module ASF
def self.rwhosts
return @rwhosts if @rwhosts # cache the rwhosts list
rwhosts = Array(ASF::Config.get(:ldaprw)) # allow separate override for
RW LDAP
- rwhosts = hosts if rwhosts.empty? # default to RO hosts
+ if rwhosts.empty?
+ if File.exist? LDAP_MISC
+ begin
+ ldap_misc = YAML.safe_load(File.read(LDAP_MISC))
+ rwhosts = Array(ldap_misc['ldapclient_asf']['write_uri'])
+ rescue StandardError => e
+ Wunderbar.warn "Could not parse write_uri: #{e.inspect}"
+ end
+ else
+ Wunderbar.warn "Could not find #{LDAP_MISC}"
+ end
+ if rwhosts.empty? # default to RO hosts
+ rwhosts = hosts
+ Wunderbar.debug 'Using rwhosts from hosts'
+ else
+ Wunderbar.debug 'Using rwhosts from LDAP_MISC'
+ end
+ else
+ Wunderbar.debug 'Using rwhosts from Whimsy config'
+ end
raise 'Cannot determine writable LDAP URI from ldap.conf or local
config!' if rwhosts.empty?
@rwhosts = rwhosts
end