osrf / uctf

Unmanned Capture the Flag (U-CTF) project.
Apache License 2.0
24 stars 10 forks source link

race condition running sasc_deploy in parallel #108

Closed tfoote closed 7 years ago

tfoote commented 7 years ago

I think the other instance was writing it while this one was processing.

Likely just document not to run in parallel. I don't think there's much else to do.

Working on host 192.168.2.12
Traceback (most recent call last):
  File "/opt/sasc/bin/sasc_deploy", line 251, in <module>
    check_connection(ip)
  File "/opt/sasc/bin/sasc_deploy", line 159, in check_connection
    known_hosts = paramiko.hostkeys.HostKeys(KNOWN_HOSTS_FILE)
  File "/usr/lib/python2.7/dist-packages/paramiko/hostkeys.py", line 63, in __init__
    self.load(filename)
  File "/usr/lib/python2.7/dist-packages/paramiko/hostkeys.py", line 101, in load
    e = HostKeyEntry.from_line(line, lineno)
  File "/usr/lib/python2.7/dist-packages/paramiko/hostkeys.py", line 335, in from_line
    key = ECDSAKey(data=decodebytes(key), validate_point=False)
  File "/usr/lib/python2.7/dist-packages/paramiko/ecdsakey.py", line 70, in __init__
    validate_point=validate_point)
  File "/usr/lib/python2.7/dist-packages/ecdsa/keys.py", line 47, in from_string
    point = ellipticcurve.Point(curve.curve, x, y, order)
  File "/usr/lib/python2.7/dist-packages/ecdsa/ellipticcurve.py", line 73, in __init__
    if self.__curve: assert self.__curve.contains_point( x, y )
AssertionError
tfoote commented 7 years ago

It looks like a file lock on the known hosts file would be the right thing to do.

The best library for this looks to be at: https://fasteners.readthedocs.io/en/latest/examples.html#interprocess-locks