78 lines
2.6 KiB
Diff
78 lines
2.6 KiB
Diff
From 6c8906559cd049b14b08e4d3158338f6611f04e4 Mon Sep 17 00:00:00 2001
|
|
From: Firstyear <william@blackhats.net.au>
|
|
Date: Fri, 20 Aug 2021 09:18:50 +1000
|
|
Subject: [PATCH] Issue 4877 - RFE - EntryUUID to validate UUIDs on fixup
|
|
(#4878)
|
|
|
|
Bug Description: Due to changing the syntax of EntryUUID's
|
|
to string, we may have invalid EntryUUID's imported into
|
|
the database.
|
|
|
|
Fix Description: To resolve this during a fixup we validate
|
|
that Uuid's have a valid syntax. If they do not, we regenerate
|
|
them.
|
|
|
|
fixes: https://github.com/389ds/389-ds-base/issues/4877
|
|
|
|
Author: William Brown <william@blackhats.net.au>
|
|
|
|
Review by: @mreynolds389
|
|
---
|
|
src/plugins/entryuuid/src/lib.rs | 28 ++++++++++++++++++++--------
|
|
1 file changed, 20 insertions(+), 8 deletions(-)
|
|
|
|
diff --git a/src/plugins/entryuuid/src/lib.rs b/src/plugins/entryuuid/src/lib.rs
|
|
index 29a9f1258..ad3faef4b 100644
|
|
--- a/src/plugins/entryuuid/src/lib.rs
|
|
+++ b/src/plugins/entryuuid/src/lib.rs
|
|
@@ -144,11 +144,17 @@ impl SlapiPlugin3 for EntryUuid {
|
|
// Error if the first filter is empty?
|
|
|
|
// Now, to make things faster, we wrap the filter in a exclude term.
|
|
+
|
|
+ // 2021 - #4877 because we allow entryuuid to be strings, on import these may
|
|
+ // be invalid. As a result, we DO need to allow the fixup to check the entryuuid
|
|
+ // value is correct, so we can not exclude these during the search.
|
|
+ /*
|
|
let raw_filter = if !raw_filter.starts_with('(') && !raw_filter.ends_with('(') {
|
|
format!("(&({})(!(entryuuid=*)))", raw_filter)
|
|
} else {
|
|
format!("(&{}(!(entryuuid=*)))", raw_filter)
|
|
};
|
|
+ */
|
|
|
|
Ok(FixupData { basedn, raw_filter })
|
|
}
|
|
@@ -213,14 +219,20 @@ pub fn entryuuid_fixup_mapfn(e: &EntryRef, _data: &()) -> Result<(), PluginError
|
|
/* Supply a modification to the entry. */
|
|
let sdn = e.get_sdnref();
|
|
|
|
- /* Sanity check that entryuuid doesn't already exist */
|
|
- if e.contains_attr("entryUUID") {
|
|
- log_error!(
|
|
- ErrorLevel::Plugin,
|
|
- "skipping fixup for -> {}",
|
|
- sdn.to_dn_string()
|
|
- );
|
|
- return Ok(());
|
|
+ /* Check that entryuuid doesn't already exist, and is valid */
|
|
+ if let Some(valueset) = e.get_attr("entryUUID") {
|
|
+ if valueset.iter().all(|v| {
|
|
+ let u: Result<Uuid, _> = (&v).try_into();
|
|
+ u.is_ok()
|
|
+ }) {
|
|
+ // All values were valid uuid, move on!
|
|
+ log_error!(
|
|
+ ErrorLevel::Plugin,
|
|
+ "skipping fixup for -> {}",
|
|
+ sdn.to_dn_string()
|
|
+ );
|
|
+ return Ok(());
|
|
+ }
|
|
}
|
|
|
|
// Setup the modifications
|
|
--
|
|
2.31.1
|
|
|