Impr: Properly integrate no-log with xorg/client log

This commit is contained in:
Gijs Burghoorn 2023-03-30 22:01:52 +02:00
parent 3084b778ab
commit a310466e68
5 changed files with 30 additions and 12 deletions

View file

@ -55,6 +55,9 @@ client_log_path = "/var/log/lemurs.client.log"
# Where to log to for the XServer.
xserver_log_path = "/var/log/lemurs.xorg.log"
# Disable all logging. This is overwritten by the `--no-log` flag.
no_log = false
# The PAM service that should be used to login
pam_service = "lemurs"

View file

@ -159,6 +159,8 @@ toml_config_struct! { Config, PartialConfig,
client_log_path => String,
xserver_log_path => String,
no_log => bool,
pam_service => String,
shell_login_flag => ShellLoginFlag,

View file

@ -141,6 +141,8 @@ fn main() -> Result<(), Box<dyn Error>> {
if !cli.no_log {
setup_logger(cli.preview);
info!("Lemurs logger is running");
} else {
config.no_log = true;
}
if !cli.preview {

View file

@ -172,13 +172,18 @@ impl PostLoginEnvironment {
ShellLoginFlag::Long => Some("--login"),
};
let client = lower_command_permissions_to_user(Command::new(SYSTEM_SHELL), user_info);
let mut client = lower_command_permissions_to_user(Command::new(SYSTEM_SHELL), user_info);
info!(
"Setup client to log `stdout` and `stderr` to '{log_path}'",
log_path = config.client_log_path
);
let mut client = output_command_to_log(client, Path::new(&config.client_log_path));
let mut client = if config.no_log {
client.stdout(Stdio::null()).stderr(Stdio::null());
client
} else {
info!(
"Setup client to log `stdout` and `stderr` to '{log_path}'",
log_path = config.client_log_path
);
output_command_to_log(client, Path::new(&config.client_log_path))
};
if let Some(shell_login_flag) = shell_login_flag {
client.arg(shell_login_flag);

View file

@ -135,12 +135,18 @@ pub fn setup_x(
libc::signal(SIGUSR1, SIG_IGN);
}
let child = Command::new(super::SYSTEM_SHELL);
info!(
"Setup XServer to log `stdout` and `stderr` to '{log_path}'",
log_path = config.xserver_log_path
);
let mut child = output_command_to_log(child, Path::new(&config.xserver_log_path));
let mut child = Command::new(super::SYSTEM_SHELL);
let mut child = if config.no_log {
child.stdout(Stdio::null()).stderr(Stdio::null());
child
} else {
info!(
"Setup XServer to log `stdout` and `stderr` to '{log_path}'",
log_path = config.xserver_log_path
);
output_command_to_log(child, Path::new(&config.xserver_log_path))
};
let mut child = child
.arg("-c")
.arg(format!("/usr/bin/X {display_value} vt{doubledigit_vtnr}"))