[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [flashproxy/master] Store CA certs file in TOR_PT_STATE_LOCATION if defined.



commit 8113e07a92cb25978a373c864de61fbaabb3ebb3
Author: David Fifield <david@xxxxxxxxxxxxxxx>
Date:   Wed Oct 24 15:59:28 2012 -0700

    Store CA certs file in TOR_PT_STATE_LOCATION if defined.
---
 flashproxy-reg-email |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/flashproxy-reg-email b/flashproxy-reg-email
index 7c5fd3f..33d9db4 100755
--- a/flashproxy-reg-email
+++ b/flashproxy-reg-email
@@ -1,5 +1,6 @@
 #!/usr/bin/env python
 
+import errno
 import getopt
 import os
 import re
@@ -161,6 +162,19 @@ def format_addr(addr):
         result += u":%d" % port
     return result
 
+def get_state_dir():
+    """Get a directory where we can put temporary files. Returns None if any
+    suitable temporary directory will do."""
+    pt_dir = os.environ.get("TOR_PT_STATE_LOCATION")
+    if pt_dir is None:
+        return None
+    try:
+        os.makedirs(pt_dir)
+    except OSError, e:
+        if e.errno != errno.EEXIST:
+            raise
+    return pt_dir
+
 options.remote_addr = (DEFAULT_REMOTE_ADDRESS, DEFAULT_REMOTE_PORT)
 options.email_addr = DEFAULT_EMAIL_ADDRESS
 options.smtp_addr = (DEFAULT_SMTP_HOST, DEFAULT_SMTP_PORT)
@@ -212,7 +226,8 @@ if options.debug:
     smtp.set_debuglevel(1)
 
 try:
-    ca_certs_fd, ca_certs_path = tempfile.mkstemp(prefix="flashproxy-reg-email-", suffix=".crt")
+    ca_certs_fd, ca_certs_path = tempfile.mkstemp(prefix="flashproxy-reg-email-",
+        dir=get_state_dir(), suffix=".crt")
     try:
         os.write(ca_certs_fd, CA_CERTS)
         os.close(ca_certs_fd)



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits