actually remove the shadow line and fix a final newline
This commit is contained in:
parent
bacbfae4d1
commit
6389bb988d
@ -85,6 +85,7 @@ impl LockedFileGuard {
|
|||||||
self.file
|
self.file
|
||||||
.write_all(&new_content.into_bytes())
|
.write_all(&new_content.into_bytes())
|
||||||
.expect("Failed to write all users.");
|
.expect("Failed to write all users.");
|
||||||
|
let _ = self.file.write("\n".as_bytes());
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,6 +116,25 @@ impl UserDBWrite for UserDBLocal {
|
|||||||
let ncont = locked_p.replace_contents(modified_p);
|
let ncont = locked_p.replace_contents(modified_p);
|
||||||
match ncont {
|
match ncont {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
|
let shad = user.get_shadow();
|
||||||
|
match shad {
|
||||||
|
Some(shadow) => {
|
||||||
|
let modified_s = shadow.remove_in(&s);
|
||||||
|
let ncont = locked_s.replace_contents(modified_s);
|
||||||
|
match ncont {
|
||||||
|
Ok(_) => (),
|
||||||
|
Err(e) => {
|
||||||
|
return Err(format!(
|
||||||
|
"Error during write to the database. \
|
||||||
|
Please doublecheck as the shadowdatabase could be corrupted: {}",
|
||||||
|
e,
|
||||||
|
)
|
||||||
|
.into());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None => (),
|
||||||
|
}
|
||||||
// Remove the user from the memory database(HashMap)
|
// Remove the user from the memory database(HashMap)
|
||||||
let res = self.users.remove(username);
|
let res = self.users.remove(username);
|
||||||
return Ok(
|
return Ok(
|
||||||
|
Loading…
Reference in New Issue
Block a user