Skip to content

Commit 3c5b6c5

Browse files
authored
Merge pull request #257 from hug-dev/new-socket-path
Modify socket path to conform to FHS
2 parents 2a57277 + 9275f3a commit 3c5b6c5

File tree

22 files changed

+103
-124
lines changed

22 files changed

+103
-124
lines changed

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ features = ["pkcs11-provider", "tpm-provider", "tss-esapi/docs", "mbed-crypto-pr
5252

5353
[features]
5454
default = []
55-
no-parsec-user-and-clients-group = []
5655
mbed-crypto-provider = ["psa-crypto"]
5756
pkcs11-provider = ["pkcs11", "picky-asn1-der", "picky-asn1", "picky-asn1-x509", "psa-crypto", "rand"]
5857
tpm-provider = ["tss-esapi", "picky-asn1-der", "picky-asn1", "picky-asn1-x509", "hex"]

ci.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ while [ "$#" -gt 0 ]; do
6767
PROVIDER_NAME=$1
6868
cp $(pwd)/e2e_tests/provider_cfg/$1/config.toml $CONFIG_PATH
6969
if [ "$PROVIDER_NAME" = "all" ]; then
70-
FEATURES="--features=all-providers,no-parsec-user-and-clients-group"
70+
FEATURES="--features=all-providers"
7171
TEST_FEATURES="--features=all-providers"
7272
else
73-
FEATURES="--features=$1-provider,no-parsec-user-and-clients-group"
73+
FEATURES="--features=$1-provider"
7474
TEST_FEATURES="--features=$1-provider"
7575
fi
7676
;;

config.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
# Log level to be applied across the service. Can be overwritten for certain modules which have the same
1919
# configuration key. Possible values: "debug", "info", "warn", "error", "trace"
20+
# WARNING: This option will not be updated if the configuration is reloaded with a different one.
2021
#log_level = "warn"
2122

2223
# Control whether log entries contain a timestamp.
@@ -44,6 +45,12 @@ listener_type = "DomainSocket"
4445
# timeout expires, the connection is dropped.
4546
timeout = 200 # in milliseconds
4647

48+
# Specify the Unix Domain Socket path. The path is fixed and should always be the default one for
49+
# clients to connect. However, it is useful to change it for tests.
50+
# WARNING: If a file already exists at that path, the service will remove it before creating the
51+
# socket file.
52+
#socket_path = "/run/parsec/parsec.sock"
53+
4754
# (Required) Configuration for the components managing key info for providers.
4855
# Defined as an array of tables: https://github.com/toml-lang/toml#user-content-array-of-tables
4956
[[key_manager]]
@@ -54,7 +61,7 @@ name = "on-disk-manager"
5461
manager_type = "OnDisk"
5562

5663
# Path to the location where the mapping will be persisted (in this case, the filesystem path)
57-
#store_path = "./mappings"
64+
#store_path = "/var/lib/parsec/mappings"
5865

5966
# (Required) Provider configurations.
6067
# Defined as an array of tables: https://github.com/toml-lang/toml#user-content-array-of-tables

e2e_tests/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ publish = false
1414

1515
[dependencies]
1616
serde = { version = "1.0.115", features = ["derive"] }
17-
parsec-client = { version = "0.9.0", features = ["testing"] }
17+
parsec-client = { version = "0.10.0", features = ["testing"] }
1818
log = "0.4.11"
1919
rand = "0.7.3"
2020

e2e_tests/provider_cfg/all/config.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ allow_root = true
1010
[listener]
1111
listener_type = "DomainSocket"
1212
timeout = 200 # in milliseconds
13+
socket_path = "/tmp/parsec.sock"
1314

1415
[[key_manager]]
1516
name = "on-disk-manager"
1617
manager_type = "OnDisk"
18+
store_path = "./mappings"
1719

1820
[[provider]]
1921
provider_type = "MbedCrypto"

e2e_tests/provider_cfg/mbed-crypto/config.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ listener_type = "DomainSocket"
1212
# The timeout needs to be smaller than the test client timeout (five seconds) as it is testing
1313
# that the service does not hang for very big values of body or authentication length.
1414
timeout = 3000 # in milliseconds
15+
socket_path = "/tmp/parsec.sock"
1516

1617
[[key_manager]]
1718
name = "on-disk-manager"
1819
manager_type = "OnDisk"
20+
store_path = "./mappings"
1921

2022
[[provider]]
2123
provider_type = "MbedCrypto"

e2e_tests/provider_cfg/pkcs11/config.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ listener_type = "DomainSocket"
1212
# The timeout needs to be smaller than the test client timeout (five seconds) as it is testing
1313
# that the service does not hang for very big values of body or authentication length.
1414
timeout = 3000 # in milliseconds
15+
socket_path = "/tmp/parsec.sock"
1516

1617
[[key_manager]]
1718
name = "on-disk-manager"
1819
manager_type = "OnDisk"
20+
store_path = "./mappings"
1921

2022
[[provider]]
2123
provider_type = "Pkcs11"

e2e_tests/provider_cfg/tpm/config.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ listener_type = "DomainSocket"
1212
# The timeout needs to be smaller than the test client timeout (five seconds) as it is testing
1313
# that the service does not hang for very big values of body or authentication length.
1414
timeout = 3000 # in milliseconds
15+
socket_path = "/tmp/parsec.sock"
1516

1617
[[key_manager]]
1718
name = "on-disk-manager"
1819
manager_type = "OnDisk"
20+
store_path = "./mappings"
1921

2022
[[provider]]
2123
provider_type = "Tpm"

e2e_tests/src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,15 @@ use parsec_client::core::interface::operations::psa_key_attributes::{
2222
Attributes, EccFamily, Lifetime, Policy, Type, UsageFlags,
2323
};
2424
use parsec_client::core::interface::requests::{Opcode, ProviderID, ResponseStatus, Result};
25+
use parsec_client::core::ipc_handler::unix_socket;
2526
use parsec_client::core::secrecy::{ExposeSecret, Secret};
2627
use parsec_client::error::Error;
2728
use std::collections::HashSet;
2829
use std::time::Duration;
2930

31+
const TEST_SOCKET_PATH: &str = "/tmp/parsec.sock";
32+
const TEST_TIMEOUT: Duration = Duration::from_secs(1);
33+
3034
/// Client structure automatically choosing a provider and high-level operation functions.
3135
#[derive(Debug)]
3236
pub struct TestClient {
@@ -58,6 +62,9 @@ impl TestClient {
5862
created_keys: Some(HashSet::new()),
5963
};
6064

65+
let ipc_handler = unix_socket::Handler::new(TEST_SOCKET_PATH.into(), Some(TEST_TIMEOUT));
66+
client.basic_client.set_ipc_handler(Box::from(ipc_handler));
67+
6168
let crypto_provider = client.find_crypto_provider();
6269
client.set_provider(crypto_provider);
6370
client

e2e_tests/src/raw_request.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const MAX_BODY_SIZE: usize = 1 << 31;
1313
#[derive(Copy, Clone, Debug)]
1414
pub struct RawRequestClient;
1515

16-
static SOCKET_PATH: &str = "/tmp/parsec/parsec.sock";
16+
static SOCKET_PATH: &str = "/tmp/parsec.sock";
1717
const TIMEOUT: Duration = Duration::from_secs(5);
1818

1919
#[allow(clippy::new_without_default)]

e2e_tests/tests/config/tomls/list_providers_1.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ log_error_details = true
66
[listener]
77
listener_type = "DomainSocket"
88
timeout = 200 # in milliseconds
9+
socket_path = "/tmp/parsec.sock"
910

1011
[[key_manager]]
1112
name = "on-disk-manager"
1213
manager_type = "OnDisk"
14+
store_path = "./mappings"
1315

1416
[[provider]]
1517
provider_type = "MbedCrypto"

e2e_tests/tests/config/tomls/list_providers_2.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ log_error_details = true
66
[listener]
77
listener_type = "DomainSocket"
88
timeout = 200 # in milliseconds
9+
socket_path = "/tmp/parsec.sock"
910

1011
[[key_manager]]
1112
name = "on-disk-manager"
1213
manager_type = "OnDisk"
14+
store_path = "./mappings"
1315

1416
[[provider]]
1517
provider_type = "Pkcs11"

e2e_tests/tests/config/tomls/pkcs11_software.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ listener_type = "DomainSocket"
1212
# The timeout needs to be smaller than the test client timeout (five seconds) as it is testing
1313
# that the service does not hang for very big values of body or authentication length.
1414
timeout = 3000 # in milliseconds
15+
socket_path = "/tmp/parsec.sock"
1516

1617
[[key_manager]]
1718
name = "on-disk-manager"
1819
manager_type = "OnDisk"
20+
store_path = "./mappings"
1921

2022
[[provider]]
2123
provider_type = "Pkcs11"

e2e_tests/tests/per_provider/normal_tests/export_key.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,14 @@ fn export_without_create() {
9191
}
9292

9393
#[test]
94-
fn import_and_export_public_key() -> Result<()> {
94+
fn import_and_export_key() -> Result<()> {
9595
let mut client = TestClient::new();
9696

9797
if !client.is_operation_supported(Opcode::PsaExportKey) {
9898
return Ok(());
9999
}
100100

101-
let key_name = String::from("import_and_export_public_key");
101+
let key_name = String::from("import_and_export_key");
102102
let key_data = vec![
103103
48, 129, 137, 2, 129, 129, 0, 153, 165, 220, 135, 89, 101, 254, 229, 28, 33, 138, 247, 20,
104104
102, 253, 217, 247, 246, 142, 107, 51, 40, 179, 149, 45, 117, 254, 236, 161, 109, 16, 81,

e2e_tests/tests/per_provider/normal_tests/ping.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ use parsec_client::core::interface::requests::Opcode;
77
use parsec_client::core::interface::requests::ProviderID;
88
use parsec_client::core::interface::requests::ResponseStatus;
99
use parsec_client::core::interface::requests::Result;
10+
use parsec_client::core::ipc_handler::unix_socket;
11+
use std::time::Duration;
1012

1113
#[test]
1214
fn test_ping() -> Result<()> {
@@ -20,7 +22,13 @@ fn test_ping() -> Result<()> {
2022

2123
#[test]
2224
fn mangled_ping() {
23-
let client = RequestClient::default();
25+
let client = RequestClient {
26+
ipc_handler: Box::from(unix_socket::Handler::new(
27+
"/tmp/parsec.sock".into(),
28+
Some(Duration::from_secs(1)),
29+
)),
30+
..Default::default()
31+
};
2432
let mut req = Request::new();
2533
req.header.provider = ProviderID::Core;
2634
req.header.opcode = Opcode::Ping;

fuzz/config.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
[listener]
44
listener_type = "DomainSocket"
55
timeout = 200 # in milliseconds
6+
socket_path = "/tmp/parsec.sock"
67

78
[[key_manager]]
89
name = "on-disk-manager"
910
manager_type = "OnDisk"
11+
store_path = "./mappings"
1012

1113
# [[provider]]
1214
# provider_type = "MbedCryptoProvider"

0 commit comments

Comments
 (0)