config: Skip reading config in session worker
The decision to start a session worker or main process is taken after the config module has been queried. This means that the regular process for loading config files is also run. This can lead to errors if the config file is not in the default location, as the session worker does not receive the config argument. Skip reading config files if the session-worker flag is set.
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
use std::{collections::HashMap, env, fs::read_to_string};
|
use std::{collections::HashMap, default::Default, env, fs::read_to_string};
|
||||||
|
|
||||||
use enquote::unquote;
|
use enquote::unquote;
|
||||||
use getopts::Options;
|
use getopts::Options;
|
||||||
@@ -13,23 +13,29 @@ pub enum VtSelection {
|
|||||||
Specific(usize),
|
Specific(usize),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Eq, PartialEq)]
|
impl Default for VtSelection {
|
||||||
|
fn default() -> Self {
|
||||||
|
VtSelection::None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Eq, PartialEq, Default)]
|
||||||
pub struct ConfigSession {
|
pub struct ConfigSession {
|
||||||
pub command: String,
|
pub command: String,
|
||||||
pub user: String,
|
pub user: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Eq, PartialEq)]
|
#[derive(Debug, Eq, PartialEq, Default)]
|
||||||
pub struct ConfigInternal {
|
pub struct ConfigInternal {
|
||||||
pub session_worker: usize,
|
pub session_worker: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Eq, PartialEq)]
|
#[derive(Debug, Eq, PartialEq, Default)]
|
||||||
pub struct ConfigTerminal {
|
pub struct ConfigTerminal {
|
||||||
pub vt: VtSelection,
|
pub vt: VtSelection,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Eq, PartialEq)]
|
#[derive(Debug, Eq, PartialEq, Default)]
|
||||||
pub struct ConfigFile {
|
pub struct ConfigFile {
|
||||||
pub terminal: ConfigTerminal,
|
pub terminal: ConfigTerminal,
|
||||||
pub default_session: ConfigSession,
|
pub default_session: ConfigSession,
|
||||||
@@ -197,6 +203,13 @@ pub fn read_config() -> Result<Config, Error> {
|
|||||||
.unwrap_or(0),
|
.unwrap_or(0),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if internal.session_worker > 0 {
|
||||||
|
return Ok(Config {
|
||||||
|
file: Default::default(),
|
||||||
|
internal,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
let config_str = match matches.opt_str("config") {
|
let config_str = match matches.opt_str("config") {
|
||||||
Some(v) => read_to_string(v),
|
Some(v) => read_to_string(v),
|
||||||
None => read_to_string("/etc/greetd/greetd.conf")
|
None => read_to_string("/etc/greetd/greetd.conf")
|
||||||
|
Reference in New Issue
Block a user