[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r15883: Updated to remove annoying print statements no one will see, (projects/gettor)
Author: ioerror
Date: 2008-07-13 22:34:41 -0400 (Sun, 13 Jul 2008)
New Revision: 15883
Modified:
projects/gettor/gettor.py
projects/gettor/gettor_blacklist.py
projects/gettor/gettor_requests.py
projects/gettor/gettor_responses.py
Log:
Updated to remove annoying print statements no one will see, new state directory, the whole works may even work.
Modified: projects/gettor/gettor.py
===================================================================
--- projects/gettor/gettor.py 2008-07-14 02:19:07 UTC (rev 15882)
+++ projects/gettor/gettor.py 2008-07-14 02:34:41 UTC (rev 15883)
@@ -35,7 +35,7 @@
"""
__program__ = 'gettor.py'
-__version__ = '20080713.00'
+__version__ = '20080713.01'
__url__ = 'https://tor-svn.freehaven.net/svn/tor/trunk/contrib/gettor/'
__author__ = 'Jacob Appelbaum <jacob@xxxxxxxxxxxxx>'
__copyright__ = 'Copyright (c) 2008, Jacob Appelbaum'
@@ -58,27 +58,27 @@
if not parsedMessage:
syslog.syslog("gettor: No parsed message. Dropping message.")
- print "gettor: No parsed message. Dropping message."
exit(1)
signature = False
signature = gettor_requests.verifySignature(rawMessage)
- print "Signature is : " + str(signature)
+ syslog.syslog("gettor: Signature is : " + str(signature))
replyTo = False
srcEmail = "gettor@xxxxxxxxxxxxxx"
# TODO XXX:
# Make the zip files and ensure they match packageList
# Make each zip file like so:
- # zip -9 windows-bindle.z \
+ # zip -9 windows-bundle.z \
# vidalia-bundle-0.2.0.29-rc-0.1.6.exe \
# vidalia-bundle-0.2.0.29-rc-0.1.6.exe.asc
#
+ distDir = "/var/lib/gettor/pkg/"
packageList = {
- "windows-bundle": "/tmp/windows-bundle.z",
- "macosx-bundle": "/tmp/macosx-bundle.z",
- "linux-bundle": "/tmp/linux-bundle.z",
- "source-bundle": "/tmp/source-bundle.z"
+ "windows-bundle": distDir + "windows-bundle.z",
+ "macosx-bundle": distDir + "macosx-bundle.z",
+ "linux-bundle": distDir + "linux-bundle.z",
+ "source-bundle": distDir + "source-bundle.z"
}
# XXX TODO: Ensure we have a proper replyTO or bail out (majorly malformed mail).
@@ -90,52 +90,42 @@
if not replyTo:
syslog.syslog("No help dispatched. Invalid reply address for user.")
- print "No help dispatched. Invalid reply address for user."
exit(1)
if not signature and previouslyHelped:
syslog.syslog("gettor: Unsigned messaged to gettor by blacklisted user dropped.")
- print "No help dispatched. Unsigned and unhelped for blacklisted user."
exit(1)
if not signature and not previouslyHelped:
# Reply with some help and bail out
- # Someday call blackList(replyTo)
+ gettor_blacklist.blackList(replyTo, True)
message = """
- You should try your request again with a provider that implements DKIM. Sorry.
+ Sorry, You should send your request from a provider that implements DKIM:
+ http://www.dkim.org/
+ We've blocked your address for a temporary (less than a day) time to prevent abuse.
"""
gettor_responses.sendHelp(message, srcEmail, replyTo)
- print "attempting to send email from: " + srcEmail + "The mail is sent to: " + replyTo
syslog.syslog("gettor: Unsigned messaged to gettor. We issued some help about using DKIM.")
- print "gettor: Unsigned messaged to gettor. We issued some help about using DKIM."
exit(0)
if signature:
syslog.syslog("gettor: Signed messaged to gettor.")
- print "gettor: Signed messaged to gettor."
try:
- print "gettor: Parsing now."
package = gettor_requests.parseRequest(parsedMessage, packageList)
except:
package = None
- if package == "windows-bundle":
- print "gettor: " + package + " selected."
- syslog.syslog("gettor: " + package + " selected.")
- message = "Here's your requested software as a zip file. Please \
- verify the signature."
- print "attempting to send email from: " +
- srcEmail + "The mail is sent to: " + replyTo
+ if package != None:
+ syslog.syslog("gettor: " + str(package) + " selected.")
+ message = "Here's your requested software as a zip file. Please " + \
+ "unzip the package and verify the signature."
gettor_responses.sendPackage(message, srcEmail, replyTo, packageList[package])
exit(0)
else:
- print "Package request is unknown: " + package
- message = " Your request was misunderstood. Please select one of the \
- following packages: " + packageList.keys()
-
+ message = "Your request was misunderstood. Please select one of the " + \
+ "following packages: " + str(packageList.keys()) + \
+ "\n" + "Please respond with a single package name."
gettor_responses.sendHelp(message, srcEmail, replyTo)
- print "attempting to send email from: " + srcEmail + "The mail is sent to: " + replyTo
syslog.syslog("gettor: Signed messaged to gettor. We issued some help about proper email formatting.")
- print "gettor: Signed messaged to gettor. We issued some help about proper email formatting."
exit(0)
Modified: projects/gettor/gettor_blacklist.py
===================================================================
--- projects/gettor/gettor_blacklist.py 2008-07-14 02:19:07 UTC (rev 15882)
+++ projects/gettor/gettor_blacklist.py 2008-07-14 02:34:41 UTC (rev 15883)
@@ -6,7 +6,7 @@
import hashlib
import os
-stateDir = "/tmp/gettor/"
+stateDir = "/var/lib/gettor/"
blStateDir = stateDir + "bl/"
def blackList(address, createEntry=False):
@@ -18,9 +18,11 @@
# XXX TODO: Eventually we may want to sort entries with netcom
# style /tmp/gettor/2-digits-of-hash/2-more-digits/rest-of-hash files
+ prepBLStateDir()
+
privateAddress = makeAddressPrivate(address)
blackListed = lookupBlackListEntry(privateAddress)
-
+
if blackListed:
return True
elif createEntry:
@@ -28,7 +30,7 @@
return False
-def lookupBlackListEntry(privateAddress, stateDir="/tmp/gettor/bl/"):
+def lookupBlackListEntry(privateAddress, stateDir="/var/lib/gettor/bl/"):
""" Check to see if we have a blacklist entry for the given address. """
entry = stateDir + str(privateAddress)
try:
@@ -37,7 +39,7 @@
return False
return True
-def createBlackListEntry(privateAddress, stateDir="/tmp/gettor/bl/"):
+def createBlackListEntry(privateAddress, stateDir="/var/lib/gettor/bl/"):
""" Create a zero byte file that represents the address in our blacklist. """
entry = stateDir + str(privateAddress)
stat = None
@@ -49,12 +51,10 @@
fd.close()
return True
except:
- print "Entry not found. We were unable to create an entry."
return False
- print "It appears that we already had an entry."
return False
-def removeBlackListEntry(privateAddress, stateDir="/tmp/gettor/bl/"):
+def removeBlackListEntry(privateAddress, stateDir="/var/lib/gettor/bl/"):
""" Remove the zero byte file that represents an entry in our blacklist."""
entry = stateDir + str(privateAddress)
stat = None
@@ -70,20 +70,16 @@
privateAddress = hash.hexdigest()
return privateAddress
-def prepBLStateDir(stateDir = "/tmp/gettor/bl/"):
- print "Preparing the state directory for gettor."
+def prepBLStateDir(stateDir = "/var/lib/gettor/"):
stat = None
try:
stat = os.stat(stateDir)
- print "We found a state directory"
return True
except OSError:
try:
- os.mkdir(stateDir)
- print "No state directory was found, we created one"
+ os.makedirs(stateDir)
return True
except:
- print "Unable to make a state directory"
return False
def blackListtests(address):
Modified: projects/gettor/gettor_requests.py
===================================================================
--- projects/gettor/gettor_requests.py 2008-07-14 02:19:07 UTC (rev 15882)
+++ projects/gettor/gettor_requests.py 2008-07-14 02:34:41 UTC (rev 15883)
@@ -47,8 +47,6 @@
# It may be too unfriendly to our users
for line in email.Iterators.body_line_iterator(parsedMessage):
for package in packages.keys():
- print "Line is: " + line
- print "Package is " + package
match = re.match(package, line)
if match:
return package
@@ -58,10 +56,10 @@
if __name__ == "__main__" :
""" Give us an email to understand what we think of it. """
packageList = {
- "windows-bundle": "/tmp/windows-bundle.z",
- "macosx-bundle": "/tmp/macosx-bundle.z",
- "linux-bundle": "/tmp/linux-bundle.z",
- "source-bundle": "/tmp/source-bundle.z"
+ "windows-bundle": "/var/lib/gettor/pkg/windows-bundle.z",
+ "macosx-bundle": "/var/lib/gettor/pkg/macosx-bundle.z",
+ "linux-bundle": "/var/lib/gettor/pkg/linux-bundle.z",
+ "source-bundle": "/var/lib/gettor/pkg/source-bundle.z"
}
print "Fetching raw message."
Modified: projects/gettor/gettor_responses.py
===================================================================
--- projects/gettor/gettor_responses.py 2008-07-14 02:19:07 UTC (rev 15882)
+++ projects/gettor/gettor_responses.py 2008-07-14 02:34:41 UTC (rev 15883)
@@ -12,10 +12,8 @@
""" Send a helpful message to the user interacting with us """
help = constructMessage(message, source, destination)
try:
- print "Attempting to send the following message: "
status = sendMessage(help, source, destination)
except:
- print "Message sending failed."
status = False
return status
@@ -23,10 +21,8 @@
""" Send a message with an attachment to the user interacting with us """
package = constructMessage(message, source, destination, filelist)
try:
- print "Attempting to send the following message: "
status = sendMessage(package, destination)
except:
- print "Message sending failed."
status = False
return status