all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox-backup 0/2] reduce pbs-api-types deps
@ 2022-01-12 13:52 Fabian Grünbichler
  2022-01-12 13:52 ` [pbs-devel] [PATCH proxmox-backup 1/2] api-types: move RsaPubKeyInfo to pbs-client Fabian Grünbichler
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Fabian Grünbichler @ 2022-01-12 13:52 UTC (permalink / raw)
  To: pbs-devel

this cuts down the dependency tree of pbs-api-types by 31 (transitive)
deps (and shaves off a whopping 2-3s of `cargo build --release` time
;)). obviously we use all those deps in pbs itself, but simplification
doesn't hurt if we want to re-use this elsewhere.

Fabian Grünbichler (2):
  api-types: move RsaPubKeyInfo to pbs-client
  api-types: relax NODENAME_SCHEMA

 pbs-api-types/Cargo.toml         |  4 ---
 pbs-api-types/src/lib.rs         | 44 ++------------------------------
 proxmox-backup-client/src/key.rs | 37 ++++++++++++++++++++++++++-
 3 files changed, 38 insertions(+), 47 deletions(-)

-- 
2.30.2





^ permalink raw reply	[flat|nested] 4+ messages in thread

* [pbs-devel] [PATCH proxmox-backup 1/2] api-types: move RsaPubKeyInfo to pbs-client
  2022-01-12 13:52 [pbs-devel] [PATCH proxmox-backup 0/2] reduce pbs-api-types deps Fabian Grünbichler
@ 2022-01-12 13:52 ` Fabian Grünbichler
  2022-01-12 13:52 ` [pbs-devel] [PATCH proxmox-backup 2/2] api-types: relax NODENAME_SCHEMA Fabian Grünbichler
  2022-01-14  5:30 ` [pbs-devel] applied-series: [PATCH proxmox-backup 0/2] reduce pbs-api-types deps Thomas Lamprecht
  2 siblings, 0 replies; 4+ messages in thread
From: Fabian Grünbichler @ 2022-01-12 13:52 UTC (permalink / raw)
  To: pbs-devel

it's the only thing requiring openssl in pbs-api-types, and it's only
used by the client to pretty-print the 'master' key, which is
client-specific.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
 pbs-api-types/Cargo.toml         |  1 -
 pbs-api-types/src/lib.rs         | 33 ----------------------------
 proxmox-backup-client/src/key.rs | 37 +++++++++++++++++++++++++++++++-
 3 files changed, 36 insertions(+), 35 deletions(-)

diff --git a/pbs-api-types/Cargo.toml b/pbs-api-types/Cargo.toml
index b40a707c..09107ace 100644
--- a/pbs-api-types/Cargo.toml
+++ b/pbs-api-types/Cargo.toml
@@ -21,4 +21,3 @@ proxmox-uuid = { version = "1.0.0", features = [ "serde" ] }
 
 [target.'cfg(not(target_arch="wasm32"))'.dependencies]
 proxmox-sys = "0.2" # only needed for nodename()??
-openssl = "0.10"
diff --git a/pbs-api-types/src/lib.rs b/pbs-api-types/src/lib.rs
index 0a0dd33d..26bef33d 100644
--- a/pbs-api-types/src/lib.rs
+++ b/pbs-api-types/src/lib.rs
@@ -312,39 +312,6 @@ pub const PASSWORD_HINT_SCHEMA: Schema = StringSchema::new("Password hint.")
     .schema();
 
 
-#[api]
-#[derive(Deserialize, Serialize)]
-/// RSA public key information
-pub struct RsaPubKeyInfo {
-    /// Path to key (if stored in a file)
-    #[serde(skip_serializing_if="Option::is_none")]
-    pub path: Option<String>,
-    /// RSA exponent
-    pub exponent: String,
-    /// Hex-encoded RSA modulus
-    pub modulus: String,
-    /// Key (modulus) length in bits
-    pub length: usize,
-}
-
-#[cfg(not(target_arch="wasm32"))]
-impl std::convert::TryFrom<openssl::rsa::Rsa<openssl::pkey::Public>> for RsaPubKeyInfo {
-    type Error = anyhow::Error;
-
-    fn try_from(value: openssl::rsa::Rsa<openssl::pkey::Public>) -> Result<Self, Self::Error> {
-        let modulus = value.n().to_hex_str()?.to_string();
-        let exponent = value.e().to_dec_str()?.to_string();
-        let length = value.size() as usize * 8;
-
-        Ok(Self {
-            path: None,
-            exponent,
-            modulus,
-            length,
-        })
-    }
-}
-
 #[api()]
 #[derive(Debug, Clone, Serialize, Deserialize)]
 #[serde(rename_all = "PascalCase")]
