diff options
Diffstat (limited to 'src/lib/Bcfg2')
-rw-r--r-- | src/lib/Bcfg2/Client/Tools/POSIX/File.py | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/lib/Bcfg2/Client/Tools/POSIX/File.py b/src/lib/Bcfg2/Client/Tools/POSIX/File.py index 40aade818..558d360b1 100644 --- a/src/lib/Bcfg2/Client/Tools/POSIX/File.py +++ b/src/lib/Bcfg2/Client/Tools/POSIX/File.py @@ -107,13 +107,16 @@ class POSIXFile(POSIXTool): (os.path.dirname(entry.get('name')), err)) return False try: - os.fdopen(newfd, 'w').write(filedata) - except (OSError, IOError): - err = sys.exc_info()[1] - self.logger.error("POSIX: Failed to open temp file %s for writing " - "%s: %s" % - (newfile, entry.get("name"), err)) - return False + try: + os.fdopen(newfd, 'w').write(filedata) + except (OSError, IOError): + err = sys.exc_info()[1] + self.logger.error("POSIX: Failed to open temp file %s for " + "writing %s: %s" % + (newfile, entry.get("name"), err)) + return False + finally: + os.close(newfd) return newfile def _rename_tmpfile(self, newfile, entry): |