Description: Added a basic check to see if the LDIF files are actually LDIF files. Also added checks that the database RUV are present as well.
https://pagure.io/389-ds-base/issue/49840
Reviewed by: ?
I think it will be better if verify_ldif_file will check the whole file. It doesn't cost us much but saves us from many issues in the future.
We can improve it with something like this (ldif is part of python-ldap):
ldif
with open("/tmp/export_master2.ldif", 'rb') as f: ldif.LDIFRecordList(f).parse()
It will throw an error if the ldif file is bad:
Traceback (most recent call last): File "<stdin>", line 2, in <module> File "/usr/lib64/python3.6/site-packages/ldif.py", line 461, in parse return self.parse_entry_records() # parse() File "/usr/lib64/python3.6/site-packages/ldif.py", line 425, in parse_entry_records raise ValueError('Line %d: First line of record does not start with "dn:": %s' % (self.line_counter,repr(k))) ValueError: Line 28: First line of record does not start with "dn:": 'modifyTimestamp'
If you'll catch it like this, we can have a clean logged error:
with open("/tmp/export_master2.ldif", 'rb') as f: try: ldif.LDIFRecordList(f).parse() except ValueError as e: print(e)
It will print Line 28: First line of record does not start with "dn:": 'modifyTimestamp'
Line 28: First line of record does not start with "dn:": 'modifyTimestamp'
rebased onto a8dd789b1d18105536aca622edc250ddf2273491
@spichugi changes made, thanks!
Couple of small issues here... First, I think you need to reset the cursor somewhere here, because 'get_dns(MLDIF, opts)' fails overwise. LDIFRecordList will read the data from MLDIF and RLDIF and the cursor will be in the end of the file.
Second, if the LDIFRecordList().parse() fails then we don't close() the MLDIF and RLDIF files...
Overwise, looks good to me!
rebased onto 8ed778bee9a76d812eea89a25904dc52154c017d
@spichugi - fixed, please review
rebased onto 5d2c2a198e4a54fd8c092bde28e1829e97f36296
thanks! Ack
rebased onto 60cb52040704686d9541a2e2eb2765d86cb10af2
Pull-Request has been merged by mreynolds
389-ds-base is moving from Pagure to Github. This means that new issues and pull requests will be accepted only in 389-ds-base's github repository.
This pull request has been cloned to Github as issue and is available here: - https://github.com/389ds/389-ds-base/issues/2900
If you want to continue to work on the PR, please navigate to the github issue, download the patch from the attachments and file a new pull request.
Thank you for understanding. We apologize for all inconvenience.
Pull-Request has been closed by spichugi
Description: Added a basic check to see if the LDIF files are actually
LDIF files. Also added checks that the database RUV are
present as well.
https://pagure.io/389-ds-base/issue/49840
Reviewed by: ?