1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-29 03:57:44 +00:00

mktemp: change directory permission after creation

This commit is contained in:
353fc443 2022-05-02 07:20:29 +00:00
parent bf3a86f654
commit 87c2122e76
No known key found for this signature in database
GPG key ID: D58B14ED3D42A937

View file

@ -13,11 +13,12 @@ use uucore::display::{println_verbatim, Quotable};
use uucore::error::{FromIo, UError, UResult};
use uucore::format_usage;
use std::env;
use std::error::Error;
use std::fmt::Display;
use std::iter;
use std::os::unix::prelude::PermissionsExt;
use std::path::{is_separator, Path, PathBuf};
use std::{env, fs};
use rand::Rng;
use tempfile::Builder;
@ -272,5 +273,8 @@ fn exec(dir: &Path, prefix: &str, rand: usize, suffix: &str, make_dir: bool) ->
.map_err(|e| MkTempError::PersistError(e.file.path().to_path_buf()))?
.1
};
if make_dir {
fs::set_permissions(&path, fs::Permissions::from_mode(0o700))?;
}
println_verbatim(path).map_err_context(|| "failed to print directory name".to_owned())
}