Commit c54c9fdc authored by Marco Mariani's avatar Marco Mariani

generatepassword recipe: added missing O_TRUNC

parent 3365305c
...@@ -60,7 +60,7 @@ class Recipe(object): ...@@ -60,7 +60,7 @@ class Recipe(object):
try: try:
with open(self.storage_path) as f: with open(self.storage_path) as f:
passwd = f.read() passwd = f.read()
except IOError, e: except IOError as e:
if e.errno != errno.ENOENT: if e.errno != errno.ENOENT:
raise raise
passwd = None passwd = None
...@@ -79,11 +79,11 @@ class Recipe(object): ...@@ -79,11 +79,11 @@ class Recipe(object):
if self.storage_path: if self.storage_path:
try: try:
os.unlink(self.storage_path) os.unlink(self.storage_path)
except OSError, e: except OSError as e:
if e.errno != errno.ENOENT: if e.errno != errno.ENOENT:
raise raise
fd = os.open(self.storage_path, fd = os.open(self.storage_path,
os.O_CREAT | os.O_EXCL | os.O_WRONLY, 0600) os.O_CREAT | os.O_EXCL | os.O_WRONLY | os.O_TRUNC, 0600)
try: try:
os.write(fd, self.passwd) os.write(fd, self.passwd)
finally: finally:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment