From 9cbb8e9e87eeda7dd1ff3c6fe59a28d95efedad1 Mon Sep 17 00:00:00 2001 From: Martin Kangur Date: Wed, 31 Jan 2018 12:47:28 +0200 Subject: [PATCH 1/2] Update application.rb Use PG.connect instead of PGconn.connect --- lib/pg_ldap_sync/application.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pg_ldap_sync/application.rb b/lib/pg_ldap_sync/application.rb index b0136bd..3ba1ae3 100644 --- a/lib/pg_ldap_sync/application.rb +++ b/lib/pg_ldap_sync/application.rb @@ -314,7 +314,7 @@ class Application ldap_groups = uniq_names search_ldap_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_groups = uniq_names search_pg_groups From 2f24829bc53c07ffd08790e264eb35d192c14977 Mon Sep 17 00:00:00 2001 From: Martin Kangur Date: Wed, 31 Jan 2018 13:14:43 +0200 Subject: [PATCH 2/2] Use PG everywhere instead of PGconn --- lib/pg_ldap_sync/application.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pg_ldap_sync/application.rb b/lib/pg_ldap_sync/application.rb index 3ba1ae3..c984730 100644 --- a/lib/pg_ldap_sync/application.rb +++ b/lib/pg_ldap_sync/application.rb @@ -12,7 +12,7 @@ begin rescue LoadError => e begin require 'postgres' - class PGconn + class PG alias initialize_before_hash_change initialize def initialize(*args) arg = args.first @@ -149,7 +149,7 @@ class Application groups = [] res = pg_exec "SELECT rolname, oid FROM pg_roles WHERE #{pg_groups_conf[:filter]}" 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] } group = PgRole.new tuple[0], member_names log.info{ "found pg-group: #{group.name.inspect} with members: #{member_names.inspect}"}