From 84c52f3810d2bdb4a0d7f3d55d2c4100050b4aa4 Mon Sep 17 00:00:00 2001 From: Stoiko Ivanov Date: Mon, 9 May 2022 12:17:51 +0200 Subject: [PATCH 01/35] common: d/control: break/replace libpve-rs-perl (<< 0.6.0) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit libproxmox-rs-perl ships /usr/share/perl5/PVE/RS/CalendarEvent.pm, which was also present in libpve-rs-perl until version 0.5.1 This can lead to a (racy) issue while upgrading - depending on which of libproxmox-rs-perl or libpve-rs-perl gets unpacked first we potentially run into: ``` dpkg: error processing archive \ /tmp/apt-dpkg-install-lNBzMn/48-libproxmox-rs-perl_0.1.0_amd64.deb (--unpack): trying to overwrite '/usr/share/perl5/PVE/RS/CalendarEvent.pm', \ which is also in package libpve-rs-perl 0.5.1 ``` This patch follows the debian policy manual for these situations: https://www.debian.org/doc/debian-policy/ch-relationships.html#s-breaks Signed-off-by: Stoiko Ivanov Reviewed-by: Fabian Grünbichler Acked-by: Fabian Grünbichler --- common/pkg/debian/control | 2 ++ 1 file changed, 2 insertions(+) diff --git a/common/pkg/debian/control b/common/pkg/debian/control index cdda8c54..8bc510c0 100644 --- a/common/pkg/debian/control +++ b/common/pkg/debian/control @@ -17,6 +17,8 @@ Depends: ${perl:Depends}, ${shlibs:Depends}, libpve-rs-perl (>= 0.6.0) | libpmg-rs-perl (>= 0.5.0), +Breaks: libpve-rs-perl (<< 0.6.0) +Replaces: libpve-rs-perl (<< 0.6.0) Description: PVE/PMG common parts which have been ported to Rust - Perl packages Contains the perl side of modules provided by the libraries of both libpve-rs-perl and libpmg-rs-perl, loading whichever is available. From b67ff27d9e5869d0e7d25bf6b0c8176b401cb438 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= Date: Thu, 2 Jun 2022 13:36:44 +0200 Subject: [PATCH 02/35] update to nix 0.24 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fabian Grünbichler --- pmg-rs/Cargo.toml | 2 +- pmg-rs/src/tfa.rs | 2 +- pve-rs/Cargo.toml | 2 +- pve-rs/src/tfa.rs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pmg-rs/Cargo.toml b/pmg-rs/Cargo.toml index a9e80bf2..6645e91b 100644 --- a/pmg-rs/Cargo.toml +++ b/pmg-rs/Cargo.toml @@ -22,7 +22,7 @@ crate-type = [ "cdylib" ] anyhow = "1.0" hex = "0.4" libc = "0.2" -nix = "0.19" +nix = "0.24" serde = "1.0" serde_bytes = "0.11.3" serde_json = "1.0" diff --git a/pmg-rs/src/tfa.rs b/pmg-rs/src/tfa.rs index 404ddb29..7dbfdaef 100644 --- a/pmg-rs/src/tfa.rs +++ b/pmg-rs/src/tfa.rs @@ -382,7 +382,7 @@ pub(crate) fn mkdir>(path: P, mode: libc::mode_t) -> Result<(), E let path = path.as_ref(); match nix::unistd::mkdir(path, unsafe { Mode::from_bits_unchecked(mode) }) { Ok(()) => Ok(()), - Err(nix::Error::Sys(Errno::EEXIST)) => Ok(()), + Err(Errno::EEXIST) => Ok(()), Err(err) => bail!("failed to create directory {:?}: {}", path, err), } } diff --git a/pve-rs/Cargo.toml b/pve-rs/Cargo.toml index 21ef614f..4414487a 100644 --- a/pve-rs/Cargo.toml +++ b/pve-rs/Cargo.toml @@ -20,7 +20,7 @@ base32 = "0.4" base64 = "0.13" hex = "0.4" libc = "0.2" -nix = "0.19" +nix = "0.24" serde = "1.0" serde_bytes = "0.11" serde_json = "1.0" diff --git a/pve-rs/src/tfa.rs b/pve-rs/src/tfa.rs index cc53118c..c5023384 100644 --- a/pve-rs/src/tfa.rs +++ b/pve-rs/src/tfa.rs @@ -783,7 +783,7 @@ pub(crate) fn mkdir>(path: P, mode: libc::mode_t) -> Result<(), E let path = path.as_ref(); match nix::unistd::mkdir(path, unsafe { Mode::from_bits_unchecked(mode) }) { Ok(()) => Ok(()), - Err(nix::Error::Sys(Errno::EEXIST)) => Ok(()), + Err(Errno::EEXIST) => Ok(()), Err(err) => bail!("failed to create directory {:?}: {}", path, err), } } From 0ddf4db9342b5001ae729083483ab53a44d31d33 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Tue, 10 May 2022 07:12:30 +0200 Subject: [PATCH 03/35] common: bump version to 0.1.1 Signed-off-by: Thomas Lamprecht --- common/pkg/debian/changelog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/common/pkg/debian/changelog b/common/pkg/debian/changelog index 0ed05be4..a956cf52 100644 --- a/common/pkg/debian/changelog +++ b/common/pkg/debian/changelog @@ -1,3 +1,9 @@ +libproxmox-rs-perl (0.1.1) bullseye; urgency=medium + + * rebuild to record break/replace for libpve-rs-perl (<< 0.6.0) + + -- Proxmox Support Team Tue, 10 May 2022 07:12:11 +0200 + libproxmox-rs-perl (0.1.0) bullseye; urgency=medium * initial release From 3db78c95c34c6fe1a3e9e176086a442b7f42e12c Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Tue, 10 May 2022 07:13:56 +0200 Subject: [PATCH 04/35] buildsys: remove common-deb flag file too on clean Signed-off-by: Thomas Lamprecht --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index eff11846..6f9b5977 100644 --- a/Makefile +++ b/Makefile @@ -95,4 +95,4 @@ common-deb: build .PHONY: clean clean: cargo clean - rm -rf ./build ./PVE ./PMG ./pve-deb ./pmg-deb + rm -rf ./build ./PVE ./PMG ./pve-deb ./pmg-deb ./common-deb From b2a4623ac76565bd94ff280b94bf990baeee978f Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Mon, 20 Jun 2022 10:33:11 +0200 Subject: [PATCH 05/35] d/control: update build-dep for nix rs dependency to 0.24 was missed in commit b67ff27d9e5869d0e7d25bf6b0c8176b401cb438 Signed-off-by: Thomas Lamprecht --- pmg-rs/debian/control | 2 +- pve-rs/debian/control | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pmg-rs/debian/control b/pmg-rs/debian/control index c74576eb..d089af28 100644 --- a/pmg-rs/debian/control +++ b/pmg-rs/debian/control @@ -11,7 +11,7 @@ Build-Depends: librust-anyhow-1+default-dev, librust-hex-0.4+default-dev, librust-libc-0.2+default-dev, - librust-nix-0.19+default-dev, + librust-nix-0.24+default-dev, librust-perlmod-0.13+default-dev, librust-perlmod-0.13+exporter-dev, librust-proxmox-acme-rs-0.4+client-dev, diff --git a/pve-rs/debian/control b/pve-rs/debian/control index 6adec83a..6f34e3e2 100644 --- a/pve-rs/debian/control +++ b/pve-rs/debian/control @@ -12,7 +12,7 @@ Build-Depends: librust-base64-0.13+default-dev, librust-hex-0.4+default-dev, librust-libc-0.2+default-dev, - librust-nix-0.19+default-dev, + librust-nix-0.24+default-dev, librust-perlmod-0.13+default-dev, librust-perlmod-0.13+exporter-dev, librust-proxmox-apt-0.8+default-dev, From c3982c55b8f3ffa9aa4ba73ae00ec2758bf71fe3 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Wed, 6 Jul 2022 12:34:41 +0200 Subject: [PATCH 06/35] common: fix base for PMG Signed-off-by: Wolfgang Bumiller --- Proxmox/Lib/Common.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Proxmox/Lib/Common.pm b/Proxmox/Lib/Common.pm index d8a0d570..1e6b26d6 100644 --- a/Proxmox/Lib/Common.pm +++ b/Proxmox/Lib/Common.pm @@ -35,7 +35,7 @@ BEGIN { push @ISA, $base; } else { eval { require Proxmox::Lib::PVE and push @ISA, 'Proxmox::Lib::PVE'; }; - eval { require Proxmox::Lib::PMG and push @ISA, 'Proxmox::Lib::PVE'; } if $@; + eval { require Proxmox::Lib::PMG and push @ISA, 'Proxmox::Lib::PMG'; } if $@; die $@ if $@; } } From f386660b4baf6b0f698970fad06e349ba82ac1d2 Mon Sep 17 00:00:00 2001 From: Fabian Ebner Date: Fri, 8 Jul 2022 13:55:53 +0200 Subject: [PATCH 07/35] move apt repositories module to common while introducing a 'product' parameter to the relevant functions and adding wrappers for backwards-compatibility. Suggested-by: Wolfgang Bumiller Signed-off-by: Fabian Ebner --- Makefile | 4 +- common/src/apt/mod.rs | 1 + common/src/apt/repositories.rs | 164 +++++++++++++++++++++++++++++++++ common/src/mod.rs | 1 + pmg-rs/src/apt/repositories.rs | 142 ++-------------------------- pve-rs/src/apt/repositories.rs | 142 ++-------------------------- 6 files changed, 183 insertions(+), 271 deletions(-) create mode 100644 common/src/apt/mod.rs create mode 100644 common/src/apt/repositories.rs diff --git a/Makefile b/Makefile index 6f9b5977..c0212a87 100644 --- a/Makefile +++ b/Makefile @@ -41,7 +41,9 @@ pve pmg: gen: $(call package_template,PMG,pmg_rs) $(call package_template,PVE,pve_rs) - perl ./scripts/genpackage.pl Common Proxmox::RS::CalendarEvent + perl ./scripts/genpackage.pl Common \ + Proxmox::RS::APT::Repositories \ + Proxmox::RS::CalendarEvent perl ./scripts/genpackage.pl PVE \ PVE::RS::APT::Repositories \ PVE::RS::OpenId \ diff --git a/common/src/apt/mod.rs b/common/src/apt/mod.rs new file mode 100644 index 00000000..21b552a0 --- /dev/null +++ b/common/src/apt/mod.rs @@ -0,0 +1 @@ +pub mod repositories; diff --git a/common/src/apt/repositories.rs b/common/src/apt/repositories.rs new file mode 100644 index 00000000..26a20e46 --- /dev/null +++ b/common/src/apt/repositories.rs @@ -0,0 +1,164 @@ +#[perlmod::package(name = "Proxmox::RS::APT::Repositories")] +pub mod export { + use std::convert::TryInto; + + use anyhow::{bail, Error}; + use serde::{Deserialize, Serialize}; + + use proxmox_apt::repositories::{ + APTRepositoryFile, APTRepositoryFileError, APTRepositoryHandle, APTRepositoryInfo, + APTStandardRepository, + }; + + #[derive(Deserialize, Serialize)] + #[serde(rename_all = "kebab-case")] + /// Result for the repositories() function + pub struct RepositoriesResult { + /// Successfully parsed files. + pub files: Vec, + + /// Errors for files that could not be parsed or read. + pub errors: Vec, + + /// Common digest for successfully parsed files. + pub digest: String, + + /// Additional information/warnings about repositories. + pub infos: Vec, + + /// Standard repositories and their configuration status. + pub standard_repos: Vec, + } + + #[derive(Deserialize, Serialize)] + #[serde(rename_all = "kebab-case")] + /// For changing an existing repository. + pub struct ChangeProperties { + /// Whether the repository should be enabled or not. + pub enabled: Option, + } + + /// Get information about configured repositories and standard repositories for `product`. + #[export] + pub fn repositories(product: &str) -> Result { + let (files, errors, digest) = proxmox_apt::repositories::repositories()?; + let digest = hex::encode(&digest); + + let suite = proxmox_apt::repositories::get_current_release_codename()?; + + let infos = proxmox_apt::repositories::check_repositories(&files, suite); + let standard_repos = + proxmox_apt::repositories::standard_repositories(&files, product, suite); + + Ok(RepositoriesResult { + files, + errors, + digest, + infos, + standard_repos, + }) + } + + /// Add the repository identified by the `handle` and `product`. + /// If the repository is already configured, it will be set to enabled. + /// + /// The `digest` parameter asserts that the configuration has not been modified. + #[export] + pub fn add_repository(handle: &str, product: &str, digest: Option<&str>) -> Result<(), Error> { + let (mut files, errors, current_digest) = proxmox_apt::repositories::repositories()?; + + let handle: APTRepositoryHandle = handle.try_into()?; + let suite = proxmox_apt::repositories::get_current_release_codename()?; + + if let Some(digest) = digest { + let expected_digest = hex::decode(digest)?; + if expected_digest != current_digest { + bail!("detected modified configuration - file changed by other user? Try again."); + } + } + + // check if it's already configured first + for file in files.iter_mut() { + for repo in file.repositories.iter_mut() { + if repo.is_referenced_repository(handle, product, &suite.to_string()) { + if repo.enabled { + return Ok(()); + } + + repo.set_enabled(true); + file.write()?; + + return Ok(()); + } + } + } + + let (repo, path) = + proxmox_apt::repositories::get_standard_repository(handle, product, suite); + + if let Some(error) = errors.iter().find(|error| error.path == path) { + bail!( + "unable to parse existing file {} - {}", + error.path, + error.error, + ); + } + + if let Some(file) = files.iter_mut().find(|file| file.path == path) { + file.repositories.push(repo); + + file.write()?; + } else { + let mut file = match APTRepositoryFile::new(&path)? { + Some(file) => file, + None => bail!("invalid path - {}", path), + }; + + file.repositories.push(repo); + + file.write()?; + } + + Ok(()) + } + + /// Change the properties of the specified repository. + /// + /// The `digest` parameter asserts that the configuration has not been modified. + #[export] + pub fn change_repository( + path: &str, + index: usize, + options: ChangeProperties, + digest: Option<&str>, + ) -> Result<(), Error> { + let (mut files, errors, current_digest) = proxmox_apt::repositories::repositories()?; + + if let Some(digest) = digest { + let expected_digest = hex::decode(digest)?; + if expected_digest != current_digest { + bail!("detected modified configuration - file changed by other user? Try again."); + } + } + + if let Some(error) = errors.iter().find(|error| error.path == path) { + bail!("unable to parse file {} - {}", error.path, error.error); + } + + if let Some(file) = files.iter_mut().find(|file| file.path == path) { + if let Some(repo) = file.repositories.get_mut(index) { + if let Some(enabled) = options.enabled { + repo.set_enabled(enabled); + } + + file.write()?; + } else { + bail!("invalid index - {}", index); + } + } else { + bail!("invalid path - {}", path); + } + + Ok(()) + } +} diff --git a/common/src/mod.rs b/common/src/mod.rs index fe377d71..738657ea 100644 --- a/common/src/mod.rs +++ b/common/src/mod.rs @@ -1 +1,2 @@ +pub mod apt; mod calendar_event; diff --git a/pmg-rs/src/apt/repositories.rs b/pmg-rs/src/apt/repositories.rs index 596ea4d4..f6ddb370 100644 --- a/pmg-rs/src/apt/repositories.rs +++ b/pmg-rs/src/apt/repositories.rs @@ -1,61 +1,13 @@ #[perlmod::package(name = "PMG::RS::APT::Repositories")] mod export { - use std::convert::TryInto; + use anyhow::Error; - use anyhow::{bail, Error}; - use serde::{Deserialize, Serialize}; - - use proxmox_apt::repositories::{ - APTRepositoryFile, APTRepositoryFileError, APTRepositoryHandle, APTRepositoryInfo, - APTStandardRepository, - }; - - #[derive(Deserialize, Serialize)] - #[serde(rename_all = "kebab-case")] - /// Result for the repositories() function - pub struct RepositoriesResult { - /// Successfully parsed files. - pub files: Vec, - - /// Errors for files that could not be parsed or read. - pub errors: Vec, - - /// Common digest for successfully parsed files. - pub digest: String, - - /// Additional information/warnings about repositories. - pub infos: Vec, - - /// Standard repositories and their configuration status. - pub standard_repos: Vec, - } - - #[derive(Deserialize, Serialize)] - #[serde(rename_all = "kebab-case")] - /// For changing an existing repository. - pub struct ChangeProperties { - /// Whether the repository should be enabled or not. - pub enabled: Option, - } + use crate::common::apt::repositories::export as common; /// Get information about configured and standard repositories. #[export] - pub fn repositories() -> Result { - let (files, errors, digest) = proxmox_apt::repositories::repositories()?; - let digest = hex::encode(&digest); - - let suite = proxmox_apt::repositories::get_current_release_codename()?; - - let infos = proxmox_apt::repositories::check_repositories(&files, suite); - let standard_repos = proxmox_apt::repositories::standard_repositories(&files, "pmg", suite); - - Ok(RepositoriesResult { - files, - errors, - digest, - infos, - standard_repos, - }) + pub fn repositories() -> Result { + common::repositories("pmg") } /// Add the repository identified by the `handle`. @@ -64,60 +16,7 @@ mod export { /// The `digest` parameter asserts that the configuration has not been modified. #[export] pub fn add_repository(handle: &str, digest: Option<&str>) -> Result<(), Error> { - let (mut files, errors, current_digest) = proxmox_apt::repositories::repositories()?; - - let handle: APTRepositoryHandle = handle.try_into()?; - let suite = proxmox_apt::repositories::get_current_release_codename()?; - - if let Some(digest) = digest { - let expected_digest = hex::decode(digest)?; - if expected_digest != current_digest { - bail!("detected modified configuration - file changed by other user? Try again."); - } - } - - // check if it's already configured first - for file in files.iter_mut() { - for repo in file.repositories.iter_mut() { - if repo.is_referenced_repository(handle, "pmg", &suite.to_string()) { - if repo.enabled { - return Ok(()); - } - - repo.set_enabled(true); - file.write()?; - - return Ok(()); - } - } - } - - let (repo, path) = proxmox_apt::repositories::get_standard_repository(handle, "pmg", suite); - - if let Some(error) = errors.iter().find(|error| error.path == path) { - bail!( - "unable to parse existing file {} - {}", - error.path, - error.error, - ); - } - - if let Some(file) = files.iter_mut().find(|file| file.path == path) { - file.repositories.push(repo); - - file.write()?; - } else { - let mut file = match APTRepositoryFile::new(&path)? { - Some(file) => file, - None => bail!("invalid path - {}", path), - }; - - file.repositories.push(repo); - - file.write()?; - } - - Ok(()) + common::add_repository(handle, "pmg", digest) } /// Change the properties of the specified repository. @@ -127,36 +26,9 @@ mod export { pub fn change_repository( path: &str, index: usize, - options: ChangeProperties, + options: common::ChangeProperties, digest: Option<&str>, ) -> Result<(), Error> { - let (mut files, errors, current_digest) = proxmox_apt::repositories::repositories()?; - - if let Some(digest) = digest { - let expected_digest = hex::decode(digest)?; - if expected_digest != current_digest { - bail!("detected modified configuration - file changed by other user? Try again."); - } - } - - if let Some(error) = errors.iter().find(|error| error.path == path) { - bail!("unable to parse file {} - {}", error.path, error.error); - } - - if let Some(file) = files.iter_mut().find(|file| file.path == path) { - if let Some(repo) = file.repositories.get_mut(index) { - if let Some(enabled) = options.enabled { - repo.set_enabled(enabled); - } - - file.write()?; - } else { - bail!("invalid index - {}", index); - } - } else { - bail!("invalid path - {}", path); - } - - Ok(()) + common::change_repository(path, index, options, digest) } } diff --git a/pve-rs/src/apt/repositories.rs b/pve-rs/src/apt/repositories.rs index 2d5e1da0..d5c2f560 100644 --- a/pve-rs/src/apt/repositories.rs +++ b/pve-rs/src/apt/repositories.rs @@ -1,61 +1,13 @@ #[perlmod::package(name = "PVE::RS::APT::Repositories", lib = "pve_rs")] mod export { - use std::convert::TryInto; + use anyhow::Error; - use anyhow::{bail, Error}; - use serde::{Deserialize, Serialize}; - - use proxmox_apt::repositories::{ - APTRepositoryFile, APTRepositoryFileError, APTRepositoryHandle, APTRepositoryInfo, - APTStandardRepository, - }; - - #[derive(Deserialize, Serialize)] - #[serde(rename_all = "kebab-case")] - /// Result for the repositories() function - pub struct RepositoriesResult { - /// Successfully parsed files. - pub files: Vec, - - /// Errors for files that could not be parsed or read. - pub errors: Vec, - - /// Common digest for successfully parsed files. - pub digest: String, - - /// Additional information/warnings about repositories. - pub infos: Vec, - - /// Standard repositories and their configuration status. - pub standard_repos: Vec, - } - - #[derive(Deserialize, Serialize)] - #[serde(rename_all = "kebab-case")] - /// For changing an existing repository. - pub struct ChangeProperties { - /// Whether the repository should be enabled or not. - pub enabled: Option, - } + use crate::common::apt::repositories::export as common; /// Get information about configured and standard repositories. #[export] - pub fn repositories() -> Result { - let (files, errors, digest) = proxmox_apt::repositories::repositories()?; - let digest = hex::encode(&digest); - - let suite = proxmox_apt::repositories::get_current_release_codename()?; - - let infos = proxmox_apt::repositories::check_repositories(&files, suite); - let standard_repos = proxmox_apt::repositories::standard_repositories(&files, "pve", suite); - - Ok(RepositoriesResult { - files, - errors, - digest, - infos, - standard_repos, - }) + pub fn repositories() -> Result { + common::repositories("pve") } /// Add the repository identified by the `handle`. @@ -64,60 +16,7 @@ mod export { /// The `digest` parameter asserts that the configuration has not been modified. #[export] pub fn add_repository(handle: &str, digest: Option<&str>) -> Result<(), Error> { - let (mut files, errors, current_digest) = proxmox_apt::repositories::repositories()?; - - let handle: APTRepositoryHandle = handle.try_into()?; - let suite = proxmox_apt::repositories::get_current_release_codename()?; - - if let Some(digest) = digest { - let expected_digest = hex::decode(digest)?; - if expected_digest != current_digest { - bail!("detected modified configuration - file changed by other user? Try again."); - } - } - - // check if it's already configured first - for file in files.iter_mut() { - for repo in file.repositories.iter_mut() { - if repo.is_referenced_repository(handle, "pve", &suite.to_string()) { - if repo.enabled { - return Ok(()); - } - - repo.set_enabled(true); - file.write()?; - - return Ok(()); - } - } - } - - let (repo, path) = proxmox_apt::repositories::get_standard_repository(handle, "pve", suite); - - if let Some(error) = errors.iter().find(|error| error.path == path) { - bail!( - "unable to parse existing file {} - {}", - error.path, - error.error, - ); - } - - if let Some(file) = files.iter_mut().find(|file| file.path == path) { - file.repositories.push(repo); - - file.write()?; - } else { - let mut file = match APTRepositoryFile::new(&path)? { - Some(file) => file, - None => bail!("invalid path - {}", path), - }; - - file.repositories.push(repo); - - file.write()?; - } - - Ok(()) + common::add_repository(handle, "pve", digest) } /// Change the properties of the specified repository. @@ -127,36 +26,9 @@ mod export { pub fn change_repository( path: &str, index: usize, - options: ChangeProperties, + options: common::ChangeProperties, digest: Option<&str>, ) -> Result<(), Error> { - let (mut files, errors, current_digest) = proxmox_apt::repositories::repositories()?; - - if let Some(digest) = digest { - let expected_digest = hex::decode(digest)?; - if expected_digest != current_digest { - bail!("detected modified configuration - file changed by other user? Try again."); - } - } - - if let Some(error) = errors.iter().find(|error| error.path == path) { - bail!("unable to parse file {} - {}", error.path, error.error); - } - - if let Some(file) = files.iter_mut().find(|file| file.path == path) { - if let Some(repo) = file.repositories.get_mut(index) { - if let Some(enabled) = options.enabled { - repo.set_enabled(enabled); - } - - file.write()?; - } else { - bail!("invalid index - {}", index); - } - } else { - bail!("invalid path - {}", path); - } - - Ok(()) + common::change_repository(path, index, options, digest) } } From a50a2191e80e1407dd6038fe9a773df52a989d87 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Fri, 8 Jul 2022 14:48:11 +0200 Subject: [PATCH 08/35] common: depend on next pmg/pve bump Signed-off-by: Wolfgang Bumiller --- common/pkg/debian/control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/pkg/debian/control b/common/pkg/debian/control index 8bc510c0..4669118d 100644 --- a/common/pkg/debian/control +++ b/common/pkg/debian/control @@ -16,7 +16,7 @@ Depends: ${misc:Depends}, ${perl:Depends}, ${shlibs:Depends}, - libpve-rs-perl (>= 0.6.0) | libpmg-rs-perl (>= 0.5.0), + libpve-rs-perl (>= 0.6.2) | libpmg-rs-perl (>= 0.5.1), Breaks: libpve-rs-perl (<< 0.6.0) Replaces: libpve-rs-perl (<< 0.6.0) Description: PVE/PMG common parts which have been ported to Rust - Perl packages From 059d216e12e12218e13fa189e6f274f57a8d9ee8 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Fri, 8 Jul 2022 14:49:41 +0200 Subject: [PATCH 09/35] bump pmg-rs to 0.5.2 Signed-off-by: Wolfgang Bumiller --- pmg-rs/Cargo.toml | 2 +- pmg-rs/debian/changelog | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/pmg-rs/Cargo.toml b/pmg-rs/Cargo.toml index 6645e91b..8d9a9bcf 100644 --- a/pmg-rs/Cargo.toml +++ b/pmg-rs/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pmg-rs" -version = "0.5.0" +version = "0.5.2" authors = [ "Proxmox Support Team ", "Wolfgang Bumiller ", diff --git a/pmg-rs/debian/changelog b/pmg-rs/debian/changelog index 2f5c0b34..fd572aa9 100644 --- a/pmg-rs/debian/changelog +++ b/pmg-rs/debian/changelog @@ -1,3 +1,11 @@ +libpmg-rs-perl (0.5.2) bullseye; urgency=medium + + * add common apt module + + * update nix to 0.24 + + -- Proxmox Support Team Fri, 08 Jul 2022 14:48:58 +0200 + libpmg-rs-perl (0.5.1) bullseye; urgency=medium * install missing PMG.pm file From 2ae629ac44a0e207f092342c37000d5e4bd0569c Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Fri, 8 Jul 2022 14:49:47 +0200 Subject: [PATCH 10/35] bump pve-rs to 0.6.2 Signed-off-by: Wolfgang Bumiller --- pve-rs/Cargo.toml | 2 +- pve-rs/debian/changelog | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/pve-rs/Cargo.toml b/pve-rs/Cargo.toml index 4414487a..87644053 100644 --- a/pve-rs/Cargo.toml +++ b/pve-rs/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pve-rs" -version = "0.6.1" +version = "0.6.2" authors = ["Proxmox Support Team "] edition = "2018" license = "AGPL-3" diff --git a/pve-rs/debian/changelog b/pve-rs/debian/changelog index 4c1a2a78..40b94bbb 100644 --- a/pve-rs/debian/changelog +++ b/pve-rs/debian/changelog @@ -1,3 +1,11 @@ +libpve-rs-perl (0.6.2) bullseye; urgency=medium + + * add common apt module + + * update nix to 0.24 + + -- Proxmox Support Team Fri, 08 Jul 2022 14:48:21 +0200 + libpve-rs-perl (0.6.1) bullseye; urgency=medium * update OpenID connect proxmox integration dependency to fix Azure AD From c0780981606ea45e5597f3ce5a53095aac83c3bc Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Fri, 8 Jul 2022 14:50:35 +0200 Subject: [PATCH 11/35] bump common version to 0.1.2 Signed-off-by: Wolfgang Bumiller --- common/pkg/debian/changelog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/common/pkg/debian/changelog b/common/pkg/debian/changelog index a956cf52..95941f6f 100644 --- a/common/pkg/debian/changelog +++ b/common/pkg/debian/changelog @@ -1,3 +1,9 @@ +libproxmox-rs-perl (0.1.2) bullseye; urgency=medium + + * add common apt module + + -- Proxmox Support Team Fri, 08 Jul 2022 14:50:18 +0200 + libproxmox-rs-perl (0.1.1) bullseye; urgency=medium * rebuild to record break/replace for libpve-rs-perl (<< 0.6.0) From 8fe90d189c70e290681d2faee9d2df0af83d9187 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Fri, 8 Jul 2022 14:54:22 +0200 Subject: [PATCH 12/35] buildsys: add common-upload target Signed-off-by: Wolfgang Bumiller --- Makefile | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index c0212a87..0055abdb 100644 --- a/Makefile +++ b/Makefile @@ -20,6 +20,14 @@ define package_template >Proxmox/Lib/$(1).pm endef +define upload_template + cd build; \ + dcmd --deb lib$(1)-rs-perl*.changes \ + | grep -v '.changes$$' \ + | tar -cf "$@.tar" -T-; \ + cat "$@.tar" | ssh -X repoman@repo.proxmox.com upload --product $(2) --dist bullseye +endef + .PHONY: all all: ifeq ($(BUILD_TARGET), pve) @@ -87,12 +95,12 @@ common-deb: build cd ./build/common-pkg && dpkg-buildpackage -b -uc -us touch $@ -%-upload: %-deb - cd build; \ - dcmd --deb lib$*-rs-perl*.changes \ - | grep -v '.changes$$' \ - | tar -cf "$@.tar" -T-; \ - cat "$@.tar" | ssh -X repoman@repo.proxmox.com upload --product $* --dist bullseye +pve-upload: pve-deb + $(call upload_template,pve,pve) +pmg-upload: pmg-deb + $(call upload_template,pmg,pmg) +common-upload: common-deb + $(call upload_template,proxmox,pve\,pmg) .PHONY: clean clean: From 8d143f8f9e77a117da8313ba471d9d7c28bcc138 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= Date: Thu, 30 Jun 2022 15:04:20 +0200 Subject: [PATCH 13/35] common: add proxmox_subscription wrapper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit and expose it for PVE and PMG. Signed-off-by: Fabian Grünbichler --- Makefile | 3 +- common/src/mod.rs | 1 + common/src/subscription.rs | 165 +++++++++++++++++++++++++++++++++++++ pmg-rs/Cargo.toml | 6 ++ pve-rs/Cargo.toml | 6 ++ 5 files changed, 180 insertions(+), 1 deletion(-) create mode 100644 common/src/subscription.rs diff --git a/Makefile b/Makefile index 0055abdb..0b4ffdc7 100644 --- a/Makefile +++ b/Makefile @@ -51,7 +51,8 @@ gen: $(call package_template,PVE,pve_rs) perl ./scripts/genpackage.pl Common \ Proxmox::RS::APT::Repositories \ - Proxmox::RS::CalendarEvent + Proxmox::RS::CalendarEvent \ + Proxmox::RS::Subscription perl ./scripts/genpackage.pl PVE \ PVE::RS::APT::Repositories \ PVE::RS::OpenId \ diff --git a/common/src/mod.rs b/common/src/mod.rs index 738657ea..b8b843e7 100644 --- a/common/src/mod.rs +++ b/common/src/mod.rs @@ -1,2 +1,3 @@ pub mod apt; mod calendar_event; +mod subscription; diff --git a/common/src/subscription.rs b/common/src/subscription.rs new file mode 100644 index 00000000..7d93cc00 --- /dev/null +++ b/common/src/subscription.rs @@ -0,0 +1,165 @@ +mod client { + use anyhow::{format_err, Error}; + use http::Response; + + pub(crate) struct UreqClient { + pub user_agent: String, + pub proxy: Option, + } + + impl UreqClient { + fn agent(&self) -> Result { + let mut builder = ureq::AgentBuilder::new(); + if let Some(proxy) = &self.proxy { + builder = builder.proxy(ureq::Proxy::new(proxy)?); + } + + Ok(builder.build()) + } + + fn exec_request( + &self, + req: ureq::Request, + body: Option<&str>, + ) -> Result, Error> { + let req = req.set("User-Agent", &self.user_agent); + let res = match body { + Some(body) => req.send_string(body), + None => req.call(), + }?; + + let mut builder = http::response::Builder::new() + .status(http::status::StatusCode::from_u16(res.status())?); + + for header in res.headers_names() { + if let Some(value) = res.header(&header) { + builder = builder.header(header, value); + } + } + builder + .body(res.into_string()?) + .map_err(|err| format_err!("Failed to convert HTTP response - {err}")) + } + } + + impl proxmox_http::HttpClient for UreqClient { + fn get(&self, uri: &str) -> Result, Error> { + let req = self.agent()?.get(uri); + + self.exec_request(req, None) + } + + fn post( + &self, + uri: &str, + body: Option<&str>, + content_type: Option<&str>, + ) -> Result, Error> { + let mut req = self.agent()?.post(uri); + if let Some(content_type) = content_type { + req = req.set("Content-Type", content_type); + } + + self.exec_request(req, body) + } + } +} + +#[perlmod::package(name = "Proxmox::RS::Subscription")] +mod export { + use anyhow::{bail, format_err, Error}; + + use proxmox_subscription::SubscriptionInfo; + use proxmox_sys::fs::{file_get_contents, CreateOptions}; + + use super::client::UreqClient; + + #[export] + fn read_subscription(path: String) -> Result, Error> { + let key = file_get_contents("/usr/share/keyrings/proxmox-offline-signing-key.pub")?; + let key = openssl::pkey::PKey::public_key_from_pem(&key) + .map_err(|err| format_err!("Failed to parse public key - {err}"))?; + + proxmox_subscription::files::read_subscription(path, &key) + } + + #[export] + fn write_subscription( + path: String, + apt_path: String, + url: &str, + info: SubscriptionInfo, + ) -> Result<(), Error> { + let mode = nix::sys::stat::Mode::from_bits_truncate(0o0640); + let www_data = nix::unistd::Group::from_name("www-data")? + .ok_or(format_err!("no 'www-data' group found!"))? + .gid; + let opts = CreateOptions::new() + .perm(mode) + .owner(nix::unistd::ROOT) + .group(www_data); + + let mode = nix::sys::stat::Mode::from_bits_truncate(0o0600); + let apt_opts = CreateOptions::new().perm(mode).owner(nix::unistd::ROOT); + + proxmox_subscription::files::write_subscription(path, opts, &info).and_then(|_| { + proxmox_subscription::files::update_apt_auth( + apt_path, + apt_opts, + url, + info.key, + info.serverid, + ) + }) + } + + #[export] + fn delete_subscription(path: String, apt_path: String, url: &str) -> Result<(), Error> { + let mode = nix::sys::stat::Mode::from_bits_truncate(0o0600); + let apt_opts = CreateOptions::new().perm(mode).owner(nix::unistd::ROOT); + + proxmox_subscription::files::delete_subscription(path).and_then(|_| { + proxmox_subscription::files::update_apt_auth(apt_path, apt_opts, url, None, None) + }) + } + + #[export] + fn check_subscription( + key: String, + server_id: String, + product_url: String, + user_agent: String, + proxy: Option, + ) -> Result { + let client = UreqClient { user_agent, proxy }; + + proxmox_subscription::check::check_subscription(key, server_id, product_url, client) + } + + #[export] + fn check_server_id(mut info: SubscriptionInfo) -> SubscriptionInfo { + info.check_server_id(); + info + } + + #[export] + fn check_age(mut info: SubscriptionInfo, re_check: bool) -> SubscriptionInfo { + info.check_age(re_check); + info + } + + #[export] + fn check_signature(mut info: SubscriptionInfo) -> Result { + if !info.is_signed() { + bail!("SubscriptionInfo is not signed!"); + } + + let key = file_get_contents("/usr/share/keyrings/proxmox-offline-signing-key.pub")?; + let key = openssl::pkey::PKey::public_key_from_pem(&key) + .map_err(|err| format_err!("Failed to parse public key - {err}"))?; + + info.check_signature(&key); + + Ok(info) + } +} diff --git a/pmg-rs/Cargo.toml b/pmg-rs/Cargo.toml index 8d9a9bcf..7b6f706b 100644 --- a/pmg-rs/Cargo.toml +++ b/pmg-rs/Cargo.toml @@ -21,16 +21,22 @@ crate-type = [ "cdylib" ] [dependencies] anyhow = "1.0" hex = "0.4" +http = "0.2.7" libc = "0.2" nix = "0.24" +openssl = "0.10.40" serde = "1.0" serde_bytes = "0.11.3" serde_json = "1.0" +ureq = { version = "2.4", features = ["native-certs"] } url = "2" perlmod = { version = "0.13", features = [ "exporter" ] } proxmox-acme-rs = { version = "0.4", features = ["client"] } proxmox-apt = "0.8.0" +proxmox-http = { version = "0.6.3", features = ["client-trait"] } +proxmox-subscription = "0.1" +proxmox-sys = "0.3" proxmox-tfa = { version = "2", features = ["api"] } proxmox-time = "1.1.3" diff --git a/pve-rs/Cargo.toml b/pve-rs/Cargo.toml index 87644053..3f82de6c 100644 --- a/pve-rs/Cargo.toml +++ b/pve-rs/Cargo.toml @@ -19,16 +19,22 @@ anyhow = "1.0" base32 = "0.4" base64 = "0.13" hex = "0.4" +http = "0.2.7" libc = "0.2" nix = "0.24" +openssl = "0.10.40" serde = "1.0" serde_bytes = "0.11" serde_json = "1.0" +ureq = { version = "2.4", features = ["native-certs"] } url = "2" perlmod = { version = "0.13", features = [ "exporter" ] } proxmox-apt = "0.8" +proxmox-http = { version = "0.6.3", features = ["client-trait"] } proxmox-openid = "0.9.5" +proxmox-subscription = "0.1" +proxmox-sys = "0.3" proxmox-tfa = { version = "2", features = ["api"] } proxmox-time = "1.1.3" From 03bba92a8bd8ac6dabaf86c2141ebd9030f41dd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= Date: Thu, 21 Jul 2022 12:52:37 +0200 Subject: [PATCH 14/35] adapt to proxmox-apt changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fabian Grünbichler --- common/src/apt/repositories.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/src/apt/repositories.rs b/common/src/apt/repositories.rs index 26a20e46..e1624872 100644 --- a/common/src/apt/repositories.rs +++ b/common/src/apt/repositories.rs @@ -104,7 +104,7 @@ pub mod export { ); } - if let Some(file) = files.iter_mut().find(|file| file.path == path) { + if let Some(file) = files.iter_mut().find(|file| file.path.as_ref() == Some(&path)) { file.repositories.push(repo); file.write()?; @@ -145,7 +145,7 @@ pub mod export { bail!("unable to parse file {} - {}", error.path, error.error); } - if let Some(file) = files.iter_mut().find(|file| file.path == path) { + if let Some(file) = files.iter_mut().find(|file| file.path.as_ref() == Some(&path.to_string())) { if let Some(repo) = file.repositories.get_mut(index) { if let Some(enabled) = options.enabled { repo.set_enabled(enabled); From 95e5e59fd0a10f0d1d1fa0f56eb7a6b47da2ccaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= Date: Thu, 21 Jul 2022 13:33:37 +0200 Subject: [PATCH 15/35] cargo fmt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fabian Grünbichler --- common/src/apt/repositories.rs | 10 ++++++++-- pve-rs/src/openid/mod.rs | 11 ++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/common/src/apt/repositories.rs b/common/src/apt/repositories.rs index e1624872..e710819c 100644 --- a/common/src/apt/repositories.rs +++ b/common/src/apt/repositories.rs @@ -104,7 +104,10 @@ pub mod export { ); } - if let Some(file) = files.iter_mut().find(|file| file.path.as_ref() == Some(&path)) { + if let Some(file) = files + .iter_mut() + .find(|file| file.path.as_ref() == Some(&path)) + { file.repositories.push(repo); file.write()?; @@ -145,7 +148,10 @@ pub mod export { bail!("unable to parse file {} - {}", error.path, error.error); } - if let Some(file) = files.iter_mut().find(|file| file.path.as_ref() == Some(&path.to_string())) { + if let Some(file) = files + .iter_mut() + .find(|file| file.path.as_ref() == Some(&path.to_string())) + { if let Some(repo) = file.repositories.get_mut(index) { if let Some(enabled) = options.enabled { repo.set_enabled(enabled); diff --git a/pve-rs/src/openid/mod.rs b/pve-rs/src/openid/mod.rs index aa31f9c3..8572221f 100644 --- a/pve-rs/src/openid/mod.rs +++ b/pve-rs/src/openid/mod.rs @@ -1,13 +1,13 @@ #[perlmod::package(name = "PVE::RS::OpenId", lib = "pve_rs")] mod export { - use std::sync::Mutex; use std::convert::TryFrom; + use std::sync::Mutex; use anyhow::Error; use perlmod::{to_value, Value}; - use proxmox_openid::{OpenIdConfig, OpenIdAuthenticator, PrivateAuthState}; + use proxmox_openid::{OpenIdAuthenticator, OpenIdConfig, PrivateAuthState}; const CLASSNAME: &str = "PVE::RS::OpenId"; @@ -44,7 +44,6 @@ mod export { config: OpenIdConfig, redirect_url: &str, ) -> Result { - let open_id = OpenIdAuthenticator::discover(&config, redirect_url)?; bless( class, @@ -60,7 +59,6 @@ mod export { state_dir: &str, realm: &str, ) -> Result { - let open_id = this.inner.lock().unwrap(); open_id.authorize_url(state_dir, realm) } @@ -69,17 +67,16 @@ mod export { pub fn verify_public_auth_state( state_dir: &str, state: &str, - ) -> Result<(String, PrivateAuthState), Error> { + ) -> Result<(String, PrivateAuthState), Error> { OpenIdAuthenticator::verify_public_auth_state(state_dir, state) } #[export(raw_return)] pub fn verify_authorization_code( - #[try_from_ref] this: &OpenId, + #[try_from_ref] this: &OpenId, code: &str, private_auth_state: PrivateAuthState, ) -> Result { - let open_id = this.inner.lock().unwrap(); let claims = open_id.verify_authorization_code_simple(code, &private_auth_state)?; From 31a1c78845a58f4b33da1ea785aa6693fd909d6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= Date: Thu, 21 Jul 2022 13:33:47 +0200 Subject: [PATCH 16/35] common: adapt to changes in proxmox_subscription MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fabian Grünbichler --- common/src/subscription.rs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/common/src/subscription.rs b/common/src/subscription.rs index 7d93cc00..8711d512 100644 --- a/common/src/subscription.rs +++ b/common/src/subscription.rs @@ -70,17 +70,16 @@ mod export { use anyhow::{bail, format_err, Error}; use proxmox_subscription::SubscriptionInfo; - use proxmox_sys::fs::{file_get_contents, CreateOptions}; + use proxmox_sys::fs::CreateOptions; use super::client::UreqClient; #[export] fn read_subscription(path: String) -> Result, Error> { - let key = file_get_contents("/usr/share/keyrings/proxmox-offline-signing-key.pub")?; - let key = openssl::pkey::PKey::public_key_from_pem(&key) - .map_err(|err| format_err!("Failed to parse public key - {err}"))?; - - proxmox_subscription::files::read_subscription(path, &key) + proxmox_subscription::files::read_subscription( + path.as_str(), + &[proxmox_subscription::files::DEFAULT_SIGNING_KEY], + ) } #[export] @@ -154,11 +153,7 @@ mod export { bail!("SubscriptionInfo is not signed!"); } - let key = file_get_contents("/usr/share/keyrings/proxmox-offline-signing-key.pub")?; - let key = openssl::pkey::PKey::public_key_from_pem(&key) - .map_err(|err| format_err!("Failed to parse public key - {err}"))?; - - info.check_signature(&key); + info.check_signature(&[proxmox_subscription::files::DEFAULT_SIGNING_KEY]); Ok(info) } From 818886ee45ad7bddc14c8edfe47c461e462ea569 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Thu, 21 Jul 2022 14:54:45 +0200 Subject: [PATCH 17/35] bump proxmox-apt to 0.9 and proxmox-subscription to 0.2 Signed-off-by: Wolfgang Bumiller --- pmg-rs/Cargo.toml | 4 ++-- pve-rs/Cargo.toml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pmg-rs/Cargo.toml b/pmg-rs/Cargo.toml index 7b6f706b..47b498a2 100644 --- a/pmg-rs/Cargo.toml +++ b/pmg-rs/Cargo.toml @@ -34,9 +34,9 @@ url = "2" perlmod = { version = "0.13", features = [ "exporter" ] } proxmox-acme-rs = { version = "0.4", features = ["client"] } -proxmox-apt = "0.8.0" +proxmox-apt = "0.9" proxmox-http = { version = "0.6.3", features = ["client-trait"] } -proxmox-subscription = "0.1" +proxmox-subscription = "0.2" proxmox-sys = "0.3" proxmox-tfa = { version = "2", features = ["api"] } proxmox-time = "1.1.3" diff --git a/pve-rs/Cargo.toml b/pve-rs/Cargo.toml index 3f82de6c..9e6ffdf1 100644 --- a/pve-rs/Cargo.toml +++ b/pve-rs/Cargo.toml @@ -31,10 +31,10 @@ url = "2" perlmod = { version = "0.13", features = [ "exporter" ] } -proxmox-apt = "0.8" +proxmox-apt = "0.9" proxmox-http = { version = "0.6.3", features = ["client-trait"] } proxmox-openid = "0.9.5" -proxmox-subscription = "0.1" +proxmox-subscription = "0.2" proxmox-sys = "0.3" proxmox-tfa = { version = "2", features = ["api"] } proxmox-time = "1.1.3" From 719c66bf04e4ae774e0e9ece0c961e7c12b372be Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Thu, 21 Jul 2022 14:58:35 +0200 Subject: [PATCH 18/35] bump proxmox-http to 0.6.4 Signed-off-by: Wolfgang Bumiller --- pmg-rs/Cargo.toml | 2 +- pve-rs/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pmg-rs/Cargo.toml b/pmg-rs/Cargo.toml index 47b498a2..bc77b446 100644 --- a/pmg-rs/Cargo.toml +++ b/pmg-rs/Cargo.toml @@ -35,7 +35,7 @@ perlmod = { version = "0.13", features = [ "exporter" ] } proxmox-acme-rs = { version = "0.4", features = ["client"] } proxmox-apt = "0.9" -proxmox-http = { version = "0.6.3", features = ["client-trait"] } +proxmox-http = { version = "0.6.4", features = ["client-trait"] } proxmox-subscription = "0.2" proxmox-sys = "0.3" proxmox-tfa = { version = "2", features = ["api"] } diff --git a/pve-rs/Cargo.toml b/pve-rs/Cargo.toml index 9e6ffdf1..1d2eab85 100644 --- a/pve-rs/Cargo.toml +++ b/pve-rs/Cargo.toml @@ -32,7 +32,7 @@ url = "2" perlmod = { version = "0.13", features = [ "exporter" ] } proxmox-apt = "0.9" -proxmox-http = { version = "0.6.3", features = ["client-trait"] } +proxmox-http = { version = "0.6.4", features = ["client-trait"] } proxmox-openid = "0.9.5" proxmox-subscription = "0.2" proxmox-sys = "0.3" From 73b295e8c2fc63bf1bcfc6cb4e8440c18a20cce6 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Thu, 21 Jul 2022 14:55:30 +0200 Subject: [PATCH 19/35] pve: bump d/control Signed-off-by: Wolfgang Bumiller --- pve-rs/debian/control | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pve-rs/debian/control b/pve-rs/debian/control index 6f34e3e2..441ffef8 100644 --- a/pve-rs/debian/control +++ b/pve-rs/debian/control @@ -11,18 +11,26 @@ Build-Depends: librust-base32-0.4+default-dev, librust-base64-0.13+default-dev, librust-hex-0.4+default-dev, + librust-http-0.2+default-dev (>= 0.2.7-~~), librust-libc-0.2+default-dev, librust-nix-0.24+default-dev, + librust-openssl-0.10+default-dev (>= 0.10.40-~~), librust-perlmod-0.13+default-dev, librust-perlmod-0.13+exporter-dev, - librust-proxmox-apt-0.8+default-dev, + librust-proxmox-apt-0.9+default-dev, + librust-proxmox-http-0.6+client-trait-dev (>= 0.6.4-~~), + librust-proxmox-http-0.6+default-dev (>= 0.6.4-~~), librust-proxmox-openid-0.9+default-dev (>= 0.9.5-~~), + librust-proxmox-subscription-0.2+default-dev, + librust-proxmox-sys-0.3+default-dev, librust-proxmox-tfa-2+api-dev, librust-proxmox-tfa-2+default-dev, librust-proxmox-time-1+default-dev (>= 1.1.3-~~), librust-serde-1+default-dev, librust-serde-bytes-0.11+default-dev, librust-serde-json-1+default-dev, + librust-ureq-2+default-dev (>= 2.4-~~), + librust-ureq-2+native-certs-dev (>= 2.4-~~), librust-url-2+default-dev, Maintainer: Proxmox Support Team Standards-Version: 4.5.1 From 54d694bbaf899a52f12231ab5afa2654b9fc69bd Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Thu, 21 Jul 2022 14:55:53 +0200 Subject: [PATCH 20/35] pmg: bump d/control Signed-off-by: Wolfgang Bumiller --- pmg-rs/debian/control | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pmg-rs/debian/control b/pmg-rs/debian/control index d089af28..589c6bef 100644 --- a/pmg-rs/debian/control +++ b/pmg-rs/debian/control @@ -10,19 +10,27 @@ Build-Depends: libstd-rust-dev , librust-anyhow-1+default-dev, librust-hex-0.4+default-dev, + librust-http-0.2+default-dev (>= 0.2.7-~~), librust-libc-0.2+default-dev, librust-nix-0.24+default-dev, + librust-openssl-0.10+default-dev (>= 0.10.40-~~), librust-perlmod-0.13+default-dev, librust-perlmod-0.13+exporter-dev, librust-proxmox-acme-rs-0.4+client-dev, librust-proxmox-acme-rs-0.4+default-dev, - librust-proxmox-apt-0.8+default-dev, + librust-proxmox-apt-0.9+default-dev, + librust-proxmox-http-0.6+client-trait-dev (>= 0.6.4-~~), + librust-proxmox-http-0.6+default-dev (>= 0.6.4-~~), + librust-proxmox-subscription-0.2+default-dev, + librust-proxmox-sys-0.3+default-dev, librust-proxmox-tfa-2+api-dev, librust-proxmox-tfa-2+default-dev, librust-proxmox-time-1+default-dev (>= 1.1.3-~~), librust-serde-1+default-dev, librust-serde-bytes-0.11+default-dev (>= 0.11.3-~~), librust-serde-json-1+default-dev, + librust-ureq-2+default-dev (>= 2.4-~~), + librust-ureq-2+native-certs-dev (>= 2.4-~~), librust-url-2+default-dev, Standards-Version: 4.3.0 Homepage: https://www.proxmox.com From d60b0a3ca3831e8db0e1e04476e8a65d76bcfff8 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Thu, 21 Jul 2022 14:58:48 +0200 Subject: [PATCH 21/35] bump pve-rs to 0.7.0 Signed-off-by: Wolfgang Bumiller --- pve-rs/Cargo.toml | 2 +- pve-rs/debian/changelog | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/pve-rs/Cargo.toml b/pve-rs/Cargo.toml index 1d2eab85..b7e99483 100644 --- a/pve-rs/Cargo.toml +++ b/pve-rs/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pve-rs" -version = "0.6.2" +version = "0.7.0" authors = ["Proxmox Support Team "] edition = "2018" license = "AGPL-3" diff --git a/pve-rs/debian/changelog b/pve-rs/debian/changelog index 40b94bbb..e8d88160 100644 --- a/pve-rs/debian/changelog +++ b/pve-rs/debian/changelog @@ -1,3 +1,13 @@ +libpve-rs-perl (0.7.0) bullseye; urgency=medium + + * add Proxmox::RS::Subscription support + + * bump proxmox-http to 0.6.4 to fix an issue with proxy authorization + + * adapt to changes in proxmox-apt + + -- Proxmox Support Team Thu, 21 Jul 2022 14:56:12 +0200 + libpve-rs-perl (0.6.2) bullseye; urgency=medium * add common apt module From 9c11a1bea649105024dd5f2deccbdbd8854dbdcc Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Thu, 21 Jul 2022 14:58:59 +0200 Subject: [PATCH 22/35] bump pmg-rs to 0.6.0 Signed-off-by: Wolfgang Bumiller --- pmg-rs/Cargo.toml | 2 +- pmg-rs/debian/changelog | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/pmg-rs/Cargo.toml b/pmg-rs/Cargo.toml index bc77b446..c501eee2 100644 --- a/pmg-rs/Cargo.toml +++ b/pmg-rs/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pmg-rs" -version = "0.5.2" +version = "0.6.0" authors = [ "Proxmox Support Team ", "Wolfgang Bumiller ", diff --git a/pmg-rs/debian/changelog b/pmg-rs/debian/changelog index fd572aa9..599614db 100644 --- a/pmg-rs/debian/changelog +++ b/pmg-rs/debian/changelog @@ -1,3 +1,11 @@ +libpmg-rs-perl (0.6.0) bullseye; urgency=medium + + * add Proxmox::RS::Subscription support + + * bump proxmox-http to 0.6.4 to fix an issue with proxy authorization + + -- Proxmox Support Team Thu, 21 Jul 2022 14:57:21 +0200 + libpmg-rs-perl (0.5.2) bullseye; urgency=medium * add common apt module From 75796e3275ba1a10308b5cf8f995bf82aa3c4acd Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Thu, 21 Jul 2022 15:01:20 +0200 Subject: [PATCH 23/35] common: depend on next pve-rs/pmg-rs bump Signed-off-by: Wolfgang Bumiller --- common/pkg/debian/control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/pkg/debian/control b/common/pkg/debian/control index 4669118d..adc10c27 100644 --- a/common/pkg/debian/control +++ b/common/pkg/debian/control @@ -16,7 +16,7 @@ Depends: ${misc:Depends}, ${perl:Depends}, ${shlibs:Depends}, - libpve-rs-perl (>= 0.6.2) | libpmg-rs-perl (>= 0.5.1), + libpve-rs-perl (>= 0.7.0) | libpmg-rs-perl (>= 0.6.0), Breaks: libpve-rs-perl (<< 0.6.0) Replaces: libpve-rs-perl (<< 0.6.0) Description: PVE/PMG common parts which have been ported to Rust - Perl packages From 301bfb5b9a697d0e28c5d963f149ac07277126e8 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Thu, 21 Jul 2022 15:01:47 +0200 Subject: [PATCH 24/35] bump common to 0.2.0 Signed-off-by: Wolfgang Bumiller --- common/pkg/debian/changelog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/common/pkg/debian/changelog b/common/pkg/debian/changelog index 95941f6f..535b45f4 100644 --- a/common/pkg/debian/changelog +++ b/common/pkg/debian/changelog @@ -1,3 +1,9 @@ +libproxmox-rs-perl (0.2.0) bullseye; urgency=medium + + * add Proxmox::RS::Subscription + + -- Proxmox Support Team Thu, 21 Jul 2022 15:01:29 +0200 + libproxmox-rs-perl (0.1.2) bullseye; urgency=medium * add common apt module From f337b67f4c2cea132e45e6781d456a0912e4487f Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Mon, 25 Jul 2022 11:43:40 +0200 Subject: [PATCH 25/35] buildsys: fix common upload target interpretation FWICT there's no way to escape the comma directly, so use a intermediate variable to pass the correct value to the call Signed-off-by: Thomas Lamprecht --- Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 0b4ffdc7..0836c9d1 100644 --- a/Makefile +++ b/Makefile @@ -100,8 +100,11 @@ pve-upload: pve-deb $(call upload_template,pve,pve) pmg-upload: pmg-deb $(call upload_template,pmg,pmg) + +# need to put into variable to ensure comma isn't interpreted as param separator on call +common_target=pve,pmg common-upload: common-deb - $(call upload_template,proxmox,pve\,pmg) + $(call upload_template,proxmox,$(common_target)) .PHONY: clean clean: From ed3bbe6425234c5fb6ddf712353687a029062921 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Mon, 25 Jul 2022 13:43:54 +0200 Subject: [PATCH 26/35] bump proxmox-tfa to 2.1 Signed-off-by: Wolfgang Bumiller --- pmg-rs/Cargo.toml | 2 +- pmg-rs/debian/control | 4 ++-- pve-rs/Cargo.toml | 2 +- pve-rs/debian/control | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pmg-rs/Cargo.toml b/pmg-rs/Cargo.toml index c501eee2..3eae5734 100644 --- a/pmg-rs/Cargo.toml +++ b/pmg-rs/Cargo.toml @@ -38,5 +38,5 @@ proxmox-apt = "0.9" proxmox-http = { version = "0.6.4", features = ["client-trait"] } proxmox-subscription = "0.2" proxmox-sys = "0.3" -proxmox-tfa = { version = "2", features = ["api"] } +proxmox-tfa = { version = "2.1", features = ["api"] } proxmox-time = "1.1.3" diff --git a/pmg-rs/debian/control b/pmg-rs/debian/control index 589c6bef..66f58eb9 100644 --- a/pmg-rs/debian/control +++ b/pmg-rs/debian/control @@ -23,8 +23,8 @@ Build-Depends: librust-proxmox-http-0.6+default-dev (>= 0.6.4-~~), librust-proxmox-subscription-0.2+default-dev, librust-proxmox-sys-0.3+default-dev, - librust-proxmox-tfa-2+api-dev, - librust-proxmox-tfa-2+default-dev, + librust-proxmox-tfa-2+api-dev (>= 2.1-~~), + librust-proxmox-tfa-2+default-dev (>= 2.1-~~), librust-proxmox-time-1+default-dev (>= 1.1.3-~~), librust-serde-1+default-dev, librust-serde-bytes-0.11+default-dev (>= 0.11.3-~~), diff --git a/pve-rs/Cargo.toml b/pve-rs/Cargo.toml index b7e99483..3f0849a0 100644 --- a/pve-rs/Cargo.toml +++ b/pve-rs/Cargo.toml @@ -36,5 +36,5 @@ proxmox-http = { version = "0.6.4", features = ["client-trait"] } proxmox-openid = "0.9.5" proxmox-subscription = "0.2" proxmox-sys = "0.3" -proxmox-tfa = { version = "2", features = ["api"] } +proxmox-tfa = { version = "2.1", features = ["api"] } proxmox-time = "1.1.3" diff --git a/pve-rs/debian/control b/pve-rs/debian/control index 441ffef8..82520aa7 100644 --- a/pve-rs/debian/control +++ b/pve-rs/debian/control @@ -23,8 +23,8 @@ Build-Depends: librust-proxmox-openid-0.9+default-dev (>= 0.9.5-~~), librust-proxmox-subscription-0.2+default-dev, librust-proxmox-sys-0.3+default-dev, - librust-proxmox-tfa-2+api-dev, - librust-proxmox-tfa-2+default-dev, + librust-proxmox-tfa-2+api-dev (>= 2.1-~~), + librust-proxmox-tfa-2+default-dev (>= 2.1-~~), librust-proxmox-time-1+default-dev (>= 1.1.3-~~), librust-serde-1+default-dev, librust-serde-bytes-0.11+default-dev, From c978d1384b8a1c917f16199c9a058575a55f009f Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Mon, 25 Jul 2022 13:46:10 +0200 Subject: [PATCH 27/35] bump pve-rs to 0.7.1 Signed-off-by: Wolfgang Bumiller --- pve-rs/Cargo.toml | 2 +- pve-rs/debian/changelog | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/pve-rs/Cargo.toml b/pve-rs/Cargo.toml index 3f0849a0..e1524c3b 100644 --- a/pve-rs/Cargo.toml +++ b/pve-rs/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pve-rs" -version = "0.7.0" +version = "0.7.1" authors = ["Proxmox Support Team "] edition = "2018" license = "AGPL-3" diff --git a/pve-rs/debian/changelog b/pve-rs/debian/changelog index e8d88160..5bcf6249 100644 --- a/pve-rs/debian/changelog +++ b/pve-rs/debian/changelog @@ -1,3 +1,9 @@ +libpve-rs-perl (0.7.1) bullseye; urgency=medium + + * add 'allow-subdomains' property to webauthn config + + -- Proxmox Support Team Mon, 25 Jul 2022 13:45:11 +0200 + libpve-rs-perl (0.7.0) bullseye; urgency=medium * add Proxmox::RS::Subscription support From 4cc6259a60d635a08ffd40450703d05c0483a83f Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Mon, 25 Jul 2022 13:46:35 +0200 Subject: [PATCH 28/35] bump pmg-rs to 0.6.1 Signed-off-by: Wolfgang Bumiller --- pmg-rs/Cargo.toml | 2 +- pmg-rs/debian/changelog | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/pmg-rs/Cargo.toml b/pmg-rs/Cargo.toml index 3eae5734..c99ed628 100644 --- a/pmg-rs/Cargo.toml +++ b/pmg-rs/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pmg-rs" -version = "0.6.0" +version = "0.6.1" authors = [ "Proxmox Support Team ", "Wolfgang Bumiller ", diff --git a/pmg-rs/debian/changelog b/pmg-rs/debian/changelog index 599614db..06289ce7 100644 --- a/pmg-rs/debian/changelog +++ b/pmg-rs/debian/changelog @@ -1,3 +1,9 @@ +libpmg-rs-perl (0.6.1) bullseye; urgency=medium + + * add 'allow-subdomains' property to webauthn config + + -- Proxmox Support Team Mon, 25 Jul 2022 13:45:39 +0200 + libpmg-rs-perl (0.6.0) bullseye; urgency=medium * add Proxmox::RS::Subscription support From 39c29ee9a4b4fbedd31732b7fcb92551f2bf5627 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= Date: Tue, 2 Aug 2022 14:42:50 +0200 Subject: [PATCH 29/35] bump proxmox-sys dependency to 0.4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fabian Grünbichler --- pmg-rs/Cargo.toml | 2 +- pmg-rs/debian/control | 2 +- pve-rs/Cargo.toml | 2 +- pve-rs/debian/control | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pmg-rs/Cargo.toml b/pmg-rs/Cargo.toml index c99ed628..4dfa813c 100644 --- a/pmg-rs/Cargo.toml +++ b/pmg-rs/Cargo.toml @@ -37,6 +37,6 @@ proxmox-acme-rs = { version = "0.4", features = ["client"] } proxmox-apt = "0.9" proxmox-http = { version = "0.6.4", features = ["client-trait"] } proxmox-subscription = "0.2" -proxmox-sys = "0.3" +proxmox-sys = "0.4" proxmox-tfa = { version = "2.1", features = ["api"] } proxmox-time = "1.1.3" diff --git a/pmg-rs/debian/control b/pmg-rs/debian/control index 66f58eb9..aebf869a 100644 --- a/pmg-rs/debian/control +++ b/pmg-rs/debian/control @@ -22,7 +22,7 @@ Build-Depends: librust-proxmox-http-0.6+client-trait-dev (>= 0.6.4-~~), librust-proxmox-http-0.6+default-dev (>= 0.6.4-~~), librust-proxmox-subscription-0.2+default-dev, - librust-proxmox-sys-0.3+default-dev, + librust-proxmox-sys-0.4+default-dev, librust-proxmox-tfa-2+api-dev (>= 2.1-~~), librust-proxmox-tfa-2+default-dev (>= 2.1-~~), librust-proxmox-time-1+default-dev (>= 1.1.3-~~), diff --git a/pve-rs/Cargo.toml b/pve-rs/Cargo.toml index e1524c3b..4b45413e 100644 --- a/pve-rs/Cargo.toml +++ b/pve-rs/Cargo.toml @@ -35,6 +35,6 @@ proxmox-apt = "0.9" proxmox-http = { version = "0.6.4", features = ["client-trait"] } proxmox-openid = "0.9.5" proxmox-subscription = "0.2" -proxmox-sys = "0.3" +proxmox-sys = "0.4" proxmox-tfa = { version = "2.1", features = ["api"] } proxmox-time = "1.1.3" diff --git a/pve-rs/debian/control b/pve-rs/debian/control index 82520aa7..ee8d141c 100644 --- a/pve-rs/debian/control +++ b/pve-rs/debian/control @@ -22,7 +22,7 @@ Build-Depends: librust-proxmox-http-0.6+default-dev (>= 0.6.4-~~), librust-proxmox-openid-0.9+default-dev (>= 0.9.5-~~), librust-proxmox-subscription-0.2+default-dev, - librust-proxmox-sys-0.3+default-dev, + librust-proxmox-sys-0.4+default-dev, librust-proxmox-tfa-2+api-dev (>= 2.1-~~), librust-proxmox-tfa-2+default-dev (>= 2.1-~~), librust-proxmox-time-1+default-dev (>= 1.1.3-~~), From db85dc1b7a6f510a62663583d13cb6701bad9dbe Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Wed, 17 Aug 2022 13:13:47 +0200 Subject: [PATCH 30/35] common: add versioned Breaks Signed-off-by: Wolfgang Bumiller --- common/pkg/debian/control | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/common/pkg/debian/control b/common/pkg/debian/control index adc10c27..4c7ee669 100644 --- a/common/pkg/debian/control +++ b/common/pkg/debian/control @@ -12,12 +12,16 @@ Rules-Requires-Root: no Package: libproxmox-rs-perl Architecture: any +# always bump both versioned Depends and Breaks, otherwise systems with both +# libpmg-rs-perl and libpve-rs-perl might load an outdated lib and break Depends: ${misc:Depends}, ${perl:Depends}, ${shlibs:Depends}, libpve-rs-perl (>= 0.7.0) | libpmg-rs-perl (>= 0.6.0), -Breaks: libpve-rs-perl (<< 0.6.0) +Breaks: + libpve-rs-perl (<< 0.7.0), + libpmg-rs-perl (<< 0.6.0), Replaces: libpve-rs-perl (<< 0.6.0) Description: PVE/PMG common parts which have been ported to Rust - Perl packages Contains the perl side of modules provided by the libraries of both libpve-rs-perl and From 95b9307776feb48d4bdbbfd60138121d8a854ecd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= Date: Thu, 4 Aug 2022 10:31:37 +0200 Subject: [PATCH 31/35] update to proxmox-http 0.7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fabian Grünbichler --- common/src/subscription.rs | 78 +++++--------------------------------- pmg-rs/Cargo.toml | 3 +- pmg-rs/debian/control | 7 ++-- pve-rs/Cargo.toml | 3 +- pve-rs/debian/control | 7 ++-- 5 files changed, 17 insertions(+), 81 deletions(-) diff --git a/common/src/subscription.rs b/common/src/subscription.rs index 8711d512..d4c72273 100644 --- a/common/src/subscription.rs +++ b/common/src/subscription.rs @@ -1,70 +1,3 @@ -mod client { - use anyhow::{format_err, Error}; - use http::Response; - - pub(crate) struct UreqClient { - pub user_agent: String, - pub proxy: Option, - } - - impl UreqClient { - fn agent(&self) -> Result { - let mut builder = ureq::AgentBuilder::new(); - if let Some(proxy) = &self.proxy { - builder = builder.proxy(ureq::Proxy::new(proxy)?); - } - - Ok(builder.build()) - } - - fn exec_request( - &self, - req: ureq::Request, - body: Option<&str>, - ) -> Result, Error> { - let req = req.set("User-Agent", &self.user_agent); - let res = match body { - Some(body) => req.send_string(body), - None => req.call(), - }?; - - let mut builder = http::response::Builder::new() - .status(http::status::StatusCode::from_u16(res.status())?); - - for header in res.headers_names() { - if let Some(value) = res.header(&header) { - builder = builder.header(header, value); - } - } - builder - .body(res.into_string()?) - .map_err(|err| format_err!("Failed to convert HTTP response - {err}")) - } - } - - impl proxmox_http::HttpClient for UreqClient { - fn get(&self, uri: &str) -> Result, Error> { - let req = self.agent()?.get(uri); - - self.exec_request(req, None) - } - - fn post( - &self, - uri: &str, - body: Option<&str>, - content_type: Option<&str>, - ) -> Result, Error> { - let mut req = self.agent()?.post(uri); - if let Some(content_type) = content_type { - req = req.set("Content-Type", content_type); - } - - self.exec_request(req, body) - } - } -} - #[perlmod::package(name = "Proxmox::RS::Subscription")] mod export { use anyhow::{bail, format_err, Error}; @@ -72,7 +5,9 @@ mod export { use proxmox_subscription::SubscriptionInfo; use proxmox_sys::fs::CreateOptions; - use super::client::UreqClient; + use proxmox_http::ProxyConfig; + use proxmox_http::HttpOptions; + use proxmox_http::client::sync::Client; #[export] fn read_subscription(path: String) -> Result, Error> { @@ -130,7 +65,12 @@ mod export { user_agent: String, proxy: Option, ) -> Result { - let client = UreqClient { user_agent, proxy }; + let proxy_config = match proxy { + Some(url) => Some(ProxyConfig::parse_proxy_url(&url)?), + None => None, + }; + let options = HttpOptions { proxy_config, user_agent: Some(user_agent) , ..Default::default() }; + let client = Client::new(options); proxmox_subscription::check::check_subscription(key, server_id, product_url, client) } diff --git a/pmg-rs/Cargo.toml b/pmg-rs/Cargo.toml index 4dfa813c..2339aead 100644 --- a/pmg-rs/Cargo.toml +++ b/pmg-rs/Cargo.toml @@ -28,14 +28,13 @@ openssl = "0.10.40" serde = "1.0" serde_bytes = "0.11.3" serde_json = "1.0" -ureq = { version = "2.4", features = ["native-certs"] } url = "2" perlmod = { version = "0.13", features = [ "exporter" ] } proxmox-acme-rs = { version = "0.4", features = ["client"] } proxmox-apt = "0.9" -proxmox-http = { version = "0.6.4", features = ["client-trait"] } +proxmox-http = { version = "0.7", features = ["client-sync", "client-trait"] } proxmox-subscription = "0.2" proxmox-sys = "0.4" proxmox-tfa = { version = "2.1", features = ["api"] } diff --git a/pmg-rs/debian/control b/pmg-rs/debian/control index aebf869a..090c67bc 100644 --- a/pmg-rs/debian/control +++ b/pmg-rs/debian/control @@ -19,8 +19,9 @@ Build-Depends: librust-proxmox-acme-rs-0.4+client-dev, librust-proxmox-acme-rs-0.4+default-dev, librust-proxmox-apt-0.9+default-dev, - librust-proxmox-http-0.6+client-trait-dev (>= 0.6.4-~~), - librust-proxmox-http-0.6+default-dev (>= 0.6.4-~~), + librust-proxmox-http-0.7+client-sync-dev, + librust-proxmox-http-0.7+client-trait-dev, + librust-proxmox-http-0.7+default-dev, librust-proxmox-subscription-0.2+default-dev, librust-proxmox-sys-0.4+default-dev, librust-proxmox-tfa-2+api-dev (>= 2.1-~~), @@ -29,8 +30,6 @@ Build-Depends: librust-serde-1+default-dev, librust-serde-bytes-0.11+default-dev (>= 0.11.3-~~), librust-serde-json-1+default-dev, - librust-ureq-2+default-dev (>= 2.4-~~), - librust-ureq-2+native-certs-dev (>= 2.4-~~), librust-url-2+default-dev, Standards-Version: 4.3.0 Homepage: https://www.proxmox.com diff --git a/pve-rs/Cargo.toml b/pve-rs/Cargo.toml index 4b45413e..7598a64a 100644 --- a/pve-rs/Cargo.toml +++ b/pve-rs/Cargo.toml @@ -26,13 +26,12 @@ openssl = "0.10.40" serde = "1.0" serde_bytes = "0.11" serde_json = "1.0" -ureq = { version = "2.4", features = ["native-certs"] } url = "2" perlmod = { version = "0.13", features = [ "exporter" ] } proxmox-apt = "0.9" -proxmox-http = { version = "0.6.4", features = ["client-trait"] } +proxmox-http = { version = "0.7", features = ["client-sync", "client-trait"] } proxmox-openid = "0.9.5" proxmox-subscription = "0.2" proxmox-sys = "0.4" diff --git a/pve-rs/debian/control b/pve-rs/debian/control index ee8d141c..ac87ddf9 100644 --- a/pve-rs/debian/control +++ b/pve-rs/debian/control @@ -18,8 +18,9 @@ Build-Depends: librust-perlmod-0.13+default-dev, librust-perlmod-0.13+exporter-dev, librust-proxmox-apt-0.9+default-dev, - librust-proxmox-http-0.6+client-trait-dev (>= 0.6.4-~~), - librust-proxmox-http-0.6+default-dev (>= 0.6.4-~~), + librust-proxmox-http-0.7+client-sync-dev, + librust-proxmox-http-0.7+client-trait-dev, + librust-proxmox-http-0.7+default-dev, librust-proxmox-openid-0.9+default-dev (>= 0.9.5-~~), librust-proxmox-subscription-0.2+default-dev, librust-proxmox-sys-0.4+default-dev, @@ -29,8 +30,6 @@ Build-Depends: librust-serde-1+default-dev, librust-serde-bytes-0.11+default-dev, librust-serde-json-1+default-dev, - librust-ureq-2+default-dev (>= 2.4-~~), - librust-ureq-2+native-certs-dev (>= 2.4-~~), librust-url-2+default-dev, Maintainer: Proxmox Support Team Standards-Version: 4.5.1 From 156f3d7727d2cf2f9143af78d2f44e55fbea23d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= Date: Wed, 7 Sep 2022 10:06:10 +0200 Subject: [PATCH 32/35] update to proxmox-subscription 0.3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fabian Grünbichler --- pmg-rs/Cargo.toml | 2 +- pmg-rs/debian/control | 2 +- pve-rs/Cargo.toml | 2 +- pve-rs/debian/control | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pmg-rs/Cargo.toml b/pmg-rs/Cargo.toml index 2339aead..4051c13c 100644 --- a/pmg-rs/Cargo.toml +++ b/pmg-rs/Cargo.toml @@ -35,7 +35,7 @@ perlmod = { version = "0.13", features = [ "exporter" ] } proxmox-acme-rs = { version = "0.4", features = ["client"] } proxmox-apt = "0.9" proxmox-http = { version = "0.7", features = ["client-sync", "client-trait"] } -proxmox-subscription = "0.2" +proxmox-subscription = "0.3" proxmox-sys = "0.4" proxmox-tfa = { version = "2.1", features = ["api"] } proxmox-time = "1.1.3" diff --git a/pmg-rs/debian/control b/pmg-rs/debian/control index 090c67bc..5af088b0 100644 --- a/pmg-rs/debian/control +++ b/pmg-rs/debian/control @@ -22,7 +22,7 @@ Build-Depends: librust-proxmox-http-0.7+client-sync-dev, librust-proxmox-http-0.7+client-trait-dev, librust-proxmox-http-0.7+default-dev, - librust-proxmox-subscription-0.2+default-dev, + librust-proxmox-subscription-0.3+default-dev, librust-proxmox-sys-0.4+default-dev, librust-proxmox-tfa-2+api-dev (>= 2.1-~~), librust-proxmox-tfa-2+default-dev (>= 2.1-~~), diff --git a/pve-rs/Cargo.toml b/pve-rs/Cargo.toml index 7598a64a..63922cc1 100644 --- a/pve-rs/Cargo.toml +++ b/pve-rs/Cargo.toml @@ -33,7 +33,7 @@ perlmod = { version = "0.13", features = [ "exporter" ] } proxmox-apt = "0.9" proxmox-http = { version = "0.7", features = ["client-sync", "client-trait"] } proxmox-openid = "0.9.5" -proxmox-subscription = "0.2" +proxmox-subscription = "0.3" proxmox-sys = "0.4" proxmox-tfa = { version = "2.1", features = ["api"] } proxmox-time = "1.1.3" diff --git a/pve-rs/debian/control b/pve-rs/debian/control index ac87ddf9..a0c785bc 100644 --- a/pve-rs/debian/control +++ b/pve-rs/debian/control @@ -22,7 +22,7 @@ Build-Depends: librust-proxmox-http-0.7+client-trait-dev, librust-proxmox-http-0.7+default-dev, librust-proxmox-openid-0.9+default-dev (>= 0.9.5-~~), - librust-proxmox-subscription-0.2+default-dev, + librust-proxmox-subscription-0.3+default-dev, librust-proxmox-sys-0.4+default-dev, librust-proxmox-tfa-2+api-dev (>= 2.1-~~), librust-proxmox-tfa-2+default-dev (>= 2.1-~~), From 8e7330c47450b731f959b223015daf58ee65076b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= Date: Wed, 7 Sep 2022 12:05:37 +0200 Subject: [PATCH 33/35] common: bump to 0.2.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit and update versioned depends/breaks Signed-off-by: Fabian Grünbichler --- common/pkg/debian/changelog | 6 ++++++ common/pkg/debian/control | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/common/pkg/debian/changelog b/common/pkg/debian/changelog index 535b45f4..1593980b 100644 --- a/common/pkg/debian/changelog +++ b/common/pkg/debian/changelog @@ -1,3 +1,9 @@ +libproxmox-rs-perl (0.2.1) bullseye; urgency=medium + + * update to proxmox-subscription 0.3 / proxmox-http 0.7 + + -- Proxmox Support Team Wed, 7 Sep 2022 11:53:10 +0200 + libproxmox-rs-perl (0.2.0) bullseye; urgency=medium * add Proxmox::RS::Subscription diff --git a/common/pkg/debian/control b/common/pkg/debian/control index 4c7ee669..ff819c0d 100644 --- a/common/pkg/debian/control +++ b/common/pkg/debian/control @@ -18,10 +18,10 @@ Depends: ${misc:Depends}, ${perl:Depends}, ${shlibs:Depends}, - libpve-rs-perl (>= 0.7.0) | libpmg-rs-perl (>= 0.6.0), + libpve-rs-perl (>= 0.7.2) | libpmg-rs-perl (>= 0.6.2), Breaks: - libpve-rs-perl (<< 0.7.0), - libpmg-rs-perl (<< 0.6.0), + libpve-rs-perl (<< 0.7.2), + libpmg-rs-perl (<< 0.6.2), Replaces: libpve-rs-perl (<< 0.6.0) Description: PVE/PMG common parts which have been ported to Rust - Perl packages Contains the perl side of modules provided by the libraries of both libpve-rs-perl and From 8e9e5218659338b614706a92d1c51a1a190e3d96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= Date: Wed, 7 Sep 2022 12:06:05 +0200 Subject: [PATCH 34/35] pve-rs: bump to 0.7.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fabian Grünbichler --- pve-rs/Cargo.toml | 2 +- pve-rs/debian/changelog | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/pve-rs/Cargo.toml b/pve-rs/Cargo.toml index 63922cc1..855c72de 100644 --- a/pve-rs/Cargo.toml +++ b/pve-rs/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pve-rs" -version = "0.7.1" +version = "0.7.2" authors = ["Proxmox Support Team "] edition = "2018" license = "AGPL-3" diff --git a/pve-rs/debian/changelog b/pve-rs/debian/changelog index 5bcf6249..0765eb92 100644 --- a/pve-rs/debian/changelog +++ b/pve-rs/debian/changelog @@ -1,3 +1,9 @@ +libpve-rs-perl (0.7.2) bullseye; urgency=medium + + * update to proxmox-subscription 0.3 / proxmox-http 0.7 + + -- Proxmox Support Team Wed, 7 Sep 2022 11:56:38 +0200 + libpve-rs-perl (0.7.1) bullseye; urgency=medium * add 'allow-subdomains' property to webauthn config From 9488180f9ef3bf57e049b645c001c3df9b65e11c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= Date: Wed, 7 Sep 2022 12:06:18 +0200 Subject: [PATCH 35/35] pmg-rs: bump to 0.6.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fabian Grünbichler --- pmg-rs/Cargo.toml | 2 +- pmg-rs/debian/changelog | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/pmg-rs/Cargo.toml b/pmg-rs/Cargo.toml index 4051c13c..903ed3b7 100644 --- a/pmg-rs/Cargo.toml +++ b/pmg-rs/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pmg-rs" -version = "0.6.1" +version = "0.6.2" authors = [ "Proxmox Support Team ", "Wolfgang Bumiller ", diff --git a/pmg-rs/debian/changelog b/pmg-rs/debian/changelog index 06289ce7..90f61b1c 100644 --- a/pmg-rs/debian/changelog +++ b/pmg-rs/debian/changelog @@ -1,3 +1,9 @@ +libpmg-rs-perl (0.6.2) bullseye; urgency=medium + + * update to proxmox-subscription 0.3 / proxmox-http 0.7 + + -- Proxmox Support Team Wed, 7 Sep 2022 11:54:26 +0200 + libpmg-rs-perl (0.6.1) bullseye; urgency=medium * add 'allow-subdomains' property to webauthn config