Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ log = "0.4.17"
fern = "0.6.1"
indoc = "1.0.8"
clap = { version = "4.0.32", features = ["wrap_help", "derive", "env"] }
users = "0.11.0"


[build-dependencies]
Expand Down
5 changes: 2 additions & 3 deletions src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ use tokio_util::compat::{
};

use std::{
path::Path,
process::ExitStatus
os::unix::fs::DirBuilderExt, path::Path, process::ExitStatus
};


Expand Down Expand Up @@ -345,7 +344,7 @@ fn print_redirect_protection(tmp_dir: &Path) {
let d = tmp_dir
.join("DO-NOT-REDIRECT-OUTSIDE-OF-NVIM-TERM(--help[-W])");

if let Err(e) = std::fs::create_dir_all(&d) {
if let Err(e) = std::fs::DirBuilder::new().mode(0o700).recursive(true).create(&d) {
panic!("Cannot create protection directory '{}': {e:?}", d.display())
}

Expand Down
8 changes: 5 additions & 3 deletions src/pager/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ pub mod gather_env {


pub mod check_usage {
use std::os::unix::fs::DirBuilderExt;

/// Contains data available after page was spawned from shell
#[derive(Debug)]
Expand Down Expand Up @@ -256,9 +257,10 @@ pub mod check_usage {
}

fn create_temp_directory() -> std::path::PathBuf {
let d = std::env::temp_dir()
.join("neovim-page");
std::fs::create_dir_all(&d)
let d = std::env::temp_dir().join(&format!(
"neovim-page.{}", users::get_current_uid()
));
std::fs::DirBuilder::new().mode(0o700).recursive(true).create(&d)
.expect("Cannot create temporary directory for page");
d
}
Expand Down
4 changes: 3 additions & 1 deletion src/pager/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,9 @@ mod output_buffer_usage {
addr.clone()
} else {
std::env::temp_dir()
.join("neovim-page")
.join(&format!(
"neovim-page.{}", users::get_current_uid()
))
.join(&format!("socket-{}", &self.outp_ctx.page_id))
.to_string_lossy()
.to_string()
Expand Down
7 changes: 5 additions & 2 deletions src/picker/context.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pub use env_context::Env;

pub mod env_context {
use std::os::unix::fs::DirBuilderExt;

#[derive(Debug)]
pub struct Env {
Expand Down Expand Up @@ -44,8 +45,10 @@ pub mod env_context {

let tmp_dir = {
let d = std::env::temp_dir()
.join("neovim-page");
std::fs::create_dir_all(&d)
.join(&format!(
"neovim-page.{}", users::get_current_uid()
));
std::fs::DirBuilder::new().mode(0o700).recursive(true).create(&d)
.expect("Cannot create temporary directory for page");
d
};
Expand Down