[Popcon-developers] Bug#773663: popularity-contest: Patch to enable Tor support

Federico Ceratto federico.ceratto at gmail.com
Sun Dec 21 18:38:25 UTC 2014


Attaching the correct support_tor.diff   :(

-- 
Federico
-------------- next part --------------
diff --git a/debian/control b/debian/control
index 2bf1d82..dbe674a 100644
--- a/debian/control
+++ b/debian/control
@@ -14,7 +14,7 @@ Architecture: all
 Pre-Depends: debconf (>= 1.5.34) | cdebconf (>= 0.106)
 Depends: ${misc:Depends}, ${perl:Depends}, dpkg (>= 1.10), libio-socket-ip-perl (>= 0.25-3)
 Recommends: gnupg, cron | fcron, exim4 | mail-transport-agent
-Suggests: anacron
+Suggests: anacron, tor
 Provides: popcon
 Description: Vote for your favourite packages automatically
  The popularity-contest package sets up a cron job that will
diff --git a/debian/cron.daily b/debian/cron.daily
index c45bccb..f3feaa7 100644
--- a/debian/cron.daily
+++ b/debian/cron.daily
@@ -12,6 +12,7 @@ unset MY_HOSTID
 unset PARTICIPATE
 unset SUBMITURLS
 unset USEHTTP
+unset USETOR
 unset MTAOPS
 
 # get configuration information
@@ -31,6 +32,24 @@ if [ -z "$MAILTO" ] && [ "yes" != "$USEHTTP" ]; then exit 0; fi
 # don't run if PARTICIPATE is "no" or unset!
 if [ "$PARTICIPATE" = "no" ] || [ -z "$PARTICIPATE" ]; then exit 0; fi
 
+# enable torify
+TORIFY_PATH=/usr/bin/torify
+if [ "$USETOR" = "yes" ]; then
+    if [ "yes" != "$USEHTTP" ]; then
+        echo "popularity-contest: when USETOR is set USEHTTP must be set as well" 2>&1
+        exit 1
+    fi
+    if [ ! -x $TORIFY_PATH ]; then
+        echo "popularity-contest: USETOR is set but torify is not available." 2>&1
+        echo "popularity-contest: Please install the tor package." 2>&1
+        exit 1
+    fi
+    TORIFY=$TORIFY_PATH
+else
+    TORIFY=''
+fi
+
+
 if [ -n "$HTTP_PROXY" ]; then
   export http_proxy="$HTTP_PROXY";
 fi
@@ -98,7 +117,7 @@ SUBMITTED=no
 # try to post the report through http POST
 if [ "$SUBMITURLS" ] && [ "yes" = "$USEHTTP" ]; then
     for URL in $SUBMITURLS ; do
-	if setsid /usr/share/popularity-contest/popcon-upload \
+	if setsid $TORIFY /usr/share/popularity-contest/popcon-upload \
 	    -u $URL -f $POPCON 2>/dev/null ; then
 		SUBMITTED=yes
 	else
@@ -108,8 +127,9 @@ if [ "$SUBMITURLS" ] && [ "yes" = "$USEHTTP" ]; then
 fi
 
 # try to email the popularity contest data
+# skip emailing if USETOR is set
 
-if [ yes != "$SUBMITTED" ] && [ "$MAILTO" ]; then
+if [ yes != "$SUBMITTED" ] && [ yes != "$USETOR" ] && [ "$MAILTO" ]; then
     if [ -x "`which sendmail 2>/dev/null`" ]; then
 	(
 	    if [ -n "$MAILFROM" ]; then
diff --git a/default.conf b/default.conf
index 433bc14..718aa99 100644
--- a/default.conf
+++ b/default.conf
@@ -51,6 +51,14 @@ SUBMITURLS="http://popcon.debian.org/cgi-bin/popcon.cgi"
 # USEHTTP enables http reporting.   Set this to 'yes' to enable it.
 USEHTTP="yes"
 
+# USETOR enables using Tor to perform http reporting.
+# In order to use it, set it to "yes" and set USEHTTP to "yes as well.
+# Also ensure that the "tor" package is installed and the tor daemon
+# is running.
+# When USETOR is set, email-based submission is disabled.
+# More information: https://www.torproject.org/
+USETOR="no"
+
 # HTTP_PROXY allows to specify an HTTP proxy server, the syntax is
 # HTTP_PROXY="http://proxy:port". This overrides the environment
 # variable http_proxy.


More information about the Popcon-developers mailing list