Merge pull request #19 from martinkangur/master

Fix compat with pg-1.0
This commit is contained in:
Lars Kanis 2018-01-31 12:35:36 +01:00 committed by GitHub
commit 0e5a997f3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -12,7 +12,7 @@ begin
rescue LoadError => e rescue LoadError => e
begin begin
require 'postgres' require 'postgres'
class PGconn class PG
alias initialize_before_hash_change initialize alias initialize_before_hash_change initialize
def initialize(*args) def initialize(*args)
arg = args.first arg = args.first
@ -149,7 +149,7 @@ class Application
groups = [] groups = []
res = pg_exec "SELECT rolname, oid FROM pg_roles WHERE #{pg_groups_conf[:filter]}" res = pg_exec "SELECT rolname, oid FROM pg_roles WHERE #{pg_groups_conf[:filter]}"
res.each do |tuple| res.each do |tuple|
res2 = pg_exec "SELECT pr.rolname FROM pg_auth_members pam JOIN pg_roles pr ON pr.oid=pam.member WHERE pam.roleid=#{PGconn.escape(tuple[1])}" res2 = pg_exec "SELECT pr.rolname FROM pg_auth_members pam JOIN pg_roles pr ON pr.oid=pam.member WHERE pam.roleid=#{PG.escape(tuple[1])}"
member_names = res2.map{|row| row[0] } member_names = res2.map{|row| row[0] }
group = PgRole.new tuple[0], member_names group = PgRole.new tuple[0], member_names
log.info{ "found pg-group: #{group.name.inspect} with members: #{member_names.inspect}"} log.info{ "found pg-group: #{group.name.inspect} with members: #{member_names.inspect}"}
@ -314,7 +314,7 @@ class Application
ldap_groups = uniq_names search_ldap_groups ldap_groups = uniq_names search_ldap_groups
# gather PGs users and groups # gather PGs users and groups
@pgconn = PGconn.connect @config[:pg_connection] @pgconn = PG.connect @config[:pg_connection]
pg_users = uniq_names search_pg_users pg_users = uniq_names search_pg_users
pg_groups = uniq_names search_pg_groups pg_groups = uniq_names search_pg_groups