Don't error trying to cleanup missing persistence file.

pull/1600/head
Roger A. Light 6 years ago
parent 04cf0cdf2d
commit b5193c84d2

@ -3,6 +3,7 @@
# Test for CVE-2018-12546, with the broker being stopped to write the persistence file, plus subscriber on different port. # Test for CVE-2018-12546, with the broker being stopped to write the persistence file, plus subscriber on different port.
from mosq_test_helper import * from mosq_test_helper import *
import os.path
import signal import signal
def write_config(filename, port1, port2, per_listener): def write_config(filename, port1, port2, per_listener):
@ -79,6 +80,8 @@ def do_test(per_listener, username):
write_acl_2(acl_file, username) write_acl_2(acl_file, username)
broker.terminate() broker.terminate()
broker.wait() broker.wait()
if os.path.isfile(persistence_file) == False:
raise FileNotFoundError("Persistence file not written")
broker = mosq_test.start_broker(filename=os.path.basename(__file__), use_conf=True, port=port1) broker = mosq_test.start_broker(filename=os.path.basename(__file__), use_conf=True, port=port1)
@ -94,7 +97,10 @@ def do_test(per_listener, username):
broker.wait() broker.wait()
os.remove(conf_file) os.remove(conf_file)
os.remove(acl_file) os.remove(acl_file)
try:
os.remove(persistence_file) os.remove(persistence_file)
except FileNotFoundError:
pass
(stdo, stde) = broker.communicate() (stdo, stde) = broker.communicate()
if rc: if rc:
print(stde.decode('utf-8')) print(stde.decode('utf-8'))

Loading…
Cancel
Save