mirror of
https://github.com/sshuttle/sshuttle.git
synced 2024-11-25 01:13:37 +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:
|
try:
|
||||||
os.link(HOSTSFILE, BAKFILE)
|
os.link(HOSTSFILE, BAKFILE)
|
||||||
except OSError:
|
except OSError:
|
||||||
|
# file is locked - performing non-atomic copy
|
||||||
shutil.copyfile(HOSTSFILE, BAKFILE)
|
shutil.copyfile(HOSTSFILE, BAKFILE)
|
||||||
tmpname = "%s.%d.tmp" % (HOSTSFILE, port)
|
tmpname = "%s.%d.tmp" % (HOSTSFILE, port)
|
||||||
f = open(tmpname, 'w')
|
f = open(tmpname, 'w')
|
||||||
@ -54,6 +55,9 @@ def rewrite_etc_hosts(hostmap, port):
|
|||||||
try:
|
try:
|
||||||
os.rename(tmpname, HOSTSFILE)
|
os.rename(tmpname, HOSTSFILE)
|
||||||
except OSError:
|
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)
|
shutil.move(tmpname, HOSTSFILE)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user