Skip to content

Commit

Permalink
Ensure user cache directory for Mist is owned by the current user
Browse files Browse the repository at this point in the history
  • Loading branch information
hwittenborn committed Sep 26, 2022
1 parent f96d528 commit ba80230
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mist"
version = "0.9.6"
version = "0.9.7"
authors = ["Hunter Wittenborn <[email protected]"]
description = "The official command-line interface for the makedeb Package Repository"
edition = "2021"
Expand Down
2 changes: 1 addition & 1 deletion makedeb/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# `-H 'MPR-Package: yes'` to your `makedeb` call if you want Mist to be able to
# automatically update itself.
pkgname=mist
pkgver=0.9.6
pkgver=0.9.7
pkgrel=1
pkgdesc='The official command-line interface for the makedeb Package Repository'
arch=('any')
Expand Down
8 changes: 5 additions & 3 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,9 @@ pub mod xdg {
pub fn get_cache_dir() -> 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
}

Expand Down Expand Up @@ -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<P: AsRef<super::OsStr>>(program: P) -> super::ProcCommand {
Expand Down

0 comments on commit ba80230

Please sign in to comment.