Tidy up configuration files UNIX permissions (#7983)
* Add missing libpam package causing build to fail using Docker image ``` wrapper.h:1:10: fatal error: 'security/pam_appl.h' file not found ``` Signed-off-by: Samuel FORESTIER <samuel+dev@forestier.app> * Tidy up configuration files UNIX permissions Signed-off-by: Samuel FORESTIER <samuel+dev@forestier.app> --------- Signed-off-by: Samuel FORESTIER <samuel+dev@forestier.app>
This commit is contained in:
parent
cfd27c8d87
commit
e1140b1bea
@ -487,7 +487,19 @@ pub fn load_path<T: serde::Serialize + serde::de::DeserializeOwned + Default + s
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn store_path<T: serde::Serialize>(path: PathBuf, cfg: T) -> crate::ResultType<()> {
|
pub fn store_path<T: serde::Serialize>(path: PathBuf, cfg: T) -> crate::ResultType<()> {
|
||||||
Ok(confy::store_path(path, cfg)?)
|
#[cfg(not(windows))]
|
||||||
|
{
|
||||||
|
use std::os::unix::fs::PermissionsExt;
|
||||||
|
Ok(confy::store_path_perms(
|
||||||
|
path,
|
||||||
|
cfg,
|
||||||
|
fs::Permissions::from_mode(0o600),
|
||||||
|
)?)
|
||||||
|
}
|
||||||
|
#[cfg(windows)]
|
||||||
|
{
|
||||||
|
Ok(confy::store_path(path, cfg)?)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Config {
|
impl Config {
|
||||||
@ -2471,4 +2483,26 @@ mod tests {
|
|||||||
assert_eq!(cfg, Ok(cfg_to_compare), "Failed to test wrong_field_str");
|
assert_eq!(cfg, Ok(cfg_to_compare), "Failed to test wrong_field_str");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_store_load() {
|
||||||
|
let peerconfig_id = "123456789";
|
||||||
|
let cfg: PeerConfig = Default::default();
|
||||||
|
cfg.store(&peerconfig_id);
|
||||||
|
assert_eq!(PeerConfig::load(&peerconfig_id), cfg);
|
||||||
|
|
||||||
|
#[cfg(not(windows))]
|
||||||
|
{
|
||||||
|
use std::os::unix::fs::PermissionsExt;
|
||||||
|
assert_eq!(
|
||||||
|
// ignore file type information by masking with 0o777 (see https://stackoverflow.com/a/50045872)
|
||||||
|
fs::metadata(PeerConfig::path(&peerconfig_id))
|
||||||
|
.expect("reading metadata failed")
|
||||||
|
.permissions()
|
||||||
|
.mode()
|
||||||
|
& 0o777,
|
||||||
|
0o600
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user