Revision 4cc2a728 lib/cmdlib.py
b/lib/cmdlib.py | ||
---|---|---|
386 | 386 |
add_lines = [] |
387 | 387 |
removed = False |
388 | 388 |
|
389 |
while True: |
|
390 |
rawline = f.readline() |
|
389 |
for rawline in f: |
|
391 | 390 |
logger.Debug('read %s' % (repr(rawline),)) |
392 | 391 |
|
393 |
if not rawline: |
|
394 |
# End of file |
|
395 |
break |
|
396 |
|
|
397 |
line = rawline.split('\n')[0] |
|
398 |
|
|
399 |
parts = line.split(' ') |
|
400 |
fields = parts[0].split(',') |
|
401 |
key = parts[2] |
|
402 |
|
|
403 |
haveall = True |
|
404 |
havesome = False |
|
405 |
for spec in [ ip, fullnode ]: |
|
406 |
if spec not in fields: |
|
407 |
haveall = False |
|
408 |
if spec in fields: |
|
409 |
havesome = True |
|
410 |
|
|
411 |
logger.Debug("key, pubkey = %s." % (repr((key, pubkey)),)) |
|
412 |
if haveall and key == pubkey: |
|
413 |
inthere = True |
|
414 |
save_lines.append(rawline) |
|
415 |
logger.Debug("Keeping known_hosts '%s'." % (repr(rawline),)) |
|
416 |
continue |
|
392 |
parts = rawline.rstrip('\r\n').split() |
|
393 |
|
|
394 |
# Ignore unwanted lines |
|
395 |
if len(parts) >= 3 and not rawline.lstrip()[0] == '#': |
|
396 |
fields = parts[0].split(',') |
|
397 |
key = parts[2] |
|
398 |
|
|
399 |
haveall = True |
|
400 |
havesome = False |
|
401 |
for spec in [ ip, fullnode ]: |
|
402 |
if spec not in fields: |
|
403 |
haveall = False |
|
404 |
if spec in fields: |
|
405 |
havesome = True |
|
406 |
|
|
407 |
logger.Debug("key, pubkey = %s." % (repr((key, pubkey)),)) |
|
408 |
if haveall and key == pubkey: |
|
409 |
inthere = True |
|
410 |
save_lines.append(rawline) |
|
411 |
logger.Debug("Keeping known_hosts '%s'." % (repr(rawline),)) |
|
412 |
continue |
|
417 | 413 |
|
418 |
if havesome and (not haveall or key != pubkey): |
|
419 |
removed = True |
|
420 |
logger.Debug("Discarding known_hosts '%s'." % (repr(rawline),)) |
|
421 |
continue |
|
414 |
if havesome and (not haveall or key != pubkey):
|
|
415 |
removed = True
|
|
416 |
logger.Debug("Discarding known_hosts '%s'." % (repr(rawline),))
|
|
417 |
continue
|
|
422 | 418 |
|
423 | 419 |
save_lines.append(rawline) |
424 | 420 |
|
Also available in: Unified diff