Skip to main content

open_log_file

Function open_log_file 

Source
fn open_log_file(
    log_file: &Path,
    text_logs: bool,
    uses_intro: bool,
) -> Result<File>
Expand description

Opens log_file for appending, and creates its directory if it doesn’t exist.

Plain text notices are printed only with text logs, because log collectors usually read standard output and standard error as well. Opening the file reports any error.

§Security

If the user is running Zebra with elevated permissions (“root”), they should create the log file directory before running Zebra, and make sure the Zebra user account has exclusive access to that directory, and other users can’t modify its parent directories.

This avoids a TOCTOU security issue in the Rust filesystem API.