changeset 4470:ea2aa935fbde

cfg.log_remote_addr (default: True) controls whether moin logs remote's IP/hostname to edit-log and event-log Setting this to False will improve user's privacy, but make it harder to track wiki abusers by the wiki admin. Please be careful: there might be some more storage of IP addresses, e.g.: * apache or other web server's logs * moin's cache (esp. surge protection cache) * if you sign with @SIG@ without being logged in
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Mon, 29 Dec 2008 14:37:16 +0100
parents eda228a638cf
children 5ea38c7fa252
files MoinMoin/Page.py MoinMoin/config/multiconfig.py MoinMoin/logfile/editlog.py MoinMoin/logfile/eventlog.py
diffstat 4 files changed, 27 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/Page.py	Wed Dec 24 17:09:44 2008 +0100
+++ b/MoinMoin/Page.py	Mon Dec 29 14:37:16 2008 +0100
@@ -554,7 +554,7 @@
             if editordata[0] == 'interwiki':
                 editor = "%s:%s" % editordata[1]
             else:
-                editor = editordata[1] # ip or email
+                editor = editordata[1] # ip or email or anon
             result = {
                 'timestamp': line.ed_time_usecs,
                 'editor': editor,
--- a/MoinMoin/config/multiconfig.py	Wed Dec 24 17:09:44 2008 +0100
+++ b/MoinMoin/config/multiconfig.py	Mon Dec 29 14:37:16 2008 +0100
@@ -988,6 +988,8 @@
     ('language_default', 'en', "Default language for user interface and page content, see HelpOnLanguages."),
     ('language_ignore_browser', False, "if True, ignore user's browser language settings, see HelpOnLanguages."),
 
+    ('log_remote_addr', True,
+     "if True, log the remote IP address (and maybe hostname)."),
     ('log_reverse_dns_lookups', True,
      "if True, do a reverse DNS lookup on page SAVE. If your DNS is broken, set this to False to speed up SAVE."),
     ('log_timing', False,
--- a/MoinMoin/logfile/editlog.py	Wed Dec 24 17:09:44 2008 +0100
+++ b/MoinMoin/logfile/editlog.py	Mon Dec 29 14:37:16 2008 +0100
@@ -81,9 +81,11 @@
             representing the user that did the edit.
 
             The type id is one of 'ip' (DNS or numeric IP), 'user' (user name)
-            or 'homepage' (Page instance of user's homepage).
+            or 'homepage' (Page instance of user's homepage) or 'anon' ('').
         """
-        result = 'ip', request.cfg.show_hosts and self.hostname or ''
+        result = 'anon', ''
+        if request.cfg.show_hosts and self.hostname:
+            result = 'ip', self.hostname
         if self.userid:
             if self.userid not in self._usercache:
                 self._usercache[self.userid] = user.User(request, self.userid, auth_method="editlog:75")
@@ -100,7 +102,7 @@
     def getEditor(self, request):
         """ Return a HTML-safe string representing the user that did the edit.
         """
-        if request.cfg.show_hosts:
+        if request.cfg.show_hosts and self.hostname and self.addr:
             title = " @ %s[%s]" % (self.hostname, self.addr)
         else:
             title = ""
@@ -131,6 +133,9 @@
                 idx = len(info)
             title = '???' + title
             text = request.formatter.text(info[:idx])
+        elif kind == 'anon':
+            title = ''
+            text = _('anonymous')
         else:
             raise Exception("unknown EditorData type")
         return (request.formatter.span(1, title=title) +
@@ -162,18 +167,22 @@
 
         If `host` is None, it's read from request vars.
         """
-        if host is None:
-            host = request.remote_addr
+        if request.cfg.log_remote_addr:
+            if host is None:
+                host = request.remote_addr
 
-        if request.cfg.log_reverse_dns_lookups:
-            import socket
-            try:
-                hostname = socket.gethostbyaddr(host)[0]
-                hostname = unicode(hostname, config.charset)
-            except (socket.error, UnicodeError):
+            if request.cfg.log_reverse_dns_lookups:
+                import socket
+                try:
+                    hostname = socket.gethostbyaddr(host)[0]
+                    hostname = unicode(hostname, config.charset)
+                except (socket.error, UnicodeError):
+                    hostname = host
+            else:
                 hostname = host
         else:
-            hostname = host
+            host = ''
+            hostname = ''
 
         comment = wikiutil.clean_input(comment)
         user_id = request.user.valid and request.user.id or ''
--- a/MoinMoin/logfile/eventlog.py	Wed Dec 24 17:09:44 2008 +0100
+++ b/MoinMoin/logfile/eventlog.py	Mon Dec 29 14:37:16 2008 +0100
@@ -37,8 +37,9 @@
 
         if values is None:
             values = {}
-        if add_http_info:
-            # All these are ascii
+        if request.cfg.log_remote_addr and add_http_info:
+            # if cfg.log_remote_addr is False (usually for privacy reasons),
+            # we likely do not want to log user agent and http referer either.
             for key in ['remote_addr', 'http_user_agent', 'http_referer']:
                 value = getattr(request, key, '')
                 if value: