mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-03-31 17:55:36 +00:00
Return anyhow::Result on PrivDropper waiting and socket creation
This commit is contained in:
parent
02ba4ec922
commit
cb2f7483d3
4 changed files with 41 additions and 37 deletions
|
|
@ -3,6 +3,7 @@ use std::{
|
|||
sync::{Arc, Barrier},
|
||||
};
|
||||
|
||||
use anyhow::Context;
|
||||
use privdrop::PrivDrop;
|
||||
use serde::Deserialize;
|
||||
|
||||
|
|
@ -46,7 +47,7 @@ impl PrivilegeDropper {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn after_socket_creation(&self) {
|
||||
pub fn after_socket_creation(&self) -> anyhow::Result<()> {
|
||||
if self.config.drop_privileges {
|
||||
if self.barrier.wait().is_leader() {
|
||||
PrivDrop::default()
|
||||
|
|
@ -54,8 +55,10 @@ impl PrivilegeDropper {
|
|||
.group(self.config.group.clone())
|
||||
.user(self.config.user.clone())
|
||||
.apply()
|
||||
.expect("drop privileges");
|
||||
.with_context(|| "drop privileges")?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue