From ba802309fb03d713e99ef0367b32ddcfe538b428 Mon Sep 17 00:00:00 2001 From: Hunter Wittenborn Date: Mon, 26 Sep 2022 02:22:02 -0500 Subject: [PATCH] Ensure user cache directory for Mist is owned by the current user --- CHANGELOG.md | 3 +++ Cargo.lock | 2 +- Cargo.toml | 2 +- makedeb/PKGBUILD | 2 +- src/util.rs | 8 +++++--- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 27e93b7..832b962 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +## [0.9.7] - 2022-09-26 +### Fixed +- Ensure Mist's cache directory in `${HOME}` is owned by the current user when Mist has to create it. ## [0.9.6] - 2022-09-25 ### Fixed diff --git a/Cargo.lock b/Cargo.lock index d03ad63..b1e9977 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -863,7 +863,7 @@ dependencies = [ [[package]] name = "mist" -version = "0.9.6" +version = "0.9.7" dependencies = [ "bat", "chrono", diff --git a/Cargo.toml b/Cargo.toml index 256f15a..e3af4e7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mist" -version = "0.9.6" +version = "0.9.7" authors = ["Hunter Wittenborn super::path::PathBuf { let mut cache_dir = dirs::cache_dir().unwrap(); cache_dir.push("mist"); + super::sudo::to_normal(); super::fs::create_dir(&cache_dir.clone().into_os_string().into_string().unwrap()); + super::sudo::to_root(); cache_dir } @@ -345,9 +347,9 @@ pub mod sudo { } /// Change the user to the non-root user. - // pub fn to_normal() { - // users::switch::set_effective_uid(*self::NORMAL_UID).unwrap(); - // } + pub fn to_normal() { + users::switch::set_effective_uid(*self::NORMAL_UID).unwrap(); + } // Run a command as the normal user declared by [`NORMAL_UID`]. pub fn run_as_normal_user>(program: P) -> super::ProcCommand {