Subject: [PATCH] gnu: privoxy: Fix default logging configuration.

From: Brice Waegeneire <[email-masked]>
Date: Mon, 15 Jun 2020 11:41:22 +0200

Fixes <https://issues.guix.info/32934>.

* gnu/packages/tor.scm (privoxy)[arguments]<configure-flags>: Add
'localstatedir'.
<phases>: Add 'patch-default-logging'.
---

Hello Pierre,

This patch should allow one to use privoxy's default configuration as is:

--8<---------------cut here---------------start------------->8---
$ /gnu/store/1705l8br2bc4lvs7wf7mpzj4ss0zkl9c-privoxy-3.0.28/sbin/privoxy /gnu/store/1705l8br2bc4lvs7wf7mpzj4ss0zkl9c-privoxy-3.0.28/etc/privoxy/config
$ echo $?
0
--8<---------------cut here---------------end--------------->8---

- Brice

 gnu/packages/tor.scm | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/tor.scm b/gnu/packages/tor.scm
index 2f2623b0e6..19ab5cf374 100644
--- a/gnu/packages/tor.scm
+++ b/gnu/packages/tor.scm
@@ -8,6 +8,7 @@
 ;;; Copyright © 2017 Rutger Helling <[email-masked]>
 ;;; Copyright © 2018 Ricardo Wurmus <[email-masked]>
 ;;; Copyright © 2020 Vincent Legoll <[email-masked]>
+;;; Copyright © 2020 Brice Waegeneire <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -141,8 +142,28 @@ rejects UDP traffic from the application you're using.")
        ;; $out/etc/privoxy.
        #:configure-flags (list (string-append "--sysconfdir="
                                               (assoc-ref %outputs "out")
-                                              "/etc/privoxy"))
-       #:tests? #f))
+                                              "/etc/privoxy")
+                               "--localstatedir=/var")
+       #:tests? #f                      ; no test suite
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'patch-default-logging
+           (lambda _
+             (with-fluids ((%default-port-encoding "ISO-8859-1"))
+               ;; Do not create /var/run nor /var/log/privoxy/logfile.
+               (substitute* "GNUmakefile.in"
+                 (("(logfile \\|\\| exit )1" _ match)
+                  (string-append match "0"))
+                 (("(\\$\\(DESTDIR\\)\\$\\(SHARE_DEST\\)) \\\\" _ match)
+                  match)
+                 ((".*\\$\\(LOG_DEST\\) \\$\\(DESTDIR\\)\\$\\(PID_DEST\\).*")
+                  ""))
+               ;; Disable logging in the default configuration to allow for
+               ;; non-root users using it as is.
+               (substitute* "config"
+                 (("^logdir") "#logdir")
+                 (("^logfile") "#logfile")))
+             #t)))))
     (inputs
      `(("w3m" ,w3m)
        ("pcre" ,pcre)
-- 
2.26.2