Browse code

Improve simple-to-full layout conversion.

Xavier G authored on 26/04/2020 19:14:49
Showing 1 changed files

  • yamltab index afe12a5..4528ce4 100755
... ...
@@ -420,7 +420,9 @@ def simple_principal_to_full(inentry, index, entry):
420 420
 				message = 'Invalid or unknown name_type specified in entry #%d'
421 421
 				message += '; use name_type_raw to enforce an arbitrary value'
422 422
 				raise KeytabParsingError(message % index)
423
+		entry['spn'] = principal_to_spn(principal)
423 424
 	elif 'spn' in inentry:
425
+		entry['spn'] = inentry['spn']
424 426
 		entry['principal'] = spn_to_principal(inentry['spn'])
425 427
 
426 428
 def simple_kvno_to_full(inentry, index, entry, record):
... ...
@@ -439,6 +441,7 @@ def simple_timestamp_to_full(inentry, index, entry):
439 441
 	if 'timestamp' in inentry:
440 442
 		entry['timestamp'] = inentry['timestamp']
441 443
 	elif 'date' in inentry:
444
+		entry['date'] = inentry['date']
442 445
 		if inentry['date'] == 'now':
443 446
 			entry['timestamp'] = now
444 447
 		else:
... ...
@@ -452,6 +455,7 @@ def simple_enctype_to_full(inentry, index,  entry):
452 455
 	if 'enctype_raw' in inentry:
453 456
 		entry['enctype_raw'] = inentry['enctype_raw']
454 457
 	elif 'enctype' in inentry:
458
+		entry['enctype'] = inentry['enctype']
455 459
 		try:
456 460
 			entry['enctype_raw'] = ENC_TYPES[inentry['enctype']]
457 461
 		except KeyError:
... ...
@@ -467,13 +471,14 @@ def simple_keytab_to_full(indata):
467 471
 	}
468 472
 	for index, inentry in enumerate(indata.get('entries', [])):
469 473
 		entry = {}
470
-		record = {'entry': entry}
474
+		record = {'type': 'record', 'entry': entry, 'tail': b''}
471 475
 		simple_principal_to_full(inentry, index, entry)
472 476
 		simple_kvno_to_full(inentry, index, entry, record)
473 477
 		simple_timestamp_to_full(inentry, index, entry)
474 478
 		simple_enctype_to_full(inentry, index, entry)
475 479
 		if 'key' in inentry:
476 480
 			entry['key'] = inentry['key']
481
+			entry['key_length'] = len(unhexlify(inentry['key']))
477 482
 		data['records'].append(record)
478 483
 	return data
479 484