Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Also check for the policy file in /usr/share/crypto-policies. #72

Merged
merged 1 commit into from
Jul 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ use std::ffi::{
use std::fmt::Debug;
use std::io::Read;
use std::io::Write;
use std::path::PathBuf;
use std::sync::RwLock;
use std::time::{
Duration,
Expand Down Expand Up @@ -228,8 +229,10 @@ macro_rules! linter {
// if that is not present, we fallback to the default configuration.
const RPM_SEQUOIA_CONFIG_ENV: &'static str
= "RPM_SEQUOIA_CRYPTO_POLICY";
const RPM_SEQUOIA_CONFIG: &'static str
= "/etc/crypto-policies/back-ends/rpm-sequoia.config";
const RPM_SEQUOIA_CONFIG: &[&str] = &[
"/etc/crypto-policies/back-ends/rpm-sequoia.config",
"/usr/share/crypto-policies/back-ends/rpm-sequoia.config",
];

ffi!(
/// int rpmInitCrypto(void)
Expand All @@ -248,8 +251,18 @@ fn _rpmInitCrypto() -> Binary {
let mut p = sequoia_policy_config::ConfiguredStandardPolicy
::from_policy(p);

// We can only specify a single file to
// `ConfiguredStandardPolicy::parse_config_file`. We work around
// it (for now) by taking the first file that exists.
let rpm_sequoia_config = RPM_SEQUOIA_CONFIG
.iter()
.find(|path| {
PathBuf::from(path).exists()
})
.unwrap_or(&RPM_SEQUOIA_CONFIG[0]);

match p.parse_config(RPM_SEQUOIA_CONFIG_ENV,
RPM_SEQUOIA_CONFIG)
rpm_sequoia_config)
{
Ok(false) => {
// Fallback to the default configuration.
Expand Down
Loading