mirror of
https://github.com/rosenpass/rosenpass.git
synced 2025-12-05 20:40:02 -08:00
fix: Compiling rp should be disabled on mac
This commit is contained in:
@@ -1,62 +1,19 @@
|
||||
use std::{fs, process::exit};
|
||||
|
||||
use rosenpass_util::tokio::janitor::ensure_janitor;
|
||||
|
||||
use rosenpass_secret_memory::policy;
|
||||
|
||||
use crate::cli::{Cli, Command};
|
||||
use crate::exchange::exchange;
|
||||
use crate::key::{genkey, pubkey};
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
|
||||
mod cli;
|
||||
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
|
||||
mod exchange;
|
||||
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
|
||||
mod key;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> anyhow::Result<()> {
|
||||
#[cfg(feature = "experiment_memfd_secret")]
|
||||
policy::secret_policy_try_use_memfd_secrets();
|
||||
#[cfg(not(feature = "experiment_memfd_secret"))]
|
||||
policy::secret_policy_use_only_malloc_secrets();
|
||||
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
|
||||
mod main_supported_platforms;
|
||||
|
||||
ensure_janitor(async move { main_impl().await }).await
|
||||
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
|
||||
fn main() -> anyhow::Result<()> {
|
||||
main_supported_platforms::main()
|
||||
}
|
||||
|
||||
async fn main_impl() -> anyhow::Result<()> {
|
||||
let cli = match Cli::parse(std::env::args().peekable()) {
|
||||
Ok(cli) => cli,
|
||||
Err(err) => {
|
||||
eprintln!("{}", err);
|
||||
exit(1);
|
||||
}
|
||||
};
|
||||
|
||||
// init logging
|
||||
// TODO: Taken from rosenpass; we should deduplicate the code.
|
||||
env_logger::Builder::from_default_env().init(); // sets log level filter from environment (or defaults)
|
||||
|
||||
let command = cli.command.unwrap();
|
||||
|
||||
match command {
|
||||
Command::GenKey { private_keys_dir } => genkey(&private_keys_dir),
|
||||
Command::PubKey {
|
||||
private_keys_dir,
|
||||
public_keys_dir,
|
||||
} => pubkey(&private_keys_dir, &public_keys_dir),
|
||||
Command::Exchange(mut options) => {
|
||||
options.verbose = cli.verbose;
|
||||
exchange(options).await
|
||||
}
|
||||
Command::ExchangeConfig { config_file } => {
|
||||
let s: String = fs::read_to_string(config_file).expect("cannot read config");
|
||||
let mut options: exchange::ExchangeOptions =
|
||||
toml::from_str::<exchange::ExchangeOptions>(&s).expect("cannot parse config");
|
||||
options.verbose = options.verbose || cli.verbose;
|
||||
exchange(options).await
|
||||
}
|
||||
Command::Help => {
|
||||
println!("Usage: rp [verbose] genkey|pubkey|exchange [ARGS]...");
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
#[cfg(not(any(target_os = "linux", target_os = "freebsd")))]
|
||||
fn main() {
|
||||
panic!("Unfortunately, the rp command is currently not supported on your platform. See https://github.com/rosenpass/rosenpass/issues/689 for more information and discussion.")
|
||||
}
|
||||
|
||||
58
rp/src/main_supported_platforms.rs
Normal file
58
rp/src/main_supported_platforms.rs
Normal file
@@ -0,0 +1,58 @@
|
||||
use std::{fs, process::exit};
|
||||
|
||||
use rosenpass_util::tokio::janitor::ensure_janitor;
|
||||
|
||||
use rosenpass_secret_memory::policy;
|
||||
|
||||
use crate::cli::{Cli, Command};
|
||||
use crate::exchange::{exchange, ExchangeOptions};
|
||||
use crate::key::{genkey, pubkey};
|
||||
|
||||
#[tokio::main]
|
||||
pub async fn main() -> anyhow::Result<()> {
|
||||
#[cfg(feature = "experiment_memfd_secret")]
|
||||
policy::secret_policy_try_use_memfd_secrets();
|
||||
#[cfg(not(feature = "experiment_memfd_secret"))]
|
||||
policy::secret_policy_use_only_malloc_secrets();
|
||||
|
||||
ensure_janitor(async move { main_impl().await }).await
|
||||
}
|
||||
|
||||
async fn main_impl() -> anyhow::Result<()> {
|
||||
let cli = match Cli::parse(std::env::args().peekable()) {
|
||||
Ok(cli) => cli,
|
||||
Err(err) => {
|
||||
eprintln!("{}", err);
|
||||
exit(1);
|
||||
}
|
||||
};
|
||||
|
||||
// init logging
|
||||
// TODO: Taken from rosenpass; we should deduplicate the code.
|
||||
env_logger::Builder::from_default_env().init(); // sets log level filter from environment (or defaults)
|
||||
|
||||
let command = cli.command.unwrap();
|
||||
|
||||
match command {
|
||||
Command::GenKey { private_keys_dir } => genkey(&private_keys_dir),
|
||||
Command::PubKey {
|
||||
private_keys_dir,
|
||||
public_keys_dir,
|
||||
} => pubkey(&private_keys_dir, &public_keys_dir),
|
||||
Command::Exchange(mut options) => {
|
||||
options.verbose = cli.verbose;
|
||||
exchange(options).await
|
||||
}
|
||||
Command::ExchangeConfig { config_file } => {
|
||||
let s: String = fs::read_to_string(config_file).expect("cannot read config");
|
||||
let mut options: ExchangeOptions =
|
||||
toml::from_str::<ExchangeOptions>(&s).expect("cannot parse config");
|
||||
options.verbose = options.verbose || cli.verbose;
|
||||
exchange(options).await
|
||||
}
|
||||
Command::Help => {
|
||||
println!("Usage: rp [verbose] genkey|pubkey|exchange [ARGS]...");
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
use std::process::Command;
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
|
||||
#[test]
|
||||
fn smoketest() -> anyhow::Result<()> {
|
||||
let tmpdir = tempfile::tempdir()?;
|
||||
|
||||
Reference in New Issue
Block a user