mirror of
https://github.com/kanidm/kanidm.git
synced 2025-04-30 06:05:04 +02:00
Update fs4 and improve klock handling (#3551)
This commit is contained in:
parent
5458b13398
commit
aee9ed05f3
8
Cargo.lock
generated
8
Cargo.lock
generated
|
@ -1600,12 +1600,12 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fs4"
|
name = "fs4"
|
||||||
version = "0.12.0"
|
version = "0.13.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c29c30684418547d476f0b48e84f4821639119c483b1eccd566c8cd0cd05f521"
|
checksum = "8640e34b88f7652208ce9e88b1a37a2ae95227d84abec377ccd3c5cfeb141ed4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"rustix 0.38.44",
|
"rustix 1.0.3",
|
||||||
"windows-sys 0.52.0",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
@ -173,7 +173,7 @@ dhat = "0.3.3"
|
||||||
dyn-clone = "^1.0.17"
|
dyn-clone = "^1.0.17"
|
||||||
fernet = "^0.2.1"
|
fernet = "^0.2.1"
|
||||||
filetime = "^0.2.24"
|
filetime = "^0.2.24"
|
||||||
fs4 = "^0.12.0"
|
fs4 = "^0.13.0"
|
||||||
futures = "^0.3.31"
|
futures = "^0.3.31"
|
||||||
futures-util = { version = "^0.3.30", features = ["sink"] }
|
futures-util = { version = "^0.3.30", features = ["sink"] }
|
||||||
gix = { version = "0.64.0", default-features = false }
|
gix = { version = "0.64.0", default-features = false }
|
||||||
|
|
|
@ -465,13 +465,13 @@ async fn start_daemon(opt: KanidmdParser, config: Configuration) -> ExitCode {
|
||||||
return ExitCode::FAILURE;
|
return ExitCode::FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
match &opt.commands {
|
let lock_was_setup = match &opt.commands {
|
||||||
// we aren't going to touch the DB so we can carry on
|
// we aren't going to touch the DB so we can carry on
|
||||||
KanidmdOpt::ShowReplicationCertificate { .. }
|
KanidmdOpt::ShowReplicationCertificate { .. }
|
||||||
| KanidmdOpt::RenewReplicationCertificate { .. }
|
| KanidmdOpt::RenewReplicationCertificate { .. }
|
||||||
| KanidmdOpt::RefreshReplicationConsumer { .. }
|
| KanidmdOpt::RefreshReplicationConsumer { .. }
|
||||||
| KanidmdOpt::RecoverAccount { .. }
|
| KanidmdOpt::RecoverAccount { .. }
|
||||||
| KanidmdOpt::HealthCheck(_) => (),
|
| KanidmdOpt::HealthCheck(_) => None,
|
||||||
_ => {
|
_ => {
|
||||||
// Okay - Lets now create our lock and go.
|
// Okay - Lets now create our lock and go.
|
||||||
#[allow(clippy::expect_used)]
|
#[allow(clippy::expect_used)]
|
||||||
|
@ -482,24 +482,53 @@ async fn start_daemon(opt: KanidmdParser, config: Configuration) -> ExitCode {
|
||||||
|
|
||||||
let flock = match File::create(&klock_path) {
|
let flock = match File::create(&klock_path) {
|
||||||
Ok(flock) => flock,
|
Ok(flock) => flock,
|
||||||
Err(e) => {
|
Err(err) => {
|
||||||
error!("ERROR: Refusing to start - unable to create kanidmd exclusive lock at {} - {:?}", klock_path.display(), e);
|
error!(
|
||||||
|
"ERROR: Refusing to start - unable to create kanidmd exclusive lock at {}",
|
||||||
|
klock_path.display()
|
||||||
|
);
|
||||||
|
error!(?err);
|
||||||
return ExitCode::FAILURE;
|
return ExitCode::FAILURE;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
match flock.try_lock_exclusive() {
|
match flock.try_lock_exclusive() {
|
||||||
Ok(()) => debug!("Acquired kanidm exclusive lock"),
|
Ok(true) => debug!("Acquired kanidm exclusive lock"),
|
||||||
Err(e) => {
|
Ok(false) => {
|
||||||
error!("ERROR: Refusing to start - unable to lock kanidmd exclusive lock at {} - {:?}", klock_path.display(), e);
|
error!(
|
||||||
|
"ERROR: Refusing to start - unable to lock kanidmd exclusive lock at {}",
|
||||||
|
klock_path.display()
|
||||||
|
);
|
||||||
error!("Is another kanidmd process running?");
|
error!("Is another kanidmd process running?");
|
||||||
return ExitCode::FAILURE;
|
return ExitCode::FAILURE;
|
||||||
}
|
}
|
||||||
|
Err(err) => {
|
||||||
|
error!(
|
||||||
|
"ERROR: Refusing to start - unable to lock kanidmd exclusive lock at {}",
|
||||||
|
klock_path.display()
|
||||||
|
);
|
||||||
|
error!(?err);
|
||||||
|
return ExitCode::FAILURE;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Some(klock_path)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let result_code = kanidm_main(config, opt).await;
|
||||||
|
|
||||||
|
if let Some(klock_path) = lock_was_setup {
|
||||||
|
if let Err(reason) = std::fs::remove_file(&klock_path) {
|
||||||
|
warn!(
|
||||||
|
?reason,
|
||||||
|
"WARNING: Unable to clean up kanidmd exclusive lock at {}",
|
||||||
|
klock_path.display()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
kanidm_main(config, opt).await
|
result_code
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> ExitCode {
|
fn main() -> ExitCode {
|
||||||
|
|
Loading…
Reference in a new issue