Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
marvel
GitHub Repository: marvel/qnf
Path: blob/master/elisp/gnushush.el
987 views
1
;;; gnushush.el --- make Gnus be a little secretive in message headers
2
3
;; Copyright (C) 2001,2002 Neil W. Van Dyke
4
5
;; Author: Neil W. Van Dyke <[email protected]>
6
;; Version: 1.2
7
;; X-URL: http://www.neilvandyke.org/gnushush/
8
;; X-CVS: $Id: gnushush.el,v 1.21 2002/12/02 19:56:07 neil Exp $ GMT
9
10
;; This is free software; you can redistribute it and/or modify it under the
11
;; terms of the GNU General Public License as published by the Free Software
12
;; Foundation; either version 2, or (at your option) any later version. This
13
;; is distributed in the hope that it will be useful, but without any warranty;
14
;; without even the implied warranty of merchantability or fitness for a
15
;; particular purpose. See the GNU General Public License for more details.
16
;; You should have received a copy of the GNU General Public License along with
17
;; GNU Emacs; see the file `COPYING'. If not, write to the Free Software
18
;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
19
20
;;; Commentary:
21
22
;; The Gnus newsreader (at least version 5.8.3) can be a little bit of a
23
;; blabbermouth sometimes, needlessly revealing information in your mail
24
;; headers that reduces your privacy or puts you at slightly greater risk of
25
;; network attacks against your computer's security.
26
;;
27
;; `gnushush.el' is a small package that pressures Gnus into being a little
28
;; bit quieter. To use it, put the following line in your `.emacs' file:
29
;;
30
;; (require 'gnushush)
31
;;
32
;; There are some options below that you can set. Just be sure you know what
33
;; you're doing, since wrongly setting some of these options can cause problems
34
;; for other people. The defaults settings are pretty benign.
35
;;
36
;; Some later version of Gnus will probably obviate the need for this package,
37
;; but isn't it nice that Emacs Lisp lets us so easily modify software using
38
;; layered packages, rather than having to wait for some huge canonical package
39
;; to be modified?
40
41
;;; Change Log:
42
43
;; [Version 1.2, 02-Dec-2002] Fixed `gnuhush' typos (thanks Frederik Fouvry).
44
;;
45
;; [Version 1.1, 15-Oct-2002] Updated email address.
46
;;
47
;; [Version 1.0, 15-Feb-2001] Initial release.
48
49
;;; Code:
50
51
(defconst gnushush-version "1.2")
52
53
(require 'custom)
54
(require 'message)
55
56
(defgroup gnushush nil
57
"Make Gnus give away a little less info in message headers."
58
:group 'gnus
59
:prefix "gnushush-"
60
:link '(url-link "http://www.neilvandyke.org/gnushush/"))
61
62
(defcustom gnushush-enable-p t
63
"Enable `gnushush' functionality?"
64
:group 'gnushush
65
:type 'boolean)
66
67
(defcustom gnushush-fqdn 'real
68
"Fully-qualified domain name for Message-IDs (use with caution). This can be
69
set to `real', in which case Gnus behaves as normal, or to a string with the
70
FQDN of your choosing. It is important that you only specify an FQDN if you
71
know what you are doing and you control the domain of the FQDN (e.g., you have
72
a second-level domain registered to you for your personal home network, and you
73
are certain that disguising `laptop.bedroom.homedomain.foo' as `homedomain.foo'
74
will not make it possible to have duplicate Message-IDs generated by any
75
machines under the `homedomain.foo' domain)."
76
:group 'gnushush
77
:type '(choice (const real) string))
78
79
(defcustom gnushush-uid 'random
80
"UID handling for Message-IDs.
81
Normally, Gnus will encode your numeric user ID (UID) into each Message-ID,
82
which can reveal that you are using the same computer account to post to Usenet
83
under multiple identities. There is also a *small* risk that knowledge of a
84
UID can help an attacker break into your computer over the Internet. In any
85
case, you may see little sense in publishing your UID to the world. If this
86
variable If set to `real', then Gnus behaves as normal. If set to `random',
87
a random number is used as a fake UID when the Message-ID is generated. If
88
set to a positive integer, then that number will be used as the fake UID."
89
:group 'gnushush
90
:type '(choice (const real) (const random) integer))
91
92
(defcustom gnushush-sender-header 'none
93
"Handling of Sender headers.
94
You may wish to ``spam-proof'' your email address in the From headers of your
95
Usenet posts to avoid various email address harvesters that scour Usenet for
96
spam targets. Or you may wish to hide your identity, by faking your email
97
address in the From header (*and via other means*, since simply modifying the
98
\From header is probably not adequate to conceal your identity). The problem
99
is that Gnus is a bit of a tattletale -- when it sees a modified From header,
100
it will go and secretly add a Sender header that includes your username and
101
your computer's fully-qualified domain name. If this variable is set to
102
`none', then `gnushush' will remove any Sender header added by Gnus before the
103
message is sent. If this variable is set to `real', then any Sender header
104
will be left alone."
105
:group 'gnushush
106
:type '(choice (const real) (const none)))
107
108
(defcustom gnushush-user-agent-header "Emacs Gnus"
109
"Handling of User-Agent headers.
110
Gnus likes to add a User-Agent header to all messages that discloses what
111
versions of Gnus and Emacs you are running. In general, security-wise, it is
112
best not to disclose what software and versions you are running, since that
113
advertises your vulnerability to particular security exploits. If this
114
variable is set to `real', then the User-Agent header added by Gnus is left
115
unchanged. If this variable is set to `none', then all User-Agent headers are
116
stripped before sending. If this variable is set to a string, then the
117
contents of the string are used as the value of the User-Agent header. By
118
default, `gnushush' will set the variable to acknowledge that you run the neato
119
Gnus and Emacs software, but does not say what versions. The distinction is
120
minor, but there is no sense in needlessly advertising what software versions
121
you run."
122
:group 'gnushush
123
:type '(choice (const real) (const none) string))
124
125
(defun gnushush-customize ()
126
(interactive)
127
(customize-group 'gnushush))
128
129
(defun gnushush-dummy-system-name ()
130
gnushush-fqdn)
131
132
(defun gnushush-dummy-user-login-name (&optional uid)
133
(progn "user"))
134
135
(defun gnushush-dummy-user-uid ()
136
(cond ((eq gnushush-uid 'real) (error "gnushush internal error"))
137
((eq gnushush-uid 'random) (random 1296))
138
((integerp gnushush-uid) gnushush-uid)
139
(t (error "gnushush-uid must be integer, 'random, or 'real"))))
140
141
(defadvice message-generate-headers (after gnushush-ad-mgh activate)
142
(when gnushush-enable-p
143
(let ((victims
144
(delq nil
145
(list
146
(unless (eq gnushush-user-agent-header 'real) "User-Agent")
147
(unless (eq gnushush-sender-header 'real) "Sender")))))
148
(when victims
149
(save-match-data
150
(save-restriction
151
(message-narrow-to-headers)
152
(goto-char (point-min))
153
(let ((regexp (concat "^\\("
154
(mapconcat 'identity victims "\\|")
155
"\\):"))
156
(case-fold-search t))
157
(while (re-search-forward regexp nil t)
158
(delete-region (progn (beginning-of-line) (point))
159
(progn (forward-line) (point)))))
160
(when (stringp gnushush-user-agent-header)
161
(goto-char (point-max))
162
(unless (bolp) (insert "\n"))
163
(insert "User-Agent: " gnushush-user-agent-header)
164
(insert "\n"))))))))
165
166
(defadvice message-make-message-id (around gnushush-ad-mmmi activate protect)
167
(let ((gnushush-saved-sn (symbol-function 'system-name))
168
(gnushush-saved-uln (symbol-function 'user-login-name))
169
(gnushush-saved-uu (symbol-function 'user-uid)))
170
(unwind-protect
171
(progn
172
(when gnushush-enable-p
173
(unless (eq gnushush-fqdn 'real)
174
(fset 'system-name 'gnushush-dummy-system-name))
175
(unless (eq gnushush-uid 'real)
176
(fset 'user-login-name 'gnushush-dummy-user-login-name)
177
(fset 'user-uid 'gnushush-dummy-user-uid)))
178
ad-do-it)
179
(fset 'system-name gnushush-saved-sn)
180
(fset 'user-login-name gnushush-saved-uln)
181
(fset 'user-uid gnushush-saved-uu))))
182
183
(random t)
184
185
(provide 'gnushush)
186
187
;; gnushush.el ends here
188
189