diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 79465001..630d8c08 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,7 +38,7 @@ jobs: - uses: actions/checkout@v1 - run: cargo build --verbose - run: | - cargo run & + RUST_BACKTRACE=1 RUST_LOG=info cargo run & cargo test --test normal integ-test-persistence: @@ -49,7 +49,7 @@ jobs: - run: cargo build --verbose - name: Tests executed before the shutdown run: | - cargo run & + RUST_BACKTRACE=1 RUST_LOG=info cargo run & SERVER_PID=$! cargo test --test persistent-before kill $SERVER_PID @@ -62,7 +62,7 @@ jobs: printf '\xe0\x19\xb2\x5c' > mappings/cm9vdA==/1/VGVzdCBLZXk\= - name: Tests executed after the shutdown run: | - cargo run & + RUST_BACKTRACE=1 RUST_LOG=info cargo run & cargo test --test persistent-after stress-test: @@ -72,6 +72,6 @@ jobs: - uses: actions/checkout@v1 - run: cargo build --verbose - run: | - cargo run & + RUST_BACKTRACE=1 RUST_LOG=info cargo run & cargo test --test stress_test diff --git a/Cargo.lock b/Cargo.lock index a72defe3..85b21f81 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -186,7 +186,19 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", - "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "env_logger" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", + "humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -238,7 +250,7 @@ dependencies = [ [[package]] name = "humantime" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -401,8 +413,10 @@ dependencies = [ "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "bindgen 0.50.0 (registry+https://github.com/rust-lang/crates.io-index)", "cargo_toml 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parsec-client-test 0.1.2 (git+https://github.com/parallaxsecond/parsec-client-test?tag=0.1.2)", + "parsec-client-test 0.1.3 (git+https://github.com/parallaxsecond/parsec-client-test?tag=0.1.3)", "parsec-interface 0.1.0 (git+https://github.com/parallaxsecond/parsec-interface-rs?tag=0.1.0)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "sd-notify 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -416,9 +430,10 @@ dependencies = [ [[package]] name = "parsec-client-test" -version = "0.1.2" -source = "git+https://github.com/parallaxsecond/parsec-client-test?tag=0.1.2#babb6b10a9763491f2adfe9b541738dae7e685d8" +version = "0.1.3" +source = "git+https://github.com/parallaxsecond/parsec-client-test?tag=0.1.3#cf1627209529cfb2376e127801cb29bdf7847ccd" dependencies = [ + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "num 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parsec-interface 0.1.0 (git+https://github.com/parallaxsecond/parsec-interface-rs?tag=0.1.0)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -864,13 +879,14 @@ dependencies = [ "checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" "checksum either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5527cfe0d098f36e3f8839852688e63c8fff1c90b2b405aef730615f9a7bcf7b" "checksum env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "aafcde04e90a5226a6443b7aabdb016ba2f8307c847d524724bd9b346dd1a2d3" +"checksum env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" "checksum fixedbitset 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "86d4de0081402f5e88cdac65c8dcdcc73118c1a7a465e2a05f0da05843a8ea33" "checksum fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" "checksum getrandom 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "fc344b02d3868feb131e8b5fe2b9b0a1cc42942679af493061fc13b853243872" "checksum glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" "checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" -"checksum humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ca7e5f2e110db35f93b837c81797f3714500b81d517bf20c431b16d3ca4f114" +"checksum humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" "checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" "checksum itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5b8467d9c1cebe26feb08c640139247fac215782d35371ade9a2136ed6085358" "checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" @@ -889,7 +905,7 @@ dependencies = [ "checksum num-rational 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f2885278d5fe2adc2f75ced642d52d879bffaceb5a2e0b1d4309ffdfb239b454" "checksum num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "6ba9a427cfca2be13aa6f6403b0b7e7368fe982bfa16fccc450ce74c46cd9b32" "checksum num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bcef43580c035376c0705c42792c294b66974abbfd2789b511784023f71f3273" -"checksum parsec-client-test 0.1.2 (git+https://github.com/parallaxsecond/parsec-client-test?tag=0.1.2)" = "" +"checksum parsec-client-test 0.1.3 (git+https://github.com/parallaxsecond/parsec-client-test?tag=0.1.3)" = "" "checksum parsec-interface 0.1.0 (git+https://github.com/parallaxsecond/parsec-interface-rs?tag=0.1.0)" = "" "checksum peeking_take_while 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" "checksum petgraph 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)" = "9c3659d1ee90221741f65dd128d9998311b0e40c5d3c23a62445938214abce4f" diff --git a/Cargo.toml b/Cargo.toml index 4fe7f644..ecf0bf6c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,9 +20,11 @@ signal-hook = "0.1.10" sd-notify = { version = "0.1.0", optional = true } toml = "0.4.2" serde = { version = "1.0", features = ["derive"] } +env_logger = "0.7.1" +log = "0.4.8" [dev-dependencies] -parsec-client-test = { git = "https://github.com/parallaxsecond/parsec-client-test", tag = "0.1.2" } +parsec-client-test = { git = "https://github.com/parallaxsecond/parsec-client-test", tag = "0.1.3" } num_cpus = "1.10.1" [build-dependencies] diff --git a/README.md b/README.md index 17e91b20..f5bf4dc7 100644 --- a/README.md +++ b/README.md @@ -137,9 +137,11 @@ This project uses the following third party crates: * uuid (Apache-2.0) * threadpool (Apache-2.0) * std-semaphore (MIT and Apache-2.0) -* num_cpus (MIT and Apache-2.0) +* num\_cpus (MIT and Apache-2.0) * signal-hook (MIT and Apache-2.0) * sd-notify (Apache-2.0) +* log (Apache-2.0) +* env\_logger (MIT and Apache-2.0) This project uses the following third party libraries: * [Mbed Crypto](https://github.com/ARMmbed/mbed-crypto) (Apache-2.0) diff --git a/src/bin/main.rs b/src/bin/main.rs index 8c77e591..a8cf98a6 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -12,6 +12,7 @@ // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +use log::info; use parsec::utils::{ServiceBuilder, ServiceConfig}; use signal_hook::{flag, SIGTERM}; use std::io::Error; @@ -25,6 +26,15 @@ const CONFIG_FILE_PATH: &str = "./config.toml"; const MAIN_LOOP_DEFAULT_SLEEP: u64 = 10; fn main() -> Result<(), Error> { + if cfg!(feature = "systemd-daemon") { + // Logs viewed with journalctl already contain timestamps. + env_logger::builder().format_timestamp(None).init(); + } else { + env_logger::init(); + } + + info!("PARSEC started."); + let config_file = ::std::fs::read_to_string(CONFIG_FILE_PATH).expect("Failed to read configuration file"); let config: ServiceConfig = @@ -33,6 +43,7 @@ fn main() -> Result<(), Error> { let front_end_handler = ServiceBuilder::build_service(&config); let listener = ServiceBuilder::start_listener(&config.listener); + // Multiple threads can not just have a reference of the front end handler because they could // outlive the run function. It is needed to give them all ownership of the front end handler // through an Arc. @@ -44,13 +55,15 @@ fn main() -> Result<(), Error> { let threadpool = ServiceBuilder::build_threadpool(config.core_settings.thread_pool_size); + info!("PARSEC is ready."); + #[cfg(feature = "systemd-daemon")] // Notify systemd that the daemon is ready, the start command will block until this point. let _ = sd_notify::notify(true, &[sd_notify::NotifyState::Ready]); loop { if kill_signal.load(Ordering::Relaxed) { - println!("SIGTERM signal received."); + info!("SIGTERM signal received."); break; } @@ -69,7 +82,7 @@ fn main() -> Result<(), Error> { } } - println!("Shutting down PARSEC, waiting for all threads to finish."); + info!("Shutting down PARSEC, waiting for all threads to finish."); threadpool.join(); Ok(()) diff --git a/src/front/domain_socket.rs b/src/front/domain_socket.rs index 1d99322d..a00cefc4 100644 --- a/src/front/domain_socket.rs +++ b/src/front/domain_socket.rs @@ -12,18 +12,17 @@ // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +use super::listener; +use listener::Listen; +use listener::ReadWrite; +use log::error; use std::fs; use std::io::ErrorKind; +use std::os::unix::io::FromRawFd; use std::os::unix::net::UnixListener; use std::path::Path; use std::time::Duration; -use super::listener; - -use listener::Listen; -use listener::ReadWrite; -use std::os::unix::io::FromRawFd; - static SOCKET_PATH: &str = "/tmp/security-daemon-socket"; /// Listener implementation for Unix sockets as the underlying IPC mechanism. @@ -87,13 +86,13 @@ impl Listen for DomainSocketListener { match stream_result { Ok((stream, _)) => { if let Err(err) = stream.set_read_timeout(Some(self.timeout)) { - println!("Failed to set read timeout ({})", err); + error!("Failed to set read timeout ({})", err); None } else if let Err(err) = stream.set_write_timeout(Some(self.timeout)) { - println!("Failed to set write timeout ({})", err); + error!("Failed to set write timeout ({})", err); None } else if let Err(err) = stream.set_nonblocking(false) { - println!("Failed to set stream as blocking ({})", err); + error!("Failed to set stream as blocking ({})", err); None } else { Some(Box::from(stream)) @@ -113,7 +112,7 @@ impl Listen for DomainSocketListener { // Check if the error is because no connections are currently present. if err.kind() != ErrorKind::WouldBlock { // Only log the real errors. - println!("Failed to connect with a UnixStream ({})", err); + error!("Failed to connect with a UnixStream ({})", err); } None } diff --git a/src/front/front_end.rs b/src/front/front_end.rs index 21e4b4dd..38584aab 100644 --- a/src/front/front_end.rs +++ b/src/front/front_end.rs @@ -14,6 +14,7 @@ // limitations under the License. use crate::authenticators::Authenticate; use crate::back::dispatcher::Dispatcher; +use log::{error, info}; use parsec_interface::requests::AuthType; use parsec_interface::requests::ResponseStatus; use parsec_interface::requests::{Request, Response}; @@ -44,11 +45,11 @@ impl FrontEndHandler { let request = match Request::read_from_stream(&mut stream) { Ok(request) => request, Err(status) => { - println!("Failed to read request; status: {}", status); + error!("Failed to read request; status: {}", status); let response = Response::from_status(status); if let Err(status) = response.write_to_stream(&mut stream) { - println!("Failed to write response; status: {}", status); + error!("Failed to write response; status: {}", status); } return; } @@ -75,8 +76,8 @@ impl FrontEndHandler { // Serialise the responso into bytes // Write bytes to stream match response.write_to_stream(&mut stream) { - Ok(_) => println!("Request handled successfully"), - Err(err) => println!("Failed to send response; error: {}", err), + Ok(_) => info!("Request handled successfully"), + Err(err) => error!("Failed to send response; error: {}", err), } } } diff --git a/src/key_id_managers/on_disk_manager/mod.rs b/src/key_id_managers/on_disk_manager/mod.rs index 9c321cc6..710efeb6 100644 --- a/src/key_id_managers/on_disk_manager/mod.rs +++ b/src/key_id_managers/on_disk_manager/mod.rs @@ -26,6 +26,7 @@ //! For security reasons, only the PARSEC service should have the ability to modify these files. use super::{KeyTriple, ManageKeyIDs}; use crate::authenticators::ApplicationName; +use log::{error, info}; use parsec_interface::requests::ProviderID; use std::collections::HashMap; use std::convert::TryFrom; @@ -192,7 +193,7 @@ impl OnDiskKeyIDManager { for app_name_dir_path in list_dirs(&mappings_dir_path)?.iter() { for provider_dir_path in list_dirs(&app_name_dir_path)?.iter() { for key_name_file_path in list_files(&provider_dir_path)?.iter() { - println!("Found mapping file: {:?}.", key_name_file_path); + info!("Found mapping file: {:?}.", key_name_file_path); let mut key_id = Vec::new(); let mut key_id_file = File::open(&key_name_file_path)?; key_id_file.read_to_end(&mut key_id)?; @@ -211,7 +212,7 @@ impl OnDiskKeyIDManager { key_store.insert(key_triple, key_id); } Err(string) => { - println!("Failed to convert the mapping path found to an UTF-8 string (error: {}).", string); + error!("Failed to convert the mapping path found to an UTF-8 string (error: {}).", string); } } } diff --git a/src/providers/mbed_provider/mod.rs b/src/providers/mbed_provider/mod.rs index c4d0a34d..00a35280 100644 --- a/src/providers/mbed_provider/mod.rs +++ b/src/providers/mbed_provider/mod.rs @@ -19,6 +19,7 @@ use std::collections::HashSet; use std::convert::TryInto; use std::sync::{Arc, Mutex, RwLock}; +use log::{error, info, warn}; use parsec_interface::operations::key_attributes::KeyLifetime; use parsec_interface::operations::ProviderInfo; use parsec_interface::operations::{OpAsymSign, ResultAsymSign}; @@ -88,13 +89,13 @@ fn get_key_id( if let Ok(key_id_bytes) = key_id.try_into() { Ok(u32::from_ne_bytes(key_id_bytes)) } else { - println!("Stored Key ID is not valid."); + error!("Stored Key ID is not valid."); Err(ResponseStatus::KeyIDManagerError) } } Ok(None) => Err(ResponseStatus::KeyDoesNotExist), Err(string) => { - println!("Key ID Manager error: {}", string); + error!("Key ID Manager error: {}", string); Err(ResponseStatus::KeyIDManagerError) } } @@ -116,14 +117,14 @@ fn create_key_id( match store_handle.insert(key_triple.clone(), key_id.to_ne_bytes().to_vec()) { Ok(insert_option) => { if insert_option.is_some() { - println!("Overwriting Key triple mapping ({})", key_triple); + warn!("Overwriting Key triple mapping ({})", key_triple); } local_ids_handle.insert(key_id); Ok(key_id) } Err(string) => { - println!("Key ID Manager error: {}", string); + error!("Key ID Manager error: {}", string); Err(ResponseStatus::KeyIDManagerError) } } @@ -141,7 +142,7 @@ fn remove_key_id( Ok(()) } Err(string) => { - println!("Key ID Manager error: {}", string); + error!("Key ID Manager error: {}", string); Err(ResponseStatus::KeyIDManagerError) } } @@ -151,7 +152,7 @@ fn key_id_exists(key_triple: &KeyTriple, store_handle: &dyn ManageKeyIDs) -> Res match store_handle.exists(key_triple) { Ok(val) => Ok(val), Err(string) => { - println!("Key ID Manager error: {}", string); + error!("Key ID Manager error: {}", string); Err(ResponseStatus::KeyIDManagerError) } } @@ -164,7 +165,7 @@ impl MbedProvider { /// Returns `None` if the initialisation failed. fn new(key_id_store: Arc>) -> Option { if unsafe { psa_crypto_binding::psa_crypto_init() } != constants::PSA_SUCCESS { - println!("Error when initialising Mbed Crypto"); + error!("Error when initialising Mbed Crypto"); return None; } let mbed_provider = MbedProvider { @@ -194,7 +195,7 @@ impl MbedProvider { let key_id = match get_key_id(key_triple, &*store_handle) { Ok(key_id) => key_id, Err(response_status) => { - println!("Error getting the Key ID for triple:\n{}\n(error: {}), continuing...", key_triple, response_status); + error!("Error getting the Key ID for triple:\n{}\n(error: {}), continuing...", key_triple, response_status); to_remove.push(key_triple.clone()); continue; } @@ -209,7 +210,7 @@ impl MbedProvider { if open_key_status == constants::PSA_ERROR_DOES_NOT_EXIST { to_remove.push(key_triple.clone()); } else if open_key_status != constants::PSA_SUCCESS { - println!( + error!( "Error {} when opening a persistent Mbed Crypto key.", open_key_status ); @@ -223,13 +224,13 @@ impl MbedProvider { } } Err(string) => { - println!("Key ID Manager error: {}", string); + error!("Key ID Manager error: {}", string); return None; } }; for key_triple in to_remove.iter() { if let Err(string) = store_handle.remove(key_triple) { - println!("Key ID Manager error: {}", string); + error!("Key ID Manager error: {}", string); return None; } } @@ -260,7 +261,7 @@ impl Provide for MbedProvider { } fn create_key(&self, app_name: ApplicationName, op: OpCreateKey) -> Result { - println!("Mbed Provider - Create Key"); + info!("Mbed Provider - Create Key"); let _semaphore_guard = self.key_slot_semaphore.access(); let key_name = op.key_name; let key_attributes = op.key_attributes; @@ -320,11 +321,11 @@ impl Provide for MbedProvider { ret_val = Ok(ResultCreateKey {}); } else { ret_val = Err(conversion_utils::convert_status(generate_key_status)); - println!("Generate key status: {}", generate_key_status); + error!("Generate key status: {}", generate_key_status); } } else { ret_val = Err(conversion_utils::convert_status(set_policy_status)); - println!("Set policy status: {}", set_policy_status); + error!("Set policy status: {}", set_policy_status); } unsafe { @@ -336,7 +337,7 @@ impl Provide for MbedProvider { } } else { ret_val = Err(conversion_utils::convert_status(create_key_status)); - println!("Create key status: {}", create_key_status); + error!("Create key status: {}", create_key_status); } if ret_val.is_err() { @@ -352,7 +353,7 @@ impl Provide for MbedProvider { } fn import_key(&self, app_name: ApplicationName, op: OpImportKey) -> Result { - println!("Mbed Provider - Import Key"); + info!("Mbed Provider - Import Key"); let _semaphore_guard = self.key_slot_semaphore.access(); let key_name = op.key_name; let key_attributes = op.key_attributes; @@ -412,11 +413,11 @@ impl Provide for MbedProvider { ret_val = Ok(ResultImportKey {}); } else { ret_val = Err(conversion_utils::convert_status(import_key_status)); - println!("Import key status: {}", import_key_status); + error!("Import key status: {}", import_key_status); } } else { ret_val = Err(conversion_utils::convert_status(set_policy_status)); - println!("Set policy status: {}", set_policy_status); + error!("Set policy status: {}", set_policy_status); } unsafe { @@ -428,7 +429,7 @@ impl Provide for MbedProvider { } } else { ret_val = Err(conversion_utils::convert_status(create_key_status)); - println!("Create key status: {}", create_key_status); + error!("Create key status: {}", create_key_status); } if ret_val.is_err() { @@ -448,7 +449,7 @@ impl Provide for MbedProvider { app_name: ApplicationName, op: OpExportPublicKey, ) -> Result { - println!("Mbed Provider - Export Public Key"); + info!("Mbed Provider - Export Public Key"); let _semaphore_guard = self.key_slot_semaphore.access(); let key_name = op.key_name; let key_lifetime = op.key_lifetime; @@ -490,7 +491,7 @@ impl Provide for MbedProvider { buffer.resize(actual_size, 0); ret_val = Ok(ResultExportPublicKey { key_data: buffer }); } else { - println!("Export status: {}", export_status); + error!("Export status: {}", export_status); ret_val = Err(conversion_utils::convert_status(export_status)); } @@ -502,7 +503,7 @@ impl Provide for MbedProvider { psa_crypto_binding::psa_close_key(key_handle); } } else { - println!("Open key status: {}", open_key_status); + error!("Open key status: {}", open_key_status); ret_val = Err(conversion_utils::convert_status(open_key_status)); } @@ -510,7 +511,7 @@ impl Provide for MbedProvider { } fn destroy_key(&self, app_name: ApplicationName, op: OpDestroyKey) -> Result { - println!("Mbed Provider - Destroy Key"); + info!("Mbed Provider - Destroy Key"); let _semaphore_guard = self.key_slot_semaphore.access(); let key_name = op.key_name; let key_lifetime = op.key_lifetime; @@ -550,7 +551,7 @@ impl Provide for MbedProvider { } fn asym_sign(&self, app_name: ApplicationName, op: OpAsymSign) -> Result { - println!("Mbed Provider - Asym Sign"); + info!("Mbed Provider - Asym Sign"); let _semaphore_guard = self.key_slot_semaphore.access(); let key_name = op.key_name; let key_lifetime = op.key_lifetime; @@ -623,7 +624,7 @@ impl Provide for MbedProvider { } fn asym_verify(&self, app_name: ApplicationName, op: OpAsymVerify) -> Result { - println!("Mbed Provider - Asym Verify"); + info!("Mbed Provider - Asym Verify"); let _semaphore_guard = self.key_slot_semaphore.access(); let key_name = op.key_name; let key_lifetime = op.key_lifetime; diff --git a/systemd-daemon/parsec.service b/systemd-daemon/parsec.service index ee0e4612..29485503 100644 --- a/systemd-daemon/parsec.service +++ b/systemd-daemon/parsec.service @@ -5,4 +5,5 @@ Documentation=https://github.com/parallaxsecond/parsec [Service] Type=notify NonBlocking=true +Environment=RUST_LOG=info ExecStart=/home/parsec/.cargo/bin/parsec diff --git a/tests/all.sh b/tests/all.sh index a807512d..b6be5583 100755 --- a/tests/all.sh +++ b/tests/all.sh @@ -20,7 +20,7 @@ # This script executes static checks, unit and integration tests for the PARSEC # service. # -# Usage: ./ci/all.sh +# Usage: ./tests/all.sh ############## # Build test # @@ -42,7 +42,7 @@ cargo clippy || exit 1 ############################ # Normal Integration tests # ############################ -cargo run & +RUST_BACKTRACE=1 RUST_LOG=info cargo run & SERVER_PID=$! cargo test --test normal || exit 1 @@ -52,7 +52,7 @@ kill $SERVER_PID ################################# # Persistence Integration tests # ################################# -cargo run & +RUST_BACKTRACE=1 RUST_LOG=info cargo run & SERVER_PID=$! cargo test --test persistent-before || exit 1 @@ -65,7 +65,7 @@ kill $SERVER_PID mkdir -p mappings/cm9vdA==/1 || exit 1 printf '\xe0\x19\xb2\x5c' > mappings/cm9vdA==/1/VGVzdCBLZXk\= -cargo run & +RUST_BACKTRACE=1 RUST_LOG=info cargo run & SERVER_PID=$! cargo test --test persistent-after || exit 1 @@ -75,7 +75,7 @@ kill $SERVER_PID ################ # Stress tests # ################ -cargo run & +RUST_BACKTRACE=1 RUST_LOG=info cargo run & SERVER_PID=$! cargo test --test stress_test || exit 1