mirror of
https://github.com/rosenpass/rosenpass.git
synced 2026-02-28 06:23:08 -08:00
chore: Reorganize memfd secret policy
- Policy is now set in main.rs, not cli.rs. - Feature is called experiment_memfd_secret, not enable_memfd_alloc This also fixes the last remaining warnings.
This commit is contained in:
@@ -53,5 +53,5 @@ procspawn = {workspace = true}
|
|||||||
|
|
||||||
[features]
|
[features]
|
||||||
enable_broker_api = ["rosenpass-wireguard-broker/enable_broker_api"]
|
enable_broker_api = ["rosenpass-wireguard-broker/enable_broker_api"]
|
||||||
enable_memfd_alloc = []
|
experiment_memfd_secret = []
|
||||||
experiment_libcrux = ["rosenpass-ciphers/experiment_libcrux"]
|
experiment_libcrux = ["rosenpass-ciphers/experiment_libcrux"]
|
||||||
|
|||||||
@@ -3,9 +3,6 @@ use clap::{Parser, Subcommand};
|
|||||||
use rosenpass_cipher_traits::Kem;
|
use rosenpass_cipher_traits::Kem;
|
||||||
use rosenpass_ciphers::kem::StaticKem;
|
use rosenpass_ciphers::kem::StaticKem;
|
||||||
use rosenpass_secret_memory::file::StoreSecret;
|
use rosenpass_secret_memory::file::StoreSecret;
|
||||||
use rosenpass_secret_memory::{
|
|
||||||
secret_policy_try_use_memfd_secrets, secret_policy_use_only_malloc_secrets,
|
|
||||||
};
|
|
||||||
use rosenpass_util::file::{LoadValue, LoadValueB64, StoreValue};
|
use rosenpass_util::file::{LoadValue, LoadValueB64, StoreValue};
|
||||||
use rosenpass_wireguard_broker::brokers::native_unix::{
|
use rosenpass_wireguard_broker::brokers::native_unix::{
|
||||||
NativeUnixBroker, NativeUnixBrokerConfigBaseBuilder, NativeUnixBrokerConfigBaseBuilderError,
|
NativeUnixBroker, NativeUnixBrokerConfigBaseBuilder, NativeUnixBrokerConfigBaseBuilderError,
|
||||||
@@ -158,13 +155,6 @@ impl CliCommand {
|
|||||||
/// ## TODO
|
/// ## TODO
|
||||||
/// - This method consumes the [`CliCommand`] value. It might be wise to use a reference...
|
/// - This method consumes the [`CliCommand`] value. It might be wise to use a reference...
|
||||||
pub fn run(self, test_helpers: Option<AppServerTest>) -> anyhow::Result<()> {
|
pub fn run(self, test_helpers: Option<AppServerTest>) -> anyhow::Result<()> {
|
||||||
//Specify secret policy
|
|
||||||
|
|
||||||
#[cfg(feature = "enable_memfd_alloc")]
|
|
||||||
secret_policy_try_use_memfd_secrets();
|
|
||||||
#[cfg(not(feature = "enable_memfd_alloc"))]
|
|
||||||
secret_policy_use_only_malloc_secrets();
|
|
||||||
|
|
||||||
use CliCommand::*;
|
use CliCommand::*;
|
||||||
match self {
|
match self {
|
||||||
Man => {
|
Man => {
|
||||||
|
|||||||
@@ -8,6 +8,14 @@ pub fn main() {
|
|||||||
// parse CLI arguments
|
// parse CLI arguments
|
||||||
let args = CliArgs::parse();
|
let args = CliArgs::parse();
|
||||||
|
|
||||||
|
{
|
||||||
|
use rosenpass_secret_memory as SM;
|
||||||
|
#[cfg(feature = "experiment_memfd_secret")]
|
||||||
|
SM::secret_policy_try_use_memfd_secrets();
|
||||||
|
#[cfg(not(feature = "experiment_memfd_secret"))]
|
||||||
|
SM::secret_policy_use_only_malloc_secrets();
|
||||||
|
}
|
||||||
|
|
||||||
// init logging
|
// init logging
|
||||||
{
|
{
|
||||||
let mut log_builder = env_logger::Builder::from_default_env(); // sets log level filter from environment (or defaults)
|
let mut log_builder = env_logger::Builder::from_default_env(); // sets log level filter from environment (or defaults)
|
||||||
|
|||||||
@@ -15,9 +15,19 @@ use std::io::Write;
|
|||||||
|
|
||||||
const BIN: &str = "rosenpass";
|
const BIN: &str = "rosenpass";
|
||||||
|
|
||||||
|
fn setup_tests() {
|
||||||
|
use rosenpass_secret_memory as SM;
|
||||||
|
#[cfg(feature = "experiment_memfd_secret")]
|
||||||
|
SM::secret_policy_try_use_memfd_secrets();
|
||||||
|
#[cfg(not(feature = "experiment_memfd_secret"))]
|
||||||
|
SM::secret_policy_use_only_malloc_secrets();
|
||||||
|
}
|
||||||
|
|
||||||
// check that we can generate keys
|
// check that we can generate keys
|
||||||
#[test]
|
#[test]
|
||||||
fn generate_keys() {
|
fn generate_keys() {
|
||||||
|
setup_tests();
|
||||||
|
|
||||||
let tmpdir = PathBuf::from(env!("CARGO_TARGET_TMPDIR")).join("keygen");
|
let tmpdir = PathBuf::from(env!("CARGO_TARGET_TMPDIR")).join("keygen");
|
||||||
fs::create_dir_all(&tmpdir).unwrap();
|
fs::create_dir_all(&tmpdir).unwrap();
|
||||||
|
|
||||||
@@ -134,6 +144,7 @@ fn run_server_client_exchange(
|
|||||||
#[test]
|
#[test]
|
||||||
#[serial]
|
#[serial]
|
||||||
fn check_exchange_under_normal() {
|
fn check_exchange_under_normal() {
|
||||||
|
setup_tests();
|
||||||
setup_logging();
|
setup_logging();
|
||||||
|
|
||||||
let tmpdir = PathBuf::from(env!("CARGO_TARGET_TMPDIR")).join("exchange");
|
let tmpdir = PathBuf::from(env!("CARGO_TARGET_TMPDIR")).join("exchange");
|
||||||
@@ -206,6 +217,7 @@ fn check_exchange_under_normal() {
|
|||||||
#[test]
|
#[test]
|
||||||
#[serial]
|
#[serial]
|
||||||
fn check_exchange_under_dos() {
|
fn check_exchange_under_dos() {
|
||||||
|
setup_tests();
|
||||||
setup_logging();
|
setup_logging();
|
||||||
|
|
||||||
//Generate binary with responder with feature integration_test
|
//Generate binary with responder with feature integration_test
|
||||||
|
|||||||
@@ -39,5 +39,5 @@ tempfile = {workspace = true}
|
|||||||
stacker = {workspace = true}
|
stacker = {workspace = true}
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
enable_memfd_alloc = []
|
experiment_memfd_secret = []
|
||||||
experiment_libcrux = ["rosenpass-ciphers/experiment_libcrux"]
|
experiment_libcrux = ["rosenpass-ciphers/experiment_libcrux"]
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ mod key;
|
|||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
#[cfg(feature = "enable_memfd_alloc")]
|
#[cfg(feature = "experiment_memfd_secret")]
|
||||||
policy::secret_policy_try_use_memfd_secrets();
|
policy::secret_policy_try_use_memfd_secrets();
|
||||||
#[cfg(not(feature = "enable_memfd_alloc"))]
|
#[cfg(not(feature = "experiment_memfd_secret"))]
|
||||||
policy::secret_policy_use_only_malloc_secrets();
|
policy::secret_policy_use_only_malloc_secrets();
|
||||||
|
|
||||||
let cli = match Cli::parse(std::env::args().peekable()) {
|
let cli = match Cli::parse(std::env::args().peekable()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user