This commit is contained in:
John Smith
2022-07-02 11:41:25 -04:00
parent d96e5a131c
commit e31aa84db0
8 changed files with 32 additions and 77 deletions

View File

@@ -1,5 +1,4 @@
use crate::xx::*;
use crate::*;
use core::fmt;
mod tools;

View File

@@ -205,8 +205,8 @@ cfg_if::cfg_if! {
Ok(())
}
} else if #[cfg(windows)] {
use std::os::windows::fs::MetadataExt;
use windows_permissions::*;
//use std::os::windows::fs::MetadataExt;
//use windows_permissions::*;
pub fn ensure_file_private_owner<P:AsRef<Path>>(path: P) -> Result<(),String>
{
@@ -217,11 +217,11 @@ cfg_if::cfg_if! {
// let uid = Uid::effective();
// let gid = Gid::effective();
let meta = std::fs::metadata(path).map_err(|e| format!("unable to get metadata for path '{:?}': {}",path, e))?;
//let meta = std::fs::metadata(path).map_err(|e| format!("unable to get metadata for path '{:?}': {}",path, e))?;
if meta.mode() != 0o600 {
std::fs::set_permissions(path,std::fs::Permissions::from_mode(0o600)).map_err(|e| format!("unable to set correct permissions on path '{:?}': {}", path, e))?;
}
//if meta.mode() != 0o600 {
// std::fs::set_permissions(path,std::fs::Permissions::from_mode(0o600)).map_err(|e| format!("unable to set correct permissions on path '{:?}': {}", path, e))?;
//}
//if meta.uid() != uid.as_raw() || meta.gid() != gid.as_raw() {
// chown(path, Some(uid), Some(gid)).map_err(|e| format!("unable to set correct owner on path '{:?}': {}", path, e))?;