diff --git a/proxmox-backup-client/src/key.rs b/proxmox-backup-client/src/key.rs
index 427a58df..288d6c67 100644
--- a/proxmox-backup-client/src/key.rs
+++ b/proxmox-backup-client/src/key.rs
@@ -2,6 +2,7 @@ use std::convert::TryFrom;
 use std::path::PathBuf;
 
 use anyhow::{bail, format_err, Error};
+use serde::{Deserialize, Serialize};
 use serde_json::Value;
 
 use proxmox_sys::linux::tty;
@@ -13,7 +14,7 @@ use proxmox_router::cli::{
 };
 use proxmox_schema::{api, ApiType, ReturnType};
 
-use pbs_api_types::{RsaPubKeyInfo, PASSWORD_HINT_SCHEMA, Kdf, KeyInfo};
+use pbs_api_types::{PASSWORD_HINT_SCHEMA, Kdf, KeyInfo};
 use pbs_config::key_config::{KeyConfig, rsa_decrypt_key_config};
 use pbs_datastore::paperkey::{generate_paper_key, PaperkeyFormat};
 use pbs_client::tools::key_source::{
@@ -21,6 +22,40 @@ use pbs_client::tools::key_source::{
     place_default_encryption_key, place_default_master_pubkey,
 };
 
+#[api]
+#[derive(Deserialize, Serialize)]
+/// RSA public key information
+pub struct RsaPubKeyInfo {
+    /// Path to key (if stored in a file)
+    #[serde(skip_serializing_if="Option::is_none")]
+    pub path: Option<String>,
+    /// RSA exponent
+    pub exponent: String,
+    /// Hex-encoded RSA modulus
+    pub modulus: String,
+    /// Key (modulus) length in bits
+    pub length: usize,
+}
+
+#[cfg(not(target_arch="wasm32"))]
+impl std::convert::TryFrom<openssl::rsa::Rsa<openssl::pkey::Public>> for RsaPubKeyInfo {
+    type Error = anyhow::Error;
+
+    fn try_from(value: openssl::rsa::Rsa<openssl::pkey::Public>) -> Result<Self, Self::Error> {
+        let modulus = value.n().to_hex_str()?.to_string();
+        let exponent = value.e().to_dec_str()?.to_string();
+        let length = value.size() as usize * 8;
+
+        Ok(Self {
+            path: None,
+            exponent,
+            modulus,
+            length,
+        })
+    }
+}
+
+
 #[api(
     input: {
         properties: {
-- 
2.30.2





^ permalink raw reply	[flat|nested] 4+ messages in thread

* [pbs-devel] [PATCH proxmox-backup 2/2] api-types: relax NODENAME_SCHEMA
  2022-01-12 13:52 [pbs-devel] [PATCH proxmox-backup 0/2] reduce pbs-api-types deps Fabian Grünbichler
  2022-01-12 13:52 ` [pbs-devel] [PATCH proxmox-backup 1/2] api-types: move RsaPubKeyInfo to pbs-client Fabian Grünbichler
@ 2022-01-12 13:52 ` Fabian Grünbichler
  2022-01-14  5:30 ` [pbs-devel] applied-series: [PATCH proxmox-backup 0/2] reduce pbs-api-types deps Thomas Lamprecht
  2 siblings, 0 replies; 4+ messages in thread
From: Fabian Grünbichler @ 2022-01-12 13:52 UTC (permalink / raw)
  To: pbs-devel

there isn't really a concept of 'nodes' in PBS (yet) anyway - and if
there ever is, it needs to be handled by the rest-server / specific API
endpoints (like in PVE), and not by the schema.

this allows dropping proxmox-sys from pbs-api-types (and thus nix and
some other transitive deps as well).

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
 pbs-api-types/Cargo.toml |  3 ---
 pbs-api-types/src/lib.rs | 11 ++---------
 2 files changed, 2 insertions(+), 12 deletions(-)

diff --git a/pbs-api-types/Cargo.toml b/pbs-api-types/Cargo.toml
index 09107ace..e77d8bc4 100644
--- a/pbs-api-types/Cargo.toml
+++ b/pbs-api-types/Cargo.toml
@@ -18,6 +18,3 @@ proxmox-schema = { version = "1.1", features = [ "api-macro" ] }
 proxmox-serde = "0.1"
 proxmox-time = "1.1.1"
 proxmox-uuid = { version = "1.0.0", features = [ "serde" ] }
-
-[target.'cfg(not(target_arch="wasm32"))'.dependencies]
-proxmox-sys = "0.2" # only needed for nodename()??
diff --git a/pbs-api-types/src/lib.rs b/pbs-api-types/src/lib.rs
index 26bef33d..e3c3df11 100644
--- a/pbs-api-types/src/lib.rs
+++ b/pbs-api-types/src/lib.rs
@@ -1,7 +1,6 @@
 //! Basic API types used by most of the PBS code.
 
 use serde::{Deserialize, Serialize};
-use anyhow::bail;
 
 pub mod common_regex;
 pub mod percent_encoding;
@@ -199,15 +198,9 @@ pub const DNS_NAME_OR_IP_SCHEMA: Schema = StringSchema::new("DNS name or IP addr
     .format(&DNS_NAME_OR_IP_FORMAT)
     .schema();
 
-#[cfg(not(target_arch="wasm32"))] // this only makes sense for the serever side
+
 pub const NODE_SCHEMA: Schema = StringSchema::new("Node name (or 'localhost')")
-    .format(&ApiStringFormat::VerifyFn(|node| {
-        if node == "localhost" || node == proxmox_sys::nodename() {
-            Ok(())
-        } else {
-            bail!("no such node '{}'", node);
-        }
-    }))
+    .format(&HOSTNAME_FORMAT)
     .schema();
 
 pub const TIME_ZONE_SCHEMA: Schema = StringSchema::new(
-- 
2.30.2





^ permalink raw reply	[flat|nested] 4+ messages in thread

* [pbs-devel] applied-series: [PATCH proxmox-backup 0/2] reduce pbs-api-types deps
  2022-01-12 13:52 [pbs-devel] [PATCH proxmox-backup 0/2] reduce pbs-api-types deps Fabian Grünbichler
  2022-01-12 13:52 ` [pbs-devel] [PATCH proxmox-backup 1/2] api-types: move RsaPubKeyInfo to pbs-client Fabian Grünbichler
  2022-01-12 13:52 ` [pbs-devel] [PATCH proxmox-backup 2/2] api-types: relax NODENAME_SCHEMA Fabian Grünbichler
@ 2022-01-14  5:30 ` Thomas Lamprecht
  2 siblings, 0 replies; 4+ messages in thread
From: Thomas Lamprecht @ 2022-01-14  5:30 UTC (permalink / raw)
  To: Proxmox Backup Server development discussion, Fabian Grünbichler

On 12.01.22 14:52, Fabian Grünbichler wrote:
> this cuts down the dependency tree of pbs-api-types by 31 (transitive)
> deps (and shaves off a whopping 2-3s of `cargo build --release` time
> ;)). obviously we use all those deps in pbs itself, but simplification
> doesn't hurt if we want to re-use this elsewhere.
> 
> Fabian Grünbichler (2):
>   api-types: move RsaPubKeyInfo to pbs-client
>   api-types: relax NODENAME_SCHEMA
> 
>  pbs-api-types/Cargo.toml         |  4 ---
>  pbs-api-types/src/lib.rs         | 44 ++------------------------------
>  proxmox-backup-client/src/key.rs | 37 ++++++++++++++++++++++++++-
>  3 files changed, 38 insertions(+), 47 deletions(-)
> 



applied, thanks!




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-01-14  5:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-12 13:52 [pbs-devel] [PATCH proxmox-backup 0/2] reduce pbs-api-types deps Fabian Grünbichler
2022-01-12 13:52 ` [pbs-devel] [PATCH proxmox-backup 1/2] api-types: move RsaPubKeyInfo to pbs-client Fabian Grünbichler
2022-01-12 13:52 ` [pbs-devel] [PATCH proxmox-backup 2/2] api-types: relax NODENAME_SCHEMA Fabian Grünbichler
2022-01-14  5:30 ` [pbs-devel] applied-series: [PATCH proxmox-backup 0/2] reduce pbs-api-types deps Thomas Lamprecht

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal