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
@@ -1,20 +0,0 @@
1
- Writing Plugins for Schleuder
2
- ----------------------------
3
-
4
- There are a few rules which any Plugin must follow to work (correctly):
5
-
6
- - Name the file: <your_name>_plugin.rb (use underscores!)
7
- - Name the class: YourNamePlugin
8
- - module Schleuder
9
- - Inherit from Plugin
10
- - Implement two instance-methods:
11
- - match(mail)
12
- Is executed to determine whether process() should be executed. Needs to
13
- take one argument (a Schleuder::Mail-object) and to return true or false.
14
- - process(mail)
15
- Is executed if match() returned true. Manipulate the taken
16
- Schleuder::Mail-object here.
17
- - use reply(origmail, your_message) to send a message to the sending
18
- list-member and prevent normal distribution.
19
-
20
- For examples see other Plugins.
@@ -1,113 +0,0 @@
1
- module Schleuder
2
- class ManageKeysPlugin < Plugin
3
- def initialize
4
- @plugin_type = :request
5
- end
6
-
7
- def list_keys(mail, value)
8
- Schleuder.log.debug 'LIST-KEY requested'
9
- listkeys(mail)
10
- end
11
-
12
- def add_key(mail, value)
13
- Schleuder.log.debug 'ADD-KEY requested'
14
- addkey(mail, mail.body)
15
- end
16
-
17
- def del_key(mail, value)
18
- Schleuder.log.debug 'DEL-KEY requested'
19
- # TODO: implement callback to sender with Hash to prevent replay
20
- # attacks.
21
- # Split at slash to work around some people's habit to include the
22
- # bitlength and key-type ("2048R/DEADBEEF"). If there's no slash this
23
- # won't do no harm. We need to force the string'iness to avoid nil's,
24
- # though.
25
- val = value.split('/').last.to_s
26
- msg = "The DEL-KEY-keyword is deprecated and will be removed some day in the future. Please use DELETE-KEY instead.".fmt
27
- msg << delkey(mail, val)
28
- msg
29
- end
30
-
31
- def delete_key(mail, value)
32
- Schleuder.log.debug 'DELETE-KEY requested'
33
- delkey(mail, value.split('/').last)
34
- end
35
-
36
- def send_key(mail, value)
37
- Schleuder.log.debug 'SEND-KEY requested'
38
- val = value.split('/').last
39
- msg = "The SEND-KEY-keyword is deprecated and will be removed some day in the future. Please use GET-KEY instead.".fmt
40
- msg << getkey(mail, val)
41
- msg
42
- end
43
-
44
- def get_key(mail, value)
45
- Schleuder.log.debug 'GET-KEY requested'
46
- val = value.split('/').last
47
- getkey(mail, val)
48
- end
49
-
50
- private
51
-
52
- def listkeys(mail)
53
- m = ""
54
- mail.crypt.list_keys.each do |k|
55
- if not (trust = [:revoked, :expired, :disabled, :invalid].grep(k.trust)).empty?
56
- m << "*Warning*: Key is #{trust.join(' and ')}!\n"
57
- end
58
- m << "#{k.to_s}"
59
- if (exp = k.subkeys.first.expires) > Time.utc(1971, 1, 1, 1)
60
- if exp < Time.now
61
- m << "Expired at #{exp}.\n"
62
- else
63
- m << "Expires at #{exp}.\n"
64
- end
65
- end
66
- m << "\n"
67
- end
68
- m
69
- end
70
-
71
- def addkey(mail, key)
72
- m = ""
73
- res = mail.crypt.add_key(key)
74
- res.imports.each do |i|
75
- if i.status == 1
76
- action = "imported"
77
- else
78
- action = "not imported"
79
- end
80
- m << "#{mail.crypt.get_key(i.fpr).to_s}\n--> #{action}\n\n"
81
- end
82
- m << "\nImportResult.inspect:\n=> #{res.inspect}"
83
- m
84
- end
85
-
86
- def delkey(mail, req)
87
- unless (key = mail.crypt.get_key(req)).first
88
- msg = "Failed to lookup key (#{req}) that should be deleted. Reason: #{key[1].capitalize}."
89
- Schleuder.log.debug msg
90
- return "--> #{msg}\n\n"
91
- end
92
- Schleuder.log.debug "Key to be deleted: #{key.inspect}"
93
- res = mail.crypt.delete_key(key.first)
94
- if res == true
95
- action = "Key deleted."
96
- else
97
- action = "Key not deleted.\nException: #{res.to_s}"
98
- end
99
- "#{key.to_s}\n--> #{action}\n\n"
100
- end
101
-
102
- def getkey(mail, req)
103
- keyblock = mail.crypt.export(req)
104
- if keyblock.empty?
105
- "#{req}\n\n--> No matching key present.\n"
106
- else
107
- "#{mail.crypt.list_keys(req).to_s.gsub(/^pub /, "\npub ")}\n\n#{keyblock}\n"
108
- end
109
- end
110
-
111
- end
112
- end
113
-
@@ -1,156 +0,0 @@
1
- module Schleuder
2
- class ManageMembersPlugin < Plugin
3
- def initialize
4
- @plugin_type = :request
5
- end
6
-
7
- def get_members(mail, value)
8
- # TODO: deprecation-notice
9
- Schleuder.log.debug 'GET-MEMBERS requested'
10
- get_membersfile
11
- end
12
-
13
- def save_members(mail, value)
14
- # TODO: deprecation-notice
15
- Schleuder.log.debug 'SAVE-MEMBERS requested'
16
- if mail.body.strip.empty?
17
- "Error, empty input. You need to write the members list yaml-formatted into the body."
18
- else
19
- Schleuder.list.members = YAML.load(mail.body)
20
- "Saving was successful.\n\nCurrent members.conf:\n\n#{get_membersfile}\n"
21
- end
22
- end
23
-
24
- def add_member(mail, value)
25
- Schleuder.log.debug 'ADD-MEMBER requested'
26
- addmember(mail, value, mail.body)
27
- end
28
-
29
- def delete_member(mail, value)
30
- Schleuder.log.debug 'DELETE-MEMBER requested'
31
- deletemember(mail, value)
32
- end
33
-
34
- def list_members(mail, value)
35
- Schleuder.log.debug 'LIST-MEMBERS requested'
36
- listmembers(mail)
37
- end
38
-
39
- def get_member(mail, value)
40
- Schleuder.log.debug 'GET-MEMBER requested'
41
- getmember(mail, value)
42
- end
43
-
44
- def listmembers(mail)
45
- msg = ''
46
- msg << "Default mime-setting for this list: #{Schleuder.list.config.default_mime.downcase}.\n"
47
- msg << "\nAdmins for this list:\n\n#{_list_members(Schleuder.list.config.admins)}"
48
- msg << "\n\nMembers:\n\n#{_list_members(Schleuder.list.members)}"
49
- msg
50
- end
51
-
52
- def _list_members(members)
53
- members.collect { |member|
54
- res = member.email.dup
55
- res << " (mime: #{member.mime.downcase})" if member.mime && !member.mime.downcase.eql?(Schleuder.list.config.default_mime.downcase)
56
- res << " :: #{_list_keys(member)}\n\n"
57
- }.join('')
58
- end
59
-
60
- def _list_keys(member)
61
- result = ''
62
- key, msg = member.key(false) # also get a potentially expired key -> will
63
- # also inform about multiple keys on the list
64
- # that might not me the case otherwise
65
- if key
66
- if key.trust.eql?(:expired)
67
- result << "*Warning*: Key expired! "
68
- elsif key.trust.eql?(:revoked)
69
- result << "*Warning*: Key revoked! "
70
- end
71
- result << member.key_descr
72
- else
73
- result << "*Warning*: #{msg}"
74
- end
75
- result
76
- end
77
-
78
- def addmember(mail, string, key)
79
- email, mime = string.split(' ')
80
- mem = Member.new({:email => email})
81
- mem.mime = mime if mime
82
- if Schleuder.list.members.any?{|m| m.email == mem.email }
83
- msg = "--> Member is already part of the list. Nothing changed!"
84
- msg << "\nExisting members-list:"
85
- else
86
- Schleuder.list.members = Schleuder.list.members << mem
87
- msg = "#{mem}\n--> Member saved.\n\n"
88
- if key
89
- mail.crypt.add_key(key).imports.each do |i|
90
- msg << "#{mail.crypt.key_descr(mail.crypt.get_key(i.fpr))}\n"
91
- if i.status.eql? 1
92
- msg << "--> Key imported.\n\n"
93
- else
94
- msg << "--> Key *not* imported (no error, maybe already present?).\n\n"
95
- end
96
- end
97
- msg << "\n"
98
- end
99
- msg << "Updated members-list:"
100
- end
101
- msg << "\n\n#{_list_members(Schleuder.list.members)}"
102
- end
103
-
104
- def deletemember(mail, string)
105
- msg = ''
106
- members = Schleuder.list.members.dup
107
- members.delete_if {|mem| mem.email.eql?(string)}
108
- if members.eql? Schleuder.list.members
109
- msg << "Member #{string} not found"
110
- else
111
- if Schleuder.list.members = members
112
- msg << "Member #{string} deleted.\n"
113
- else
114
- msg = "Something failed. Please ask the maintainer of this list to figure out what\nhappened (e.g. by mailing to #{Schleuder.list.owner_addr}).\n"
115
- end
116
- end
117
- msg << "\nUpdated members-list:\n\n#{_list_members(Schleuder.list.members)}\n"
118
- msg
119
- end
120
-
121
- def getmember(mail, string)
122
- Schleuder.log.debug "string: #{string.inspect}"
123
- msg = ''
124
- member = Schleuder.list.find_member_by_email string
125
- unless member
126
- return "Member #{string} not found.\n"
127
- end
128
- msg << "Email: #{member.email}\nMime: "
129
- if member.mime
130
- msg << member.mime.downcase
131
- else
132
- msg << "#{Schleuder.list.config.default_mime.downcase} (list-default)"
133
- end
134
- msg << "\n\n"
135
- keys = mail.crypt.list_keys(member.email)
136
- if keys.empty?
137
- msg << "*Warning*: No key!\n\n"
138
- else
139
- if keys.size > 1
140
- msg << "*Warning*: Multiple keys!\n\n"
141
- end
142
- msg << "Key(s):\n\n"
143
- keys.each do |key|
144
- msg << "#{key.to_s}Fingerprint: #{key.subkeys.first.fpr}\n\n"
145
- end
146
- end
147
- msg
148
- end
149
-
150
- private
151
- def get_membersfile
152
- File.read(Schleuder.list.members_file)
153
- end
154
- end
155
- end
156
-
@@ -1,26 +0,0 @@
1
- module Schleuder
2
- class ManageSelfPlugin < Plugin
3
- def initialize
4
- @plugin_type = :request
5
- end
6
-
7
- def unsubscribe(mail, foo)
8
- Schleuder.log.debug 'UNSUBSCRIBE requested'
9
- msg = ''
10
-
11
- key = Plugin.signing_key(mail)
12
- member = Schleuder.list.find_member_by_key(key) || Schleuder.list.find_admin_by_key(key)
13
-
14
- members = Schleuder.list.members.dup
15
- members.delete_if {|mem| mem.email.eql?(member.email)}
16
-
17
- if Schleuder.list.members = members
18
- msg << "Your address #{member.email} hast been unsubscribed.\n"
19
- else
20
- msg = "Something failed. Please ask the maintainer of this list to figure out what\nhappened (e.g. by mailing to #{Schleuder.list.owner_addr}).\n"
21
- end
22
- msg
23
- end
24
-
25
- end
26
- end
@@ -1,35 +0,0 @@
1
- module Schleuder
2
- class ResendPlugin < Plugin
3
- def initialize
4
- @plugin_type = :list
5
- end
6
-
7
- def resend(mail, value)
8
- store_address(mail, value, false)
9
- end
10
-
11
- def resend_encrypted_only(mail, value)
12
- store_address(mail, value, true)
13
- end
14
-
15
- def store_address(mail, value, encrypted_only)
16
- if mail.to.to_a.include? Schleuder.list.request_addr
17
- msg = "The resend-command may only be used in message sent over the list, not messages sent to the request-address."
18
- Schleuder.log.warn msg
19
- return msg.fmt
20
- end
21
- if Utils.emailaddress? value
22
- m = Member.new({'email' => value})
23
- if encrypted_only
24
- m.encrypted_only = true
25
- end
26
- mail.resend_to << m
27
- else
28
- Schleuder.log.warn "Skipping invalid email address given with resend-keyword: #{value}"
29
- mail.metadata[:error] << "Invalid address given: '#{value}'."
30
- end
31
- mail
32
- end
33
-
34
- end
35
- end
@@ -1,14 +0,0 @@
1
- # Clearsigns the incoming body and sends the signed text back.
2
- # Useful if the public key of a list is widely known: Let schleuder sign e.g.
3
- # the fingerprints of your email servers certificates, and publish them online.
4
- module Schleuder
5
- class SignThisPlugin < Plugin
6
- def initialize
7
- @plugin_type = :request
8
- end
9
-
10
- def sign_this(mail)
11
- mail.crypt.clearsign(mail.body)
12
- end
13
- end
14
- end
@@ -1,12 +0,0 @@
1
- module Schleuder
2
- class VersionPlugin < Plugin
3
- def initialize
4
- @plugin_type = :request
5
- end
6
-
7
- def get_version(mail, value)
8
- require 'schleuder/version'
9
- "This list runs on schleuder v#{Schleuder::VERSION}.\n\nFor documentation see <http://schleuder.nadir.org/documentation.html>"
10
- end
11
- end
12
- end
metadata.gz.sig DELETED
Binary file