]> gitweb.michael.orlitzky.com - mailshears.git/commitdiff
mailshears.gemspec: update the version to 0.0.5. master 0.0.5
authorMichael Orlitzky <michael@orlitzky.com>
Thu, 9 Jun 2022 11:47:19 +0000 (07:47 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Thu, 9 Jun 2022 11:47:19 +0000 (07:47 -0400)
18 files changed:
doc/mailshears.example.conf.yml
doc/man1/mailshears.1
lib/common/agendav_plugin.rb
lib/common/configuration.rb
lib/common/davical_plugin.rb
lib/common/postfixadmin_plugin.rb
lib/common/roundcube_plugin.rb
lib/mv/plugins/agendav.rb
lib/mv/plugins/davical.rb
lib/mv/plugins/postfixadmin.rb
lib/mv/plugins/roundcube.rb
lib/rm/plugins/agendav.rb
lib/rm/plugins/davical.rb
lib/rm/plugins/postfixadmin.rb
lib/rm/plugins/roundcube.rb
mailshears.gemspec
test/mailshears.test.conf.yml
test/mailshears_test.rb

index 0764153c71cdbb7d9ed415990117c13d54af77c3..db516a00e6d20e45674f098cb61e06f10c4bc0cb 100644 (file)
@@ -4,7 +4,6 @@ plugins: [agendav, davical, dovecot, postfixadmin, roundcube]
 agendav_dbhost: localhost
 agendav_dbport: 5432
 agendav_dbopts:
-agendav_dbtty:
 agendav_dbuser: postgres
 agendav_dbpass:
 agendav_dbname: agendav
@@ -12,7 +11,6 @@ agendav_dbname: agendav
 davical_dbhost: localhost
 davical_dbport: 5432
 davical_dbopts:
-davical_dbtty:
 davical_dbuser: postgres
 davical_dbpass:
 davical_dbname: davical
@@ -22,7 +20,6 @@ dovecot_mail_root: /var/spool/mail/vhosts
 postfixadmin_dbhost: localhost
 postfixadmin_dbport: 5432
 postfixadmin_dbopts:
-postfixadmin_dbtty:
 postfixadmin_dbuser: postgres
 postfixadmin_dbpass:
 postfixadmin_dbname: postfixadmin
@@ -30,7 +27,6 @@ postfixadmin_dbname: postfixadmin
 roundcube_dbhost: localhost
 roundcube_dbport: 5432
 roundcube_dbopts:
-roundcube_dbtty:
 roundcube_dbuser: postgres
 roundcube_dbpass:
 roundcube_dbname: roundcube
index 286e5e0e3cb3fbb854037ac9f9cae4e4f43b5dba..7efe08f7a82de015abf8e391de3d8ee9a6de1e45 100644 (file)
@@ -165,9 +165,6 @@ on. Their meanings should be self-explanatory.
 \fI<plugin>_dbopts\fR (default: empty)
 \#
 .IP \(bu
-\fI<plugin>_dbtty\fR (default: empty)
-\#
-.IP \(bu
 \fI<plugin>_dbuser\fR (default: 'postgres')
 \#
 .IP \(bu
index d8ef6d60c8445fab529bf4560cae4c578904ff3c..187df6e92a695a85aba3091bded527a8ac751038 100644 (file)
@@ -18,7 +18,6 @@ module AgendavPlugin
       :host     => cfg.agendav_dbhost,
       :port     => cfg.agendav_dbport,
       :options  => cfg.agendav_dbopts,
-      :tty      => cfg.agendav_dbtty,
       :dbname   => cfg.agendav_dbname,
       :user     => cfg.agendav_dbuser,
       :password => cfg.agendav_dbpass }
@@ -42,7 +41,7 @@ module AgendavPlugin
     sql_query  = 'SELECT username FROM prefs;'
 
     begin
-      connection.query(sql_query) do |result|
+      connection.sync_exec(sql_query) do |result|
         users = result.field_values('username')
       end
     ensure
@@ -65,7 +64,7 @@ module AgendavPlugin
 
     sql_query  = 'SELECT count(*) FROM shares;'
     begin
-      connection.query(sql_query) do |result|
+      connection.sync_exec(sql_query) do |result|
         count = result.getvalue(0,0).to_i()
       end
     ensure
index 02c30d252b796073587ee961011a02ccbebb1936..738dc8c32c9180ebf835618ae893b8cff3dc96d5 100644 (file)
@@ -79,7 +79,6 @@ class Configuration
     d['agendav_dbhost'] = 'localhost'
     d['agendav_dbport'] = 5432
     d['agendav_dbopts'] = ''
-    d['agendav_dbtty'] = ''
     d['agendav_dbuser'] = 'postgres'
     d['agendav_dbpass'] = ''
     d['agendav_dbname'] = 'agendav'
@@ -87,7 +86,6 @@ class Configuration
     d['davical_dbhost'] = 'localhost'
     d['davical_dbport'] = 5432
     d['davical_dbopts'] = ''
-    d['davical_dbtty'] = ''
     d['davical_dbuser'] = 'postgres'
     d['davical_dbpass'] = ''
     d['davical_dbname'] = 'davical'
@@ -97,7 +95,6 @@ class Configuration
     d['postfixadmin_dbhost'] = 'localhost'
     d['postfixadmin_dbport'] = 5432
     d['postfixadmin_dbopts'] = ''
-    d['postfixadmin_dbtty'] = ''
     d['postfixadmin_dbuser'] = 'postgres'
     d['postfixadmin_dbpass'] = ''
     d['postfixadmin_dbname'] = 'postfixadmin'
@@ -105,7 +102,6 @@ class Configuration
     d['roundcube_dbhost'] = 'localhost'
     d['roundcube_dbport'] = 5432
     d['roundcube_dbopts'] = ''
-    d['roundcube_dbtty'] = ''
     d['roundcube_dbuser'] = 'postgres'
     d['roundcube_dbpass'] = ''
     d['roundcube_dbname'] = 'roundcube'
index ba09770deee3eff9d8483f76d70e23a5f99dfb2e..2298a8e1fd18a5ff715cf54af843e2f84f3ac72d 100644 (file)
@@ -18,7 +18,6 @@ module DavicalPlugin
       :host     => cfg.davical_dbhost,
       :port     => cfg.davical_dbport,
       :options  => cfg.davical_dbopts,
-      :tty      => cfg.davical_dbtty,
       :dbname   => cfg.davical_dbname,
       :user     => cfg.davical_dbuser,
       :password => cfg.davical_dbpass }
@@ -55,7 +54,7 @@ module DavicalPlugin
     sql_query = 'SELECT username FROM usr WHERE user_no > 1;'
 
     begin
-      connection.query(sql_query) do |result|
+      connection.sync_exec(sql_query) do |result|
         usernames = result.field_values('username')
       end
     ensure
@@ -88,7 +87,7 @@ module DavicalPlugin
     sql_query += 'WHERE usr.username = $1;'
 
     begin
-      connection.query(sql_query, [user.to_s()]) do |result|
+      connection.sync_exec_params(sql_query, [user.to_s()]) do |result|
         if result.num_tuples > 0
           principal_id = result[0]['principal_id']
         end
index 08fca7d32efe77d488328f4ff41e4a7c1e0eaaf5..b4c9030cc9b0829785fd2c08c8b5196914e6767a 100644 (file)
@@ -20,7 +20,6 @@ module PostfixadminPlugin
       :host     => cfg.postfixadmin_dbhost,
       :port     => cfg.postfixadmin_dbport,
       :options  => cfg.postfixadmin_dbopts,
-      :tty      => cfg.postfixadmin_dbtty,
       :dbname   => cfg.postfixadmin_dbname,
       :user     => cfg.postfixadmin_dbuser,
       :password => cfg.postfixadmin_dbpass }
@@ -43,7 +42,7 @@ module PostfixadminPlugin
     sql_query = "SELECT domain FROM domain WHERE domain <> 'ALL';"
 
     begin
-      connection.query(sql_query) do |result|
+      connection.sync_exec(sql_query) do |result|
         domains = result.field_values('domain')
       end
     ensure
@@ -68,7 +67,7 @@ module PostfixadminPlugin
     sql_query = 'SELECT username FROM mailbox;'
 
     begin
-      connection.query(sql_query) do |result|
+      connection.sync_exec(sql_query) do |result|
         users = result.field_values('username')
       end
     ensure
@@ -104,7 +103,7 @@ module PostfixadminPlugin
     begin
       # Now replace each Domain with its string representation and pass
       # those in as our individual parameters.
-      connection.query(sql_query, domains.map{ |d| d.to_s() }) do |result|
+      connection.sync_exec_params(sql_query, domains.map{ |d| d.to_s() }) do |result|
         usernames = result.field_values('username')
       end
     ensure
@@ -131,7 +130,7 @@ module PostfixadminPlugin
     sql_query = 'SELECT address,goto FROM alias;'
 
     begin
-      results = connection.query(sql_query)
+      results = connection.sync_exec(sql_query)
       results.each do |row|
         # row should be a hash
         aliases << row
@@ -163,7 +162,7 @@ module PostfixadminPlugin
     sql_query = 'SELECT COUNT(domain) as count FROM domain WHERE domain = $1;'
 
     begin
-      connection.query(sql_query, [domain.to_s()]) do |result|
+      connection.sync_exec_params(sql_query, [domain.to_s()]) do |result|
         return false if result.ntuples() < 1
         count = result.getvalue(0,0).to_i()
 
index b66c9f603cf2e4c665de427d33f6210108db3b1f..2ba9a98aaf25865960b5ea94b40cbad10dfc595e 100644 (file)
@@ -19,7 +19,6 @@ module RoundcubePlugin
       :host     => cfg.roundcube_dbhost,
       :port     => cfg.roundcube_dbport,
       :options  => cfg.roundcube_dbopts,
-      :tty      => cfg.roundcube_dbtty,
       :dbname   => cfg.roundcube_dbname,
       :user     => cfg.roundcube_dbuser,
       :password => cfg.roundcube_dbpass }
@@ -52,7 +51,7 @@ module RoundcubePlugin
     sql_query = 'SELECT username FROM users;'
 
     begin
-      connection.query(sql_query) do |result|
+      connection.sync_exec(sql_query) do |result|
         usernames = result.field_values('username')
       end
     ensure
@@ -79,7 +78,7 @@ module RoundcubePlugin
     sql_query = 'SELECT user_id FROM users WHERE username = $1;'
 
     begin
-      connection.query(sql_query, [user.to_s()]) do |result|
+      connection.sync_exec_params(sql_query, [user.to_s()]) do |result|
         if result.num_tuples > 0
           user_id = result[0]['user_id']
         end
index 2177009e67295b07b3762966976668e2a932b3ef..a2fb05438dd0cb5808b45d9d64f80d323fa0b037 100644 (file)
@@ -40,7 +40,7 @@ class AgendavMv
       # The "prefs" table uses the normal username as a key...
       # This should be harmless if the source user does not exist.
       sql_query0 = 'UPDATE prefs SET username = $1 WHERE username = $2;'
-      connection.query(sql_query0, [dst.to_s(), src.to_s()])
+      connection.sync_exec_params(sql_query0, [dst.to_s(), src.to_s()])
 
       # But the "shares" table uses encoded principal URLs. For the
       # "shares" table, we need to do a find/replace on the username
@@ -58,7 +58,7 @@ class AgendavMv
       sql_queries << 'UPDATE shares SET "with"=REPLACE("with", $2, $1);'
 
       sql_queries.each do |sql_query|
-        connection.query(sql_query, [encoded_dst, encoded_src])
+        connection.sync_exec_params(sql_query, [encoded_dst, encoded_src])
       end
     ensure
       # Make sure the connection gets closed even if a query explodes.
index e7aa050889384234bc8802b924e58038290084c6..1a8a18aa70e8d27cef54ad867a230890587e6932 100644 (file)
@@ -33,7 +33,7 @@ class DavicalMv
 
     connection = PG::Connection.new(@db_hash)
     begin
-      connection.query(sql_query, [dst.to_s(), src.to_s()])
+      connection.sync_exec_params(sql_query, [dst.to_s(), src.to_s()])
     ensure
       # Make sure the connection gets closed even if the query explodes.
       connection.close()
index f8f86c6ba45236b570e16f9b5c15fa2647aa77b1..1623118109a9033fd9e01bd75ee5ba737dfcfa8f 100644 (file)
@@ -59,7 +59,7 @@ class PostfixadminMv
                   {:value => dst.domainpart(), :type => varchar},
                   {:value => dst.localpart(), :type => varchar},
                   {:value => src.to_s(), :type => varchar}]
-        connection.query(sql_query, params)
+        connection.sync_exec_params(sql_query, params)
       end
     ensure
       # Make sure the connection gets closed even if a query explodes.
index 5cd20c77064532988bff689bcf52f43c49b67692..e2126f75f244bd5288647ec41ff7610917b90b42 100644 (file)
@@ -34,7 +34,7 @@ class RoundcubeMv
 
     connection = PG::Connection.new(@db_hash)
     begin
-      connection.query(sql_query, [dst.to_s(), src.to_s()])
+      connection.sync_exec_params(sql_query, [dst.to_s(), src.to_s()])
     ensure
       # Make sure the connection gets closed even if the query explodes.
       connection.close()
index 921bfe0687e2610401f2997dfe25cc09b3cfa6b1..2c7709011ca3a421ced83d7d58e2f1aa3c6c2faf 100644 (file)
@@ -47,7 +47,7 @@ class AgendavRm
     connection = PG::Connection.new(@db_hash)
     begin
       sql_queries.each do |sql_query|
-        connection.query(sql_query, [user.to_s()])
+        connection.sync_exec_params(sql_query, [user.to_s()])
       end
     ensure
       # Make sure the connection gets closed even if a query explodes.
index 1029994b9edc77a6db010eeb73fd8ad776a1b3ed..1978e8025b20a7990c3e8bb73f954b759f0a4590 100644 (file)
@@ -27,7 +27,7 @@ class DavicalRm
 
     connection = PG::Connection.new(@db_hash)
     begin
-      connection.query(sql_query, [user.to_s()])
+      connection.sync_exec_params(sql_query, [user.to_s()])
     ensure
       # Make sure the connection gets closed even if the query explodes.
       connection.close()
index 46eda4736878c25c35e435aee446a89d77be5fe3..958d42cbfd530e9fcb0ae6c7b1b83fa9b2c0ebb3 100644 (file)
@@ -56,7 +56,7 @@ class PostfixadminRm
       sql_queries.each do |sql_query|
         varchar = 1043 # from pg_type.h
         params = [{:value => user.to_s(), :type => varchar}]
-        connection.query(sql_query, params)
+        connection.sync_exec_params(sql_query, params)
       end
     ensure
       # Make sure the connection gets closed even if a query explodes.
@@ -103,7 +103,7 @@ class PostfixadminRm
 
     begin
       sql_queries.each do |sql_query|
-        connection.query(sql_query, [domain.to_s()])
+        connection.sync_exec_params(sql_query, [domain.to_s()])
       end
     ensure
       # Make sure the connection gets closed even if a query explodes.
index cb55af7dfb2394b166c2be856f512ab7cdbf7712..56c3108c354cf79d0b5017e025d8e7c64fb75a5a 100644 (file)
@@ -32,7 +32,7 @@ class RoundcubeRm
     connection = PG::Connection.new(@db_hash)
 
     begin
-      connection.query(sql_query, [user_id])
+      connection.sync_exec_params(sql_query, [user_id])
     ensure
       # Make sure the connection gets closed even if the query explodes.
       connection.close()
index e0d9b80f722b33890fd137047340eb04ac8a7457..0187847c298c89f752ee642488aa931ef3803cfb 100644 (file)
@@ -1,7 +1,7 @@
 Gem::Specification.new do |s|
 
   s.name              = 'mailshears'
-  s.version           = '0.0.4'
+  s.version           = '0.0.5'
   s.platform          = Gem::Platform::RUBY
   s.authors           = ['Michael Orlitzky']
   s.email             = ['michael@orlitzky.com']
index 0bfbd7f19f24abb4a714c2f75ba9930290d7da4a..35df97c3c0d14dd4439d4d14a7b9ca9f107ff29a 100644 (file)
@@ -4,7 +4,6 @@ plugins: [agendav, davical, dovecot, postfixadmin, roundcube]
 agendav_dbhost: localhost
 agendav_dbport: 5432
 agendav_dbopts:
-agendav_dbtty:
 agendav_dbuser: postgres
 agendav_dbpass:
 agendav_dbname: agendav_test
@@ -12,7 +11,6 @@ agendav_dbname: agendav_test
 davical_dbhost: localhost
 davical_dbport: 5432
 davical_dbopts:
-davical_dbtty:
 davical_dbuser: postgres
 davical_dbpass:
 davical_dbname: davical_test
@@ -22,7 +20,6 @@ dovecot_mail_root: /tmp/mailshears-test
 postfixadmin_dbhost: localhost
 postfixadmin_dbport: 5432
 postfixadmin_dbopts:
-postfixadmin_dbtty:
 postfixadmin_dbuser: postgres
 postfixadmin_dbpass:
 postfixadmin_dbname: postfixadmin_test
@@ -30,7 +27,6 @@ postfixadmin_dbname: postfixadmin_test
 roundcube_dbhost: localhost
 roundcube_dbport: 5432
 roundcube_dbopts:
-roundcube_dbtty:
 roundcube_dbuser: postgres
 roundcube_dbpass:
 roundcube_dbname: roundcube_test
index 2b653ede18100dc64e4afcaaaef3f757ebc8b8f6..22c634f43b643b41c3764f21ec79fbaf5bc1c186 100644 (file)
@@ -32,16 +32,15 @@ class MailshearsTest < MiniTest::Test
     # Connect to the database (specified in the test configuration) as
     # the superuser. Your local configuration is expected to be such
     # that this "just works."
-    db_host = 'localhost'
-    db_port = 5432
-    db_opts = nil
-    db_tty = nil
-    db_name = 'postgres'
-    db_user = 'postgres'
-    db_pass = nil
-
-    connection = PG::Connection.new(db_host, db_port, db_opts, db_tty,
-                                    db_name, db_user, db_pass)
+    db_hash = {
+      :host     => 'localhost',
+      :port     => 5432,
+      :options  => nil,
+      :dbname   => 'postgres',
+      :user     => 'postgres',
+      :password => nil
+    }
+    connection = PG::Connection.new(db_hash)
 
     return connection
   end
@@ -208,24 +207,23 @@ class MailshearsTest < MiniTest::Test
       plugin_dbname = cfg.send("#{plugin}_dbname")
       next if plugin_dbname.nil? # Skip the dovecot plugin
       query = "CREATE DATABASE #{plugin_dbname};"
-      connection.query(query)
+      connection.sync_exec(query)
 
-      plugin_dbhost = cfg.send("#{plugin}_dbhost")
-      plugin_dbport = cfg.send("#{plugin}_dbport")
-      plugin_dbopts = cfg.send("#{plugin}_dbopts")
-      plugin_dbtty  = cfg.send("#{plugin}_dbtty")
-      plugin_dbuser = cfg.send("#{plugin}_dbuser")
-      plugin_dbpass = cfg.send("#{plugin}_dbpass")
+      plugin_dbhash = {
+        :host     => cfg.send("#{plugin}_dbhost"),
+        :port     => cfg.send("#{plugin}_dbport"),
+        :options  => cfg.send("#{plugin}_dbopts"),
+        :dbname   => plugin_dbname,
+        :user     => cfg.send("#{plugin}_dbuser"),
+        :password => cfg.send("#{plugin}_dbpass")
+      }
 
-      plugin_conn = PG::Connection.new(plugin_dbhost, plugin_dbport,
-                                       plugin_dbopts, plugin_dbtty,
-                                       plugin_dbname, plugin_dbuser,
-                                       plugin_dbpass)
+      plugin_conn = PG::Connection.new(plugin_dbhash)
 
       sql = File.open("test/sql/#{plugin}.sql").read()
-      plugin_conn.query(sql)
+      plugin_conn.sync_exec(sql)
       sql = File.open("test/sql/#{plugin}-fixtures.sql").read()
-      plugin_conn.query(sql)
+      plugin_conn.sync_exec(sql)
       plugin_conn.close()
     end
 
@@ -246,7 +244,7 @@ class MailshearsTest < MiniTest::Test
       plugin_dbname = cfg.send("#{plugin}_dbname")
       next if plugin_dbname.nil? # Skip the dovecot plugin
       query = "DROP DATABASE IF EXISTS #{plugin_dbname};"
-      connection.query(query)
+      connection.sync_exec(query)
     end
 
     connection.close()