From: Josh Karlin Date: Thu, 15 Apr 2010 15:19:11 +0000 (+0000) Subject: Fixed random file saving X-Git-Tag: geni-apiv1-totrunk~59 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=7d2aaf6e77d0fdfe7a31991fbd5cd43613d9c041;p=sfa.git Fixed random file saving --- diff --git a/sfa/trust/certificate.py b/sfa/trust/certificate.py index 7089bd56..c49c50cc 100644 --- a/sfa/trust/certificate.py +++ b/sfa/trust/certificate.py @@ -322,7 +322,10 @@ class Certificate: # Save the certificate to a random file in /tmp/ # @param save_parents If save_parents==True, then also save the parent certificates. def save_to_random_tmp_file(self, save_parents=True): - filename = "/tmp/cert_%d" % randint(0,999999999) + while True: + filename = "/tmp/cred_%d" % randint(0,999999999) + if not os.path.isfile(filename): + break self.save_to_file(filename, save_parents) return filename ## diff --git a/sfa/trust/credential.py b/sfa/trust/credential.py index 12ef0b73..a9be4298 100644 --- a/sfa/trust/credential.py +++ b/sfa/trust/credential.py @@ -402,7 +402,11 @@ class Credential(object): def save_to_random_tmp_file(self): - filename = "/tmp/cred_%d" % randint(0,999999999) + while True: + filename = "/tmp/cred_%d" % randint(0,999999999) + if not os.path.isfile(filename): + break + self.save_to_file(filename) return filename