Preserve current umask (#777)
* preserve umask when starting server * make sure log files are created with explicit permissions
This commit is contained in:
parent
21901c6e79
commit
45af3e4279
3 changed files with 11 additions and 5 deletions
|
|
@ -13,7 +13,6 @@ use zellij_client::{os_input_output::get_client_os_input, start_client, ClientIn
|
|||
use zellij_server::{os_input_output::get_server_os_input, start_server};
|
||||
use zellij_utils::{
|
||||
cli::{CliArgs, Command, SessionCommand, Sessions},
|
||||
consts::{ZELLIJ_TMP_DIR, ZELLIJ_TMP_LOG_DIR},
|
||||
logging::*,
|
||||
setup::{get_default_data_dir, Setup},
|
||||
structopt::StructOpt,
|
||||
|
|
@ -84,8 +83,6 @@ pub fn main() {
|
|||
}
|
||||
}
|
||||
|
||||
atomic_create_dir(&*ZELLIJ_TMP_DIR).unwrap();
|
||||
atomic_create_dir(&*ZELLIJ_TMP_LOG_DIR).unwrap();
|
||||
if let Some(path) = opts.server {
|
||||
let os_input = match get_server_os_input() {
|
||||
Ok(server_os_input) => server_os_input,
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ use std::{
|
|||
sync::{Arc, Mutex, RwLock},
|
||||
thread,
|
||||
};
|
||||
use zellij_utils::nix::sys::stat::{umask, Mode};
|
||||
use zellij_utils::pane_size::Size;
|
||||
use zellij_utils::zellij_tile;
|
||||
|
||||
|
|
@ -175,9 +176,13 @@ impl SessionState {
|
|||
|
||||
pub fn start_server(mut os_input: Box<dyn ServerOsApi>, socket_path: PathBuf) {
|
||||
info!("Starting Zellij server!");
|
||||
|
||||
// preserve the current umask: read current value by setting to another mode, and then restoring it
|
||||
let current_umask = umask(Mode::all());
|
||||
umask(current_umask);
|
||||
daemonize::Daemonize::new()
|
||||
.working_directory(std::env::current_dir().unwrap())
|
||||
.umask(0o077)
|
||||
.umask(current_umask.bits())
|
||||
.start()
|
||||
.expect("could not daemonize the server process");
|
||||
|
||||
|
|
|
|||
|
|
@ -13,10 +13,14 @@ use log4rs::append::file::FileAppender;
|
|||
use log4rs::config::{Appender, Config, Logger, Root};
|
||||
use log4rs::encode::pattern::PatternEncoder;
|
||||
|
||||
use crate::consts::{ZELLIJ_TMP_LOG_DIR, ZELLIJ_TMP_LOG_FILE};
|
||||
use crate::consts::{ZELLIJ_TMP_DIR, ZELLIJ_TMP_LOG_DIR, ZELLIJ_TMP_LOG_FILE};
|
||||
use crate::shared::set_permissions;
|
||||
|
||||
pub fn configure_logger() {
|
||||
atomic_create_dir(&*ZELLIJ_TMP_DIR).unwrap();
|
||||
atomic_create_dir(&*ZELLIJ_TMP_LOG_DIR).unwrap();
|
||||
atomic_create_file(&*ZELLIJ_TMP_LOG_DIR.join("zellij.log")).unwrap();
|
||||
|
||||
// {n} means platform dependent newline
|
||||
// module is padded to exactly 25 bytes and thread is padded to be between 10 and 15 bytes.
|
||||
let file_pattern = "{highlight({level:<6})} |{module:<25.25}| {date(%Y-%m-%d %H:%M:%S.%3f)} [{thread:<10.15}] [{file}:{line}]: {message} {n}";
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue