mirror of
https://github.com/stalwartlabs/mail-server.git
synced 2024-11-28 09:07:32 +00:00
Resolve file macros after dropping root privileges
This commit is contained in:
parent
8a07a8133e
commit
53e6c352d8
3 changed files with 12 additions and 5 deletions
|
@ -144,8 +144,8 @@ impl BootManager {
|
|||
}
|
||||
let cfg_local = config.keys.clone();
|
||||
|
||||
// Resolve macros
|
||||
config.resolve_macros().await;
|
||||
// Resolve environment macros
|
||||
config.resolve_macros(&["env"]).await;
|
||||
|
||||
// Parser servers
|
||||
let mut servers = Servers::parse(&mut config);
|
||||
|
@ -153,6 +153,9 @@ impl BootManager {
|
|||
// Bind ports and drop privileges
|
||||
servers.bind_and_drop_priv(&mut config);
|
||||
|
||||
// Resolve file and configuration macros
|
||||
config.resolve_macros(&["file", "cfg"]).await;
|
||||
|
||||
// Load stores
|
||||
let mut stores = Stores::parse(&mut config).await;
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ impl ConfigManager {
|
|||
keys: self.cfg_local.load().as_ref().clone(),
|
||||
..Default::default()
|
||||
};
|
||||
config.resolve_macros().await;
|
||||
config.resolve_all_macros().await;
|
||||
self.extend_config(&mut config, prefix)
|
||||
.await
|
||||
.map(|_| config)
|
||||
|
|
|
@ -74,12 +74,16 @@ pub struct Rate {
|
|||
pub type Result<T> = std::result::Result<T, String>;
|
||||
|
||||
impl Config {
|
||||
pub async fn resolve_macros(&mut self) {
|
||||
for macro_class in ["env", "file", "cfg"] {
|
||||
pub async fn resolve_macros(&mut self, classes: &[&str]) {
|
||||
for macro_class in classes {
|
||||
self.resolve_macro_type(macro_class).await;
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn resolve_all_macros(&mut self) {
|
||||
self.resolve_macros(&["env", "file", "cfg"]).await;
|
||||
}
|
||||
|
||||
async fn resolve_macro_type(&mut self, class: &str) {
|
||||
let macro_start = format!("%{{{class}:");
|
||||
let mut replacements = AHashMap::new();
|
||||
|
|
Loading…
Reference in a new issue