mirror of
https://github.com/sshuttle/sshuttle.git
synced 2024-12-26 16:48:52 +01:00
add comment and warning
This commit is contained in:
parent
1def53e085
commit
93200f7095
@ -34,6 +34,7 @@ def rewrite_etc_hosts(hostmap, port):
|
||||
try:
|
||||
os.link(HOSTSFILE, BAKFILE)
|
||||
except OSError:
|
||||
# file is locked - performing non-atomic copy
|
||||
shutil.copyfile(HOSTSFILE, BAKFILE)
|
||||
tmpname = "%s.%d.tmp" % (HOSTSFILE, port)
|
||||
f = open(tmpname, 'w')
|
||||
@ -54,6 +55,9 @@ def rewrite_etc_hosts(hostmap, port):
|
||||
try:
|
||||
os.rename(tmpname, HOSTSFILE)
|
||||
except OSError:
|
||||
# file is locked - performing non-atomic copy
|
||||
log('Warning: Using a non-atomic way to overwrite %s that can corrupt the file if '
|
||||
'multiple processes write to it simultaneously.' % HOSTSFILE)
|
||||
shutil.move(tmpname, HOSTSFILE)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user