schleuder 2.2.4 → 3.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +138 -0
  3. data/Rakefile +136 -0
  4. data/bin/pinentry-clearpassphrase +72 -0
  5. data/bin/schleuder +9 -89
  6. data/bin/schleuder-api-daemon +4 -0
  7. data/db/migrate/20140501103532_create_lists.rb +39 -0
  8. data/db/migrate/20140501112859_create_subscriptions.rb +21 -0
  9. data/db/migrate/201508092100_add_language_to_lists.rb +11 -0
  10. data/db/migrate/20150812165700_change_keywords_admin_only_defaults.rb +8 -0
  11. data/db/migrate/20150813235800_add_forward_all_incoming_to_admins.rb +11 -0
  12. data/db/migrate/201508141727_change_send_encrypted_only_default.rb +8 -0
  13. data/db/migrate/201508222143_add_logfiles_to_keep_to_lists.rb +11 -0
  14. data/db/migrate/201508261723_rename_delivery_disabled_to_delivery_enabled_and_change_default.rb +14 -0
  15. data/db/migrate/201508261815_strip_gpg_passphrase.rb +11 -0
  16. data/db/migrate/201508261827_remove_default_mime.rb +9 -0
  17. data/db/migrate/20160501172700_fix_headers_to_meta_defaults.rb +8 -0
  18. data/db/migrate/20170713215059_add_internal_footer_to_list.rb +11 -0
  19. data/db/schema.rb +62 -0
  20. data/etc/init.d/schleuder-api-daemon +87 -0
  21. data/etc/list-defaults.yml +123 -0
  22. data/etc/postfix/schleuder_sqlite.cf +28 -0
  23. data/etc/schleuder-api-daemon.service +10 -0
  24. data/etc/schleuder.cron.weekly +6 -0
  25. data/etc/schleuder.yml +61 -0
  26. data/lib/schleuder-api-daemon.rb +420 -0
  27. data/lib/schleuder.rb +81 -47
  28. data/lib/schleuder/cli.rb +334 -0
  29. data/lib/schleuder/cli/cert.rb +24 -0
  30. data/lib/schleuder/cli/schleuder_cert_manager.rb +84 -0
  31. data/lib/schleuder/cli/subcommand_fix.rb +11 -0
  32. data/lib/schleuder/conf.rb +131 -0
  33. data/lib/schleuder/errors/active_model_error.rb +15 -0
  34. data/lib/schleuder/errors/base.rb +17 -0
  35. data/lib/schleuder/errors/decryption_failed.rb +16 -0
  36. data/lib/schleuder/errors/fatal_error.rb +13 -0
  37. data/lib/schleuder/errors/file_not_found.rb +14 -0
  38. data/lib/schleuder/errors/invalid_listname.rb +13 -0
  39. data/lib/schleuder/errors/key_adduid_failed.rb +13 -0
  40. data/lib/schleuder/errors/key_generation_failed.rb +16 -0
  41. data/lib/schleuder/errors/keyword_admin_only.rb +13 -0
  42. data/lib/schleuder/errors/list_exists.rb +13 -0
  43. data/lib/schleuder/errors/list_not_found.rb +14 -0
  44. data/lib/schleuder/errors/list_property_missing.rb +14 -0
  45. data/lib/schleuder/errors/listdir_problem.rb +16 -0
  46. data/lib/schleuder/errors/loading_list_settings_failed.rb +14 -0
  47. data/lib/schleuder/errors/message_empty.rb +14 -0
  48. data/lib/schleuder/errors/message_not_from_admin.rb +13 -0
  49. data/lib/schleuder/errors/message_sender_not_subscribed.rb +13 -0
  50. data/lib/schleuder/errors/message_too_big.rb +14 -0
  51. data/lib/schleuder/errors/message_unauthenticated.rb +13 -0
  52. data/lib/schleuder/errors/message_unencrypted.rb +13 -0
  53. data/lib/schleuder/errors/message_unsigned.rb +13 -0
  54. data/lib/schleuder/errors/standard_error.rb +5 -0
  55. data/lib/schleuder/errors/too_many_keys.rb +17 -0
  56. data/lib/schleuder/errors/unknown_list_option.rb +14 -0
  57. data/lib/schleuder/filters/auth_filter.rb +39 -0
  58. data/lib/schleuder/filters/bounces_filter.rb +12 -0
  59. data/lib/schleuder/filters/forward_filter.rb +17 -0
  60. data/lib/schleuder/filters/forward_incoming.rb +13 -0
  61. data/lib/schleuder/filters/hotmail_message_filter.rb +25 -0
  62. data/lib/schleuder/filters/max_message_size.rb +14 -0
  63. data/lib/schleuder/filters/request_filter.rb +26 -0
  64. data/lib/schleuder/filters/send_key_filter.rb +20 -0
  65. data/lib/schleuder/filters/strip_alternative_filter.rb +21 -0
  66. data/lib/schleuder/filters_runner.rb +83 -0
  67. data/lib/schleuder/gpgme/ctx.rb +274 -0
  68. data/lib/schleuder/gpgme/import_status.rb +27 -0
  69. data/lib/schleuder/gpgme/key.rb +212 -0
  70. data/lib/schleuder/gpgme/sub_key.rb +13 -0
  71. data/lib/schleuder/gpgme/user_id.rb +22 -0
  72. data/lib/schleuder/list.rb +318 -127
  73. data/lib/schleuder/list_builder.rb +139 -0
  74. data/lib/schleuder/listlogger.rb +31 -0
  75. data/lib/schleuder/logger.rb +23 -0
  76. data/lib/schleuder/logger_notifications.rb +69 -0
  77. data/lib/schleuder/mail/message.rb +482 -0
  78. data/lib/schleuder/mail/parts_list.rb +9 -0
  79. data/lib/schleuder/plugin_runners/base.rb +91 -0
  80. data/lib/schleuder/plugin_runners/list_plugins_runner.rb +24 -0
  81. data/lib/schleuder/plugin_runners/request_plugins_runner.rb +27 -0
  82. data/lib/schleuder/plugins/attach_listkey.rb +17 -0
  83. data/lib/schleuder/plugins/get_version.rb +7 -0
  84. data/lib/schleuder/plugins/key_management.rb +113 -0
  85. data/lib/schleuder/plugins/list_management.rb +15 -0
  86. data/lib/schleuder/plugins/resend.rb +196 -0
  87. data/lib/schleuder/plugins/sign_this.rb +46 -0
  88. data/lib/schleuder/plugins/subscription_management.rb +140 -0
  89. data/lib/schleuder/runner.rb +130 -0
  90. data/lib/schleuder/subscription.rb +98 -0
  91. data/lib/schleuder/validators/boolean_validator.rb +7 -0
  92. data/lib/schleuder/validators/email_validator.rb +7 -0
  93. data/lib/schleuder/validators/fingerprint_validator.rb +7 -0
  94. data/lib/schleuder/validators/greater_than_zero_validator.rb +7 -0
  95. data/lib/schleuder/validators/no_line_breaks_validator.rb +7 -0
  96. data/lib/schleuder/version.rb +1 -1
  97. data/locales/de.yml +179 -0
  98. data/locales/en.yml +179 -0
  99. metadata +305 -108
  100. checksums.yaml.gz.sig +0 -3
  101. data.tar.gz.sig +0 -2
  102. data/LICENSE +0 -339
  103. data/README +0 -32
  104. data/bin/schleuder-fix-gem-dependencies +0 -37
  105. data/bin/schleuder-init-setup +0 -37
  106. data/bin/schleuder-migrate-v2.1-to-v2.2 +0 -225
  107. data/bin/schleuder-newlist +0 -413
  108. data/contrib/check-expired-keys.rb +0 -60
  109. data/contrib/mutt-schleuder-colors.rc +0 -10
  110. data/contrib/mutt-schleuder-resend.vim +0 -24
  111. data/contrib/smtpserver.rb +0 -76
  112. data/ext/default-list.conf +0 -149
  113. data/ext/default-members.conf +0 -7
  114. data/ext/list.conf.example +0 -14
  115. data/ext/schleuder.conf +0 -64
  116. data/lib/schleuder/archiver.rb +0 -46
  117. data/lib/schleuder/crypt.rb +0 -210
  118. data/lib/schleuder/errors.rb +0 -5
  119. data/lib/schleuder/list_config.rb +0 -146
  120. data/lib/schleuder/log/listlogger.rb +0 -57
  121. data/lib/schleuder/log/outputter/emailoutputter.rb +0 -120
  122. data/lib/schleuder/log/outputter/metaemailoutputter.rb +0 -50
  123. data/lib/schleuder/log/schleuderlogger.rb +0 -34
  124. data/lib/schleuder/mail.rb +0 -873
  125. data/lib/schleuder/mailer.rb +0 -26
  126. data/lib/schleuder/member.rb +0 -69
  127. data/lib/schleuder/plugin.rb +0 -54
  128. data/lib/schleuder/processor.rb +0 -363
  129. data/lib/schleuder/schleuder_config.rb +0 -75
  130. data/lib/schleuder/storage.rb +0 -84
  131. data/lib/schleuder/utils.rb +0 -80
  132. data/man/schleuder-newlist.8 +0 -174
  133. data/man/schleuder.8 +0 -416
  134. data/plugins/README +0 -20
  135. data/plugins/manage_keys_plugin.rb +0 -113
  136. data/plugins/manage_members_plugin.rb +0 -156
  137. data/plugins/manage_self_plugin.rb +0 -26
  138. data/plugins/resend_plugin.rb +0 -35
  139. data/plugins/sign_this_plugin.rb +0 -14
  140. data/plugins/version_plugin.rb +0 -12
  141. metadata.gz.sig +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: c37622657ee9683d0d006af23a4fb74d53c1c697
4
- data.tar.gz: 992426df30d2c0de1e97a9d9b611fc5dbc2d1557
2
+ SHA256:
3
+ metadata.gz: edc9a5383dea2704c0ea9cfaa947e657221b89a83ff693cc221c5649026711f5
4
+ data.tar.gz: 8c4117d91098a20ccb9d4f12146524eb8e7d701f60d9a77ce0573510b1dbeb42
5
5
  SHA512:
6
- metadata.gz: 8a4fa65cbe451d2880ef8f38201565c5672c8f41ebff22f8579f1e2ce3aef44f6aeb043e3d93610a55450e7296341ed8689bcf8bfc96dd40847b5d7ce1e987f5
7
- data.tar.gz: 5238664faab3274a9803bc11a9ef0a91f0c46392a825c7cfe2e040efd0cfc1b3ea2d09fa2982ac8ef9419e3ba13a0ec2a6d81bed2f484fa5846a6a5cec7c666d
6
+ metadata.gz: 25adeec03329d06994b3ebada2d8b0dd9f9e50ee8c83e5349496decacf9877e8388f2122656f984516f3b1d8f3872748d8b91366131cd6f21b4c2eef5caa915f
7
+ data.tar.gz: 83b6170572c99168c6b49471d2a34823b49e878f6d1c03ea5f65f7c9a7d999f80996c92813892942e1940822615ba17c4b8da9c864cc59c46b88f8730d5ebfed
@@ -0,0 +1,138 @@
1
+ Schleuder, version 3
2
+ ======================================
3
+
4
+ Schleuder is a gpg-enabled mailing list manager with resending-capabilities. Subscribers can communicate encrypted (and pseudonymously) among themselves, receive emails from non-subscribers and send emails to non-subscribers via the list.
5
+
6
+ Version 3 of schleuder is a complete rewrite, which aims to be more robust, flexible, and internationalized. It
7
+ also provides an API for the optional web interface called [schleuder-web](https://0xacab.org/schleuder/schleuder-web).
8
+
9
+ For more details see <https://schleuder.nadir.org/docs/>.
10
+
11
+ Requirements
12
+ ------------
13
+ * ruby >=2.1
14
+ * gnupg 2.0.x, or >=2.1.16
15
+ * gpgme
16
+ * sqlite3
17
+ * openssl
18
+
19
+ *If you use Debian stretch or CentOS 7, please have a look at the [installation docs](https://schleuder.nadir.org/docs/#installation). We do provide packages for those platforms, which simplify the installation a lot.*
20
+
21
+ *🛈 A note regarding Ubuntu: All released Ubuntu versions (including 17.10) don't meet the requirements with their packaged versions of gnupg! To run Schleuder on Ubuntu you currently have to install a more recent version of gnupg manually. A sufficient version of gnupg is included in "bionic-proposed", which might make 18.04 a usable Ubuntu release.*
22
+
23
+ On systems that base on Debian 9 ("stretch"), install the dependencies via
24
+
25
+ apt-get install ruby-dev gnupg2 libgpgme-dev libsqlite3-dev libssl-dev build-essential
26
+
27
+
28
+ We **recommend** to also run a random number generator like [haveged](http://www.issihosts.com/haveged/). This ensures Schleuder won't be blocked by lacking entropy, which otherwise might happen especially during key generation.
29
+
30
+ On Debian based systems, install it via
31
+
32
+ apt-get install haveged
33
+
34
+
35
+ Additionally these **rubygems** are required (will be installed automatically unless present):
36
+
37
+ * rake
38
+ * active_record
39
+ * sqlite3
40
+ * thor
41
+ * thin
42
+ * mail-gpg
43
+ * sinatra
44
+ * sinatra-contrib
45
+
46
+
47
+ Installing Schleuder
48
+ ------------
49
+
50
+ 1. Download [the gem](https://schleuder.nadir.org/downloads/schleuder-3.2.2.gem) and [the OpenPGP-signature](https://schleuder.nadir.org/downloads/schleuder-3.2.2.gem.sig) and verify:
51
+ ```
52
+ gpg --recv-key 0xB3D190D5235C74E1907EACFE898F2C91E2E6E1F3
53
+ gpg --verify schleuder-3.2.2.gem.sig
54
+ ```
55
+
56
+ 2. If all went well install the gem:
57
+ ```
58
+ gem install schleuder-3.2.2.gem
59
+ ```
60
+
61
+ 3. Set up schleuder:
62
+ ```
63
+ schleuder install
64
+ ```
65
+ This creates neccessary directories, copies example configs, etc. If you see errors about missing write permissions please follow the advice given.
66
+
67
+
68
+ For further information on setup and configuration please read <https://schleuder.nadir.org/docs/#setup>.
69
+
70
+
71
+ Command line usage
72
+ -----------------
73
+
74
+ See `schleuder help`.
75
+
76
+ E.g.:
77
+
78
+ Commands:
79
+ schleuder check_keys # Check all lists for unusable or expiring keys and send the results to the list-admins. (This is supposed...
80
+ schleuder help [COMMAND] # Describe available commands or one specific command
81
+ schleuder install # Set up Schleuder initially. Create folders, copy files, fill the database, etc.
82
+ schleuder version # Show version of schleuder
83
+ schleuder work list@hostname < message # Run a message through a list.
84
+
85
+ List administration
86
+ -------------------
87
+
88
+ Please use
89
+ [schleuder-cli](https://0xacab.org/schleuder/schleuder-cli) to create and
90
+ manage lists from the command line.
91
+
92
+ Optionally consider installing
93
+ [schleuder-web](https://0xacab.org/schleuder/schleuder-web), the web
94
+ interface for schleuder. It enables list-admins to manage their lists through
95
+ the web instead of using [request-keywords](https://schleuder.nadir.org/docs/#subscription-and-key-management).
96
+
97
+
98
+
99
+ Todo
100
+ ----
101
+
102
+ See <https://0xacab.org/schleuder/schleuder/issues>.
103
+
104
+ Testing
105
+ -------
106
+ We use rspec to test our code. To setup the test environment run:
107
+
108
+
109
+ SCHLEUDER_ENV=test SCHLEUDER_CONFIG=spec/schleuder.yml bundle exec rake db:init
110
+
111
+ To execute the test suite run:
112
+
113
+ bundle exec rspec
114
+
115
+ We are working on extendig the test coverage.
116
+
117
+ Contributing
118
+ ------------
119
+
120
+ Please see [CONTRIBUTING.md](CONTRIBUTING.md).
121
+
122
+
123
+ Code of Conduct
124
+ ---------------
125
+
126
+ We adopted a code of conduct. Please read [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md).
127
+
128
+
129
+ License
130
+ -------
131
+
132
+ GNU GPL 3.0. Please see [LICENSE.txt](LICENSE.txt).
133
+
134
+
135
+ Alternative Download
136
+ --------------------
137
+
138
+ Alternatively to the gem-files you can download the latest release as [a tarball](https://schleuder.nadir.org/downloads/schleuder-3.2.2.tar.gz) and [its OpenPGP-signature](https://schleuder.nadir.org/downloads/schleuder-3.2.2.tar.gz.sig).
@@ -0,0 +1,136 @@
1
+ project = 'schleuder'
2
+ require_relative "lib/#{project}.rb"
3
+
4
+ @version = Schleuder::VERSION
5
+ @tagname = "#{project}-#{@version}"
6
+ @gpguid = 'schleuder@nadir.org'
7
+ @filename_gem = "#{@tagname}.gem"
8
+ @filename_tarball = "#{@tagname}.tar.gz"
9
+
10
+ load "active_record/railties/databases.rake"
11
+
12
+ # Configure ActiveRecord
13
+ ActiveRecord::Tasks::DatabaseTasks.tap do |config|
14
+ config.root = File.dirname(__FILE__)
15
+ config.db_dir = 'db'
16
+ config.migrations_paths = ['db/migrate']
17
+ config.env = ENV['SCHLEUDER_ENV']
18
+ config.database_configuration = Schleuder::Conf.databases
19
+ end
20
+
21
+ # ActiveRecord requires this task to be present
22
+ Rake::Task.define_task("db:environment")
23
+
24
+ namespace :db do
25
+ # A shortcut.
26
+ task init: ['db:create', 'db:schema:load']
27
+ end
28
+
29
+ def edit_and_add_file(filename)
30
+ puts "Please edit #{filename} to refer to version #{@version}"
31
+ if system("gvim -f #{filename}.md")
32
+ `git add #{filename}.md`
33
+ else
34
+ exit 1
35
+ end
36
+ end
37
+
38
+ task :console do
39
+ exec "irb -r #{File.dirname(__FILE__)}/lib/schleuder.rb"
40
+ end
41
+
42
+ task :publish_gem => :website
43
+ task :git_tag => :check_version
44
+
45
+ desc "Build new version: git-tag and gem-file"
46
+ task :new_version => [
47
+ :check_version,
48
+ :edit_readme, :edit_changelog,
49
+ :git_add_version,
50
+ :git_commit,
51
+ :build_gem,
52
+ :sign_gem,
53
+ :build_tarball,
54
+ :sign_tarball,
55
+ :git_tag
56
+ ] do
57
+ end
58
+
59
+ desc "Edit CHANGELOG.md"
60
+ task :edit_changelog do
61
+ edit_and_add_file('CHANGELOG')
62
+ end
63
+
64
+ desc "Edit README"
65
+ task :edit_readme do
66
+ edit_and_add_file('README')
67
+ end
68
+
69
+ desc 'git-tag HEAD as new version'
70
+ task :git_tag do
71
+ `git tag -u #{@gpguid} -s -m "Version #{@version}" #{@tagname}`
72
+ end
73
+
74
+ desc "Add changed version to git-index"
75
+ task :git_add_version do
76
+ `git add lib/#{project}/version.rb`
77
+ end
78
+
79
+ desc "Commit changes as new version"
80
+ task :git_commit do
81
+ `git commit -m "Version #{@version} (README, gems, ...)"`
82
+ end
83
+
84
+ desc 'Build, sign and commit a gem-file.'
85
+ task :build_gem do
86
+ `gem build #{project}.gemspec`
87
+ end
88
+
89
+ desc 'OpenPGP-sign gem and tarball'
90
+ task :sign_tarball do
91
+ `gpg -u #{@gpguid} -b #{@filename_gem}`
92
+ end
93
+
94
+ desc 'OpenPGP-sign gem'
95
+ task :sign_gem do
96
+ `gpg -u #{@gpguid} -b #{@filename_tarball}`
97
+ end
98
+
99
+ desc 'Publish gem-file to rubygems.org'
100
+ task :publish_gem do
101
+ puts "Really push #{@filename_gem} to rubygems.org? [yN]"
102
+ if gets.match(/^y/i)
103
+ puts "Pushing..."
104
+ `gem push #{@filename_gem}`
105
+ else
106
+ puts "Not pushed."
107
+ end
108
+ end
109
+
110
+ desc 'Build and sign a tarball'
111
+ task :build_tarball do
112
+ `git archive --format tar.gz --prefix "#{@tagname}/" -o #{@filename_tarball} master`
113
+ end
114
+
115
+ desc 'Describe manual release-tasks'
116
+ task :website do
117
+ puts "Please update the website:
118
+ * Update changelog.
119
+ * Publish release-announcement.
120
+ "
121
+ end
122
+
123
+ desc 'Check if version-tag already exists'
124
+ task :check_version do
125
+ # Check if Schleuder::VERSION has been updated since last release
126
+ if `git tag`.match?(/^#{@tagname}$/)
127
+ $stderr.puts "Warning: Tag '#{@tagname}' already exists. Did you forget to update #{project}/version.rb?"
128
+ $stderr.print "Delete tag to continue? [yN] "
129
+ if $stdin.gets.match(/^y/i)
130
+ `git tag -d #{@tagname}`
131
+ else
132
+ exit 1
133
+ end
134
+ end
135
+ end
136
+
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # This file can be deleted once we cease to support gnupg 2.0.
4
+
5
+ require 'fileutils'
6
+ require 'cgi'
7
+ require 'openssl'
8
+
9
+ def respond(msg, flush=true)
10
+ $stdout.puts msg
11
+ if flush
12
+ $stdout.flush
13
+ end
14
+ end
15
+
16
+ def send_ok(flush=true)
17
+ respond 'OK', flush
18
+ end
19
+
20
+ def send_password
21
+ if File.exist?(OLDPWDSENTFILE)
22
+ pwd = ''
23
+ if File.exist?(EMPTYPWDSENTFILE1)
24
+ FileUtils.touch(EMPTYPWDSENTFILE2)
25
+ else
26
+ FileUtils.touch(EMPTYPWDSENTFILE1)
27
+ end
28
+ else
29
+ pwd = OLDPASSWD
30
+ FileUtils.touch(OLDPWDSENTFILE)
31
+ end
32
+ respond "D #{pwd}"
33
+ end
34
+
35
+ def do_exit
36
+ if File.exist?(EMPTYPWDSENTFILE2)
37
+ FileUtils.rm_rf(TMPDIR)
38
+ end
39
+ exit 0
40
+ end
41
+
42
+ OLDPASSWD = CGI.escape(ENV['PINENTRY_USER_DATA'].to_s)
43
+ if OLDPASSWD.empty?
44
+ respond "Fatal error: passed PINENTRY_USER_DATA was empty, cannot continue"
45
+ exit 1
46
+ end
47
+
48
+ # We need a static directory name to maintain the state across invocations of
49
+ # this file.
50
+ TMPDIR = File.join(ENV['GNUPGHOME'], '.tmp-pinentry-clearpassphrase')
51
+ OLDPWDSENTFILE = File.join(TMPDIR, '1')
52
+ EMPTYPWDSENTFILE1 = File.join(TMPDIR, '2')
53
+ EMPTYPWDSENTFILE2 = File.join(TMPDIR, '3')
54
+ if ! Dir.exist?(TMPDIR)
55
+ Dir.mkdir(TMPDIR)
56
+ end
57
+
58
+ respond "OK - what's up?"
59
+
60
+ while line = $stdin.gets do
61
+ case line
62
+ when /^GETPIN/
63
+ send_password
64
+ send_ok
65
+ when /^BYE/
66
+ send_ok false
67
+ do_exit
68
+ else
69
+ send_ok
70
+ end
71
+ end
72
+
@@ -1,96 +1,16 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- # Don't show warnings, $stdout is being watched by the MTA.
4
- $VERBOSE = nil
3
+ # Don't emit any warnings, they would be sent back to the email-sender as an
4
+ # error-message.
5
+ $VERBOSE=nil
5
6
 
6
- # TODO:
7
- # - make code comments rdoc-compatible.
8
- # - check sanity of listconfig-value like 'myaddr', 'default_mime' etc.
9
- # We need them to be properly set to process properly.
10
- # - primary setup-check / is there a valid list-config?/admin?/
11
- # admin-key?
7
+ trap("INT") { exit 1 }
12
8
 
13
- def usage
14
- puts "Usage:
15
- #{File.basename($0)} [-c baseconfig] listname < email
16
- #{File.basename($0)} [-c baseconfig] -test [listname]"
17
- exit 1
18
- end
19
-
20
- def process_test(arg)
21
- usage unless STDIN.tty?
22
- listname = ARGV.shift
23
- if listname
24
- Schleuder.log.debug "Calling Processor.test(#{listname})"
25
- Schleuder::Processor.test listname
26
- else
27
- Schleuder.log.debug "Calling Processor.test"
28
- Schleuder::Processor.test
29
- end
30
- end
31
9
 
32
- def process_list(listname)
33
- usage if STDIN.tty? or ! listname
34
- Schleuder.log.debug "Running for list #{listname}"
35
- Schleuder.log.debug 'Reading STDIN'
36
- # TODO: check for valid IO
37
- msg = STDIN.read
38
- Schleuder.log.debug 'Handing over to Processor.run'
39
- Schleuder::Processor.run listname, msg
40
- end
41
-
42
- $:.unshift File.dirname(__FILE__) + '/../lib'
43
- require 'schleuder'
44
- begin
45
- arg = ARGV.shift
46
- if arg == '-c'
47
- Schleuder.config(ARGV.shift)
48
- arg = ARGV.shift
49
- end
50
- Schleuder.log.debug "I've been called, starting up..."
51
- case arg
52
- when '-test'
53
- process_test(ARGV)
54
- when /(-h|--help)/
55
- usage
56
- when /[A-Za-z0-9]+/
57
- process_list(arg.gsub(/-(sendkey|bounces|request|owner)(@|$)/, '\2'))
58
- else
59
- usage
60
- end
61
- rescue SystemExit => e
62
- exit e.status
63
- rescue Errno::EACCES => e
64
- msg = [e.message, e.backtrace].flatten.join("\n")
65
- $stderr.puts "File permission error: %s" % msg
66
- begin
67
- Schleuder.log.fatal e
68
- rescue
69
- begin
70
- Log4r::Logger['log4r'].error e
71
- rescue
72
- end
73
- end
74
- exit 1
75
- rescue Exception => e
76
- begin
77
- # Log4r mutes all outputters on first exception so if this rescues from a
78
- # Log4r-error we can't expect the raise of a second exception here.
79
- # Unfortunately there's no direct way to identify exceptions from Log4r
80
- # because it throws StandardErrors and we're subclassing.
81
- callerfile = e.backtrace.first.split(':').first.split('/').last rescue ''
82
- if e.class == StandardError &&
83
- ['listlogger.rb', 'schleuderlogger.rb'].include?(callerfile)
84
- raise e
85
- else
86
- Schleuder.log.fatal e
87
- end
88
- rescue => f
89
- msg1 = "Logger exception: #{f}\n#{f.backtrace.join("\n")}"
90
- msg2 = "...while trying to log this exception: #{e}\n#{f.backtrace.join("\n")}"
91
- Log4r::Logger['log4r'].error { "#{msg1}\n\n#{msg2}" }
92
- $stderr.puts(f.message) if $stderr.tty?
93
- end
94
- $stderr.puts "A serious error occurred, please notify the administrators of this list or server!"
10
+ begin
11
+ require_relative '../lib/schleuder/cli'
12
+ Schleuder::Cli.start
13
+ rescue => exc
14
+ $stderr.puts "Technical Error: #{exc}\n#{exc.backtrace.first}"
95
15
  exit 1
96
16
  end