Ensure tempfiles are chmod 600

This commit is contained in:
Brian May 2015-11-28 16:13:56 +11:00
parent 6dfbc467c0
commit 191df92824
2 changed files with 2 additions and 1 deletions

View File

@ -41,7 +41,7 @@ def rewrite_etc_hosts(port):
os.chmod(tmpname, st.st_mode) os.chmod(tmpname, st.st_mode)
else: else:
os.chown(tmpname, 0, 0) os.chown(tmpname, 0, 0)
os.chmod(tmpname, 0o644) os.chmod(tmpname, 0o600)
os.rename(tmpname, HOSTSFILE) os.rename(tmpname, HOSTSFILE)

View File

@ -37,6 +37,7 @@ def write_host_cache():
for name, ip in sorted(hostnames.items()): for name, ip in sorted(hostnames.items()):
f.write('%s,%s\n' % (name, ip)) f.write('%s,%s\n' % (name, ip))
f.close() f.close()
os.chmod(tmpname, 0o600)
os.rename(tmpname, CACHEFILE) os.rename(tmpname, CACHEFILE)
finally: finally:
try: try: