mirror of
https://github.com/kanidm/kanidm.git
synced 2025-02-23 12:37:00 +01:00
Update assert to debug assert, add Makefile, and resolve an issue with reindexing
This commit is contained in:
parent
000a24b49e
commit
e670924324
11
Makefile
Normal file
11
Makefile
Normal file
|
@ -0,0 +1,11 @@
|
|||
|
||||
docker-kanidmd:
|
||||
docker build -f kanidmd/Dockerfile -t kanidmd:latest .
|
||||
|
||||
docker-radiusd:
|
||||
docker build -f kanidm_rlm_python/Dockerfile -t kanidm_radius:latest kanidm_rlm_python
|
||||
|
||||
vendor-prep:
|
||||
cargo vendor
|
||||
tar -czf vendor.tar.gz vendor
|
||||
|
|
@ -174,6 +174,13 @@ pub trait IdlSqliteTransaction {
|
|||
// have a corrupted index .....
|
||||
None => IDLBitRange::new(),
|
||||
};
|
||||
audit_log!(
|
||||
audit,
|
||||
"Got idl for index {:?} {:?} -> {:?}",
|
||||
itype,
|
||||
attr,
|
||||
idl
|
||||
);
|
||||
|
||||
Ok(Some(idl))
|
||||
}
|
||||
|
@ -497,7 +504,7 @@ impl IdlSqliteWriteTransaction {
|
|||
audit_log!(audit, "removing idx_table -> {:?}", idx_table);
|
||||
self.conn
|
||||
.prepare(format!("DROP TABLE {}", idx_table).as_str())
|
||||
.and_then(|mut stmt| stmt.query(NO_PARAMS).map(|_| ()))
|
||||
.and_then(|mut stmt| stmt.execute(NO_PARAMS).map(|_| ()))
|
||||
.map_err(|e| {
|
||||
audit_log!(audit, "sqlite error {:?}", e);
|
||||
OperationError::SQLiteError
|
||||
|
@ -512,6 +519,7 @@ impl IdlSqliteWriteTransaction {
|
|||
"rustqlite error {:?}",
|
||||
OperationError::SQLiteError
|
||||
);
|
||||
audit_log!(audit, "purge id2entry ...");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
@ -474,7 +474,9 @@ impl BackendWriteTransaction {
|
|||
.into_iter()
|
||||
.map(|e| {
|
||||
id_max = id_max + 1;
|
||||
e.to_valid_committed_id(id_max)
|
||||
let ev = e.to_valid_committed_id(id_max);
|
||||
// audit_log!(au, "assigned {} to {}", id_max, ev.get_uuid());
|
||||
ev
|
||||
})
|
||||
.collect();
|
||||
|
||||
|
@ -809,6 +811,35 @@ impl BackendWriteTransaction {
|
|||
OperationError::SerdeJsonError
|
||||
);
|
||||
|
||||
// Filter all elements that have a UUID in the system range.
|
||||
/*
|
||||
use crate::constants::UUID_ANONYMOUS;
|
||||
use crate::be::dbentry::DbEntryVers;
|
||||
use crate::be::dbvalue::DbValueV1;
|
||||
let uuid_anonymous = UUID_ANONYMOUS.clone();
|
||||
let dbentries: Vec<DbEntry> = dbentries.into_iter()
|
||||
.filter(|e| {
|
||||
let e_uuid = match &e.ent {
|
||||
DbEntryVers::V1(dbe) => dbe.attrs.get("uuid")
|
||||
.and_then(|dbvs| dbvs.first())
|
||||
.and_then(|dbv| {
|
||||
match dbv {
|
||||
DbValueV1::UU(u) => Some(u),
|
||||
_ => panic!(),
|
||||
}
|
||||
})
|
||||
.unwrap()
|
||||
};
|
||||
|
||||
e_uuid > &uuid_anonymous
|
||||
})
|
||||
.collect();
|
||||
|
||||
dbentries.iter().for_each(|e| {
|
||||
audit_log!(audit, "importing -> {:?}", e);
|
||||
});
|
||||
*/
|
||||
|
||||
// Now, we setup all the entries with new ids.
|
||||
let mut id_max = 0;
|
||||
let identries: Result<Vec<IdEntry>, _> = dbentries
|
||||
|
@ -827,6 +858,16 @@ impl BackendWriteTransaction {
|
|||
|
||||
self.idlayer.write_identries(audit, identries?)?;
|
||||
|
||||
// for debug
|
||||
/*
|
||||
self.idlayer.get_identry(audit, &IDL::ALLIDS)
|
||||
.unwrap()
|
||||
.iter()
|
||||
.for_each(|dbe| {
|
||||
audit_log!(audit, "dbe -> {:?}", dbe.id);
|
||||
});
|
||||
*/
|
||||
|
||||
// Reindex now we are loaded.
|
||||
self.reindex(audit)?;
|
||||
|
||||
|
|
|
@ -1108,15 +1108,9 @@ impl SchemaInner {
|
|||
uuid: Uuid::parse_str(UUID_SCHEMA_CLASS_ACCESS_CONTROL_PROFILE)
|
||||
.expect("unable to parse static uuid"),
|
||||
description: String::from("System Access Control Profile Class"),
|
||||
systemmay: vec![
|
||||
"acp_enable".to_string(),
|
||||
"description".to_string()
|
||||
],
|
||||
systemmay: vec!["acp_enable".to_string(), "description".to_string()],
|
||||
may: vec![],
|
||||
systemmust: vec![
|
||||
"acp_receiver".to_string(),
|
||||
"acp_targetscope".to_string(),
|
||||
],
|
||||
systemmust: vec!["acp_receiver".to_string(), "acp_targetscope".to_string()],
|
||||
must: vec![],
|
||||
},
|
||||
);
|
||||
|
|
|
@ -1477,7 +1477,7 @@ impl<'a> QueryServerWriteTransaction<'a> {
|
|||
|e: Entry<EntryInvalid, EntryNew>| self.internal_migrate_or_create(audit, e)
|
||||
));
|
||||
audit_log!(audit, "internal_migrate_or_create_str -> result {:?}", res);
|
||||
assert!(res.is_ok());
|
||||
debug_assert!(res.is_ok());
|
||||
res
|
||||
}
|
||||
|
||||
|
@ -1495,6 +1495,12 @@ impl<'a> QueryServerWriteTransaction<'a> {
|
|||
//
|
||||
// NOTE: gen modlist IS schema aware and will handle multivalue
|
||||
// correctly!
|
||||
audit_log!(
|
||||
audit,
|
||||
"internal_migrate_or_create operating on {:?}",
|
||||
e.get_uuid()
|
||||
);
|
||||
|
||||
let filt = match e.filter_from_attrs(&vec![String::from("uuid")]) {
|
||||
Some(f) => f,
|
||||
None => return Err(OperationError::FilterGeneration),
|
||||
|
@ -1541,7 +1547,7 @@ impl<'a> QueryServerWriteTransaction<'a> {
|
|||
|e: Entry<EntryValid, EntryNew>| self.internal_assert_or_create(audit, e)
|
||||
));
|
||||
audit_log!(audit, "internal_assert_or_create_str -> result {:?}", res);
|
||||
assert!(res.is_ok());
|
||||
debug_assert!(res.is_ok());
|
||||
res
|
||||
}
|
||||
|
||||
|
@ -1555,6 +1561,12 @@ impl<'a> QueryServerWriteTransaction<'a> {
|
|||
// else, if not exists, create it. IE no extra or excess
|
||||
// attributes and classes.
|
||||
|
||||
audit_log!(
|
||||
audit,
|
||||
"internal_assert_or_create operating on {:?}",
|
||||
e.get_uuid()
|
||||
);
|
||||
|
||||
// Create a filter from the entry for assertion.
|
||||
let filt = match e.filter_from_attrs(&vec![String::from("uuid")]) {
|
||||
Some(f) => f,
|
||||
|
@ -1601,7 +1613,8 @@ impl<'a> QueryServerWriteTransaction<'a> {
|
|||
self.internal_migrate_or_create(audit, e.invalidate())
|
||||
})
|
||||
.collect();
|
||||
assert!(r.is_ok());
|
||||
audit_log!(audit, "initialise_schema_core -> result {:?}", r);
|
||||
debug_assert!(r.is_ok());
|
||||
r
|
||||
}
|
||||
|
||||
|
@ -1633,7 +1646,8 @@ impl<'a> QueryServerWriteTransaction<'a> {
|
|||
.map(|e_str| self.internal_migrate_or_create_str(&mut audit_si, e_str))
|
||||
.collect();
|
||||
audit.append_scope(audit_si);
|
||||
assert!(r.is_ok());
|
||||
audit_log!(audit, "initialise_schema_idm -> result {:?}", r);
|
||||
debug_assert!(r.is_ok());
|
||||
|
||||
r.map(|_| ())
|
||||
}
|
||||
|
@ -1648,7 +1662,8 @@ impl<'a> QueryServerWriteTransaction<'a> {
|
|||
.internal_assert_or_create_str(&mut audit_an, JSON_SYSTEM_INFO_V1)
|
||||
.and_then(|_| self.internal_migrate_or_create_str(&mut audit_an, JSON_DOMAIN_INFO_V1));
|
||||
audit.append_scope(audit_an);
|
||||
assert!(res.is_ok());
|
||||
audit_log!(audit, "initialise_idm p1 -> result {:?}", res);
|
||||
debug_assert!(res.is_ok());
|
||||
if res.is_err() {
|
||||
return res;
|
||||
}
|
||||
|
@ -1672,7 +1687,8 @@ impl<'a> QueryServerWriteTransaction<'a> {
|
|||
.map(|e_str| self.internal_migrate_or_create_str(&mut audit_an, e_str))
|
||||
.collect();
|
||||
audit.append_scope(audit_an);
|
||||
assert!(res.is_ok());
|
||||
audit_log!(audit, "initialise_idm p2 -> result {:?}", res);
|
||||
debug_assert!(res.is_ok());
|
||||
if res.is_err() {
|
||||
return res;
|
||||
}
|
||||
|
@ -1735,7 +1751,8 @@ impl<'a> QueryServerWriteTransaction<'a> {
|
|||
.map(|e_str| self.internal_migrate_or_create_str(&mut audit_an, e_str))
|
||||
.collect();
|
||||
audit.append_scope(audit_an);
|
||||
assert!(res.is_ok());
|
||||
audit_log!(audit, "initialise_idm p3 -> result {:?}", res);
|
||||
debug_assert!(res.is_ok());
|
||||
if res.is_err() {
|
||||
return res;
|
||||
}
|
||||
|
@ -1912,7 +1929,7 @@ impl<'a> QueryServerWriteTransaction<'a> {
|
|||
changed_schema: _,
|
||||
changed_acp: _,
|
||||
} = self;
|
||||
assert!(!committed);
|
||||
debug_assert!(!committed);
|
||||
// Begin an audit.
|
||||
// Validate the schema as we just loaded it.
|
||||
let r = schema.validate(audit);
|
||||
|
|
Loading…
Reference in a new issue