From 6c166649e54b5a6860bba91961af54a3c5a69355 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Tue, 9 Nov 2021 15:23:56 +0100 Subject: [PATCH] This repository was moved to proxmox-perl-rs Signed-off-by: Wolfgang Bumiller --- Cargo.toml | 25 ------- Makefile | 74 ------------------ README | 1 + debian/changelog | 49 ------------ debian/compat | 1 - debian/control | 20 ----- debian/copyright | 16 ---- debian/rules | 7 -- debian/source/format | 1 - debian/triggers | 1 - rustfmt.toml | 1 - src/apt/mod.rs | 1 - src/apt/repositories.rs | 162 ---------------------------------------- src/lib.rs | 2 - src/openid/mod.rs | 88 ---------------------- 15 files changed, 1 insertion(+), 448 deletions(-) delete mode 100644 Cargo.toml delete mode 100644 Makefile create mode 100644 README delete mode 100644 debian/changelog delete mode 100644 debian/compat delete mode 100644 debian/control delete mode 100644 debian/copyright delete mode 100755 debian/rules delete mode 100644 debian/source/format delete mode 100644 debian/triggers delete mode 100644 rustfmt.toml delete mode 100644 src/apt/mod.rs delete mode 100644 src/apt/repositories.rs delete mode 100644 src/lib.rs delete mode 100644 src/openid/mod.rs diff --git a/Cargo.toml b/Cargo.toml deleted file mode 100644 index 33eac8d..0000000 --- a/Cargo.toml +++ /dev/null @@ -1,25 +0,0 @@ -[package] -name = "pve-rs" -version = "0.2.3" -authors = ["Proxmox Support Team "] -edition = "2018" -license = "AGPL-3" -description = "PVE parts which have been ported to Rust" -homepage = "https://www.proxmox.com" -exclude = [ - "build", - "debian", - "PVE", -] - -[lib] -crate-type = [ "cdylib" ] - -[dependencies] -anyhow = "1.0" -hex = "0.4" -serde = "1.0" - -perlmod = { version = "0.5.2", features = [ "exporter" ] } -proxmox-apt = "0.8" -proxmox-openid = "0.8" diff --git a/Makefile b/Makefile deleted file mode 100644 index 9701c8e..0000000 --- a/Makefile +++ /dev/null @@ -1,74 +0,0 @@ -include /usr/share/dpkg/default.mk - -PACKAGE=libpve-rs-perl - -ARCH:=$(shell dpkg-architecture -qDEB_BUILD_ARCH) -export GITVERSION:=$(shell git rev-parse HEAD) - -PERL_INSTALLVENDORARCH != perl -MConfig -e 'print $$Config{installvendorarch};' -PERL_INSTALLVENDORLIB != perl -MConfig -e 'print $$Config{installvendorlib};' - -MAIN_DEB=${PACKAGE}_${DEB_VERSION}_${ARCH}.deb -DBGSYM_DEB=${PACKAGE}-dbgsym_${DEB_VERSION}_${ARCH}.deb -DEBS=$(MAIN_DEB) $(DBGSYM_DEB) - -DESTDIR= - -PM_DIRS := \ - PVE/RS/APT - -PM_FILES := \ - PVE/RS/OpenId.pm \ - PVE/RS/APT/Repositories.pm - -ifeq ($(BUILD_MODE), release) -CARGO_BUILD_ARGS += --release -endif - -all: -ifneq ($(BUILD_MODE), skip) - cargo build $(CARGO_BUILD_ARGS) -endif - -# always re-create this dir -# but also copy the local target/ and PVE/ dirs as a build-cache -.PHONY: build -build: - rm -rf build - cargo build --release - rsync -a debian Makefile Cargo.toml Cargo.lock src target PVE build/ - -.PHONY: install -install: target/release/libpve_rs.so - install -d -m755 $(DESTDIR)$(PERL_INSTALLVENDORARCH)/auto - install -m644 target/release/libpve_rs.so $(DESTDIR)$(PERL_INSTALLVENDORARCH)/auto/libpve_rs.so - install -d -m755 $(DESTDIR)$(PERL_INSTALLVENDORLIB)/PVE/RS - for i in $(PM_DIRS); do \ - install -d -m755 $(DESTDIR)$(PERL_INSTALLVENDORLIB)/$$i; \ - done - for i in $(PM_FILES); do \ - install -m644 $$i $(DESTDIR)$(PERL_INSTALLVENDORLIB)/$$i; \ - done - -.PHONY: deb -deb: $(MAIN_DEB) -$(MAIN_DEB): build - cd build; dpkg-buildpackage -b -us -uc --no-pre-clean - lintian $(DEBS) - -distclean: clean - -clean: - cargo clean - rm -rf *.deb *.dsc *.tar.gz *.buildinfo *.changes Cargo.lock build - find . -name '*~' -exec rm {} ';' - -.PHONY: dinstall -dinstall: ${DEBS} - dpkg -i ${DEBS} - -.PHONY: upload -upload: ${DEBS} - # check if working directory is clean - git diff --exit-code --stat && git diff --exit-code --stat --staged - tar cf - ${DEBS} | ssh -X repoman@repo.proxmox.com upload --product pve --dist bullseye diff --git a/README b/README new file mode 100644 index 0000000..245f6b0 --- /dev/null +++ b/README @@ -0,0 +1 @@ +This repository was moved to `proxmox-perl-rs`. diff --git a/debian/changelog b/debian/changelog deleted file mode 100644 index b247a35..0000000 --- a/debian/changelog +++ /dev/null @@ -1,49 +0,0 @@ -libpve-rs-perl (0.2.3) bullseye; urgency=medium - - * use newer dependencies for apt to improve repo+suite handling - - -- Proxmox Support Team Thu, 29 Jul 2021 18:13:07 +0200 - -libpve-rs-perl (0.2.2) bullseye; urgency=medium - - * apt: avoid overwriting files that could not be parsed - - * apt: check if repository is already configured before adding - - -- Proxmox Support Team Fri, 02 Jul 2021 13:06:42 +0200 - -libpve-rs-perl (0.2.1) bullseye; urgency=medium - - * depend on proxmox-apt 0.4.0 - - -- Proxmox Support Team Thu, 01 Jul 2021 18:37:20 +0200 - -libpve-rs-perl (0.2.0) bullseye; urgency=medium - - * add bindings for proxmox-apt - - * depend on proxmox-openid 0.6.0 - - * move to native version format - - -- Proxmox Support Team Wed, 30 Jun 2021 20:56:19 +0200 - -libpve-rs-perl (0.1.2-1) unstable; urgency=medium - - * depend on proxmox-openid 0.5.0 - - * set proxmox "default-features = false" - - -- Proxmox Support Team Wed, 23 Jun 2021 11:34:34 +0200 - -libpve-rs-perl (0.1.1-1) unstable; urgency=medium - - * depend on perlmod 0.5.1 - - -- Proxmox Support Team Wed, 23 Jun 2021 11:09:31 +0200 - -libpve-rs-perl (0.1.0-1) unstable; urgency=medium - - * Initial release. - - -- Proxmox Support Team Thu, 27 May 2021 10:41:30 +0200 diff --git a/debian/compat b/debian/compat deleted file mode 100644 index f599e28..0000000 --- a/debian/compat +++ /dev/null @@ -1 +0,0 @@ -10 diff --git a/debian/control b/debian/control deleted file mode 100644 index 1ae8f84..0000000 --- a/debian/control +++ /dev/null @@ -1,20 +0,0 @@ -Source: libpve-rs-perl -Section: perl -Priority: optional -Maintainer: Proxmox Support Team -Build-Depends: debhelper (>= 10), - librust-perlmod-macro-dev, - librust-anyhow-dev, - librust-proxmox-openid-dev, - librust-perlmod-dev, - librust-serde-dev, -Standards-Version: 4.3.0 -Homepage: https://www.proxmox.com - -Package: libpve-rs-perl -Architecture: any -Depends: ${perl:Depends}, - ${shlibs:Depends}, -Description: Components of Proxmox Virtual Environment which have been ported to Rust. - Contains parts of Proxmox Virtual Environment which have been ported to, or - newly implemented in the Rust programming language. diff --git a/debian/copyright b/debian/copyright deleted file mode 100644 index 5661ef6..0000000 --- a/debian/copyright +++ /dev/null @@ -1,16 +0,0 @@ -Copyright (C) 2021 Proxmox Server Solutions GmbH - -This software is written by Proxmox Server Solutions GmbH - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see . diff --git a/debian/rules b/debian/rules deleted file mode 100755 index 97aca06..0000000 --- a/debian/rules +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/make -f - -#export DH_VERBOSE=1 -export BUILD_MODE=skip - -%: - dh $@ diff --git a/debian/source/format b/debian/source/format deleted file mode 100644 index 89ae9db..0000000 --- a/debian/source/format +++ /dev/null @@ -1 +0,0 @@ -3.0 (native) diff --git a/debian/triggers b/debian/triggers deleted file mode 100644 index 59dd688..0000000 --- a/debian/triggers +++ /dev/null @@ -1 +0,0 @@ -activate-noawait pve-api-updates diff --git a/rustfmt.toml b/rustfmt.toml deleted file mode 100644 index 32a9786..0000000 --- a/rustfmt.toml +++ /dev/null @@ -1 +0,0 @@ -edition = "2018" diff --git a/src/apt/mod.rs b/src/apt/mod.rs deleted file mode 100644 index 574c1a7..0000000 --- a/src/apt/mod.rs +++ /dev/null @@ -1 +0,0 @@ -mod repositories; diff --git a/src/apt/repositories.rs b/src/apt/repositories.rs deleted file mode 100644 index 2d5e1da..0000000 --- a/src/apt/repositories.rs +++ /dev/null @@ -1,162 +0,0 @@ -#[perlmod::package(name = "PVE::RS::APT::Repositories", lib = "pve_rs")] -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 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, - }) - } - - /// Add the repository identified by the `handle`. - /// 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, 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(()) - } - - /// 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/src/lib.rs b/src/lib.rs deleted file mode 100644 index cad331d..0000000 --- a/src/lib.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod apt; -pub mod openid; diff --git a/src/openid/mod.rs b/src/openid/mod.rs deleted file mode 100644 index febe927..0000000 --- a/src/openid/mod.rs +++ /dev/null @@ -1,88 +0,0 @@ -#[perlmod::package(name = "PVE::RS::OpenId", lib = "pve_rs")] -mod export { - use std::sync::Mutex; - use std::convert::TryFrom; - - use anyhow::Error; - - use perlmod::{to_value, Value}; - - use proxmox_openid::{OpenIdConfig, OpenIdAuthenticator, PrivateAuthState}; - - const CLASSNAME: &str = "PVE::RS::OpenId"; - - /// An OpenIdAuthenticator client instance. - pub struct OpenId { - inner: Mutex, - } - - impl<'a> TryFrom<&'a Value> for &'a OpenId { - type Error = Error; - - fn try_from(value: &'a Value) -> Result<&'a OpenId, Error> { - Ok(unsafe { value.from_blessed_box(CLASSNAME)? }) - } - } - - fn bless(class: Value, mut ptr: Box) -> Result { - let value = Value::new_pointer::(&mut *ptr); - let value = Value::new_ref(&value); - let this = value.bless_sv(&class)?; - let _perl = Box::leak(ptr); - Ok(this) - } - - #[export(name = "DESTROY")] - fn destroy(#[raw] this: Value) { - perlmod::destructor!(this, OpenId: CLASSNAME); - } - - /// Create a new OpenId client instance - #[export(raw_return)] - pub fn discover( - #[raw] class: Value, - config: OpenIdConfig, - redirect_url: &str, - ) -> Result { - - let open_id = OpenIdAuthenticator::discover(&config, redirect_url)?; - bless( - class, - Box::new(OpenId { - inner: Mutex::new(open_id), - }), - ) - } - - #[export] - pub fn authorize_url( - #[try_from_ref] this: &OpenId, - state_dir: &str, - realm: &str, - ) -> Result { - - let open_id = this.inner.lock().unwrap(); - open_id.authorize_url(state_dir, realm) - } - - #[export] - pub fn verify_public_auth_state( - state_dir: &str, - state: &str, - ) -> 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, - code: &str, - private_auth_state: PrivateAuthState, - ) -> Result { - - let open_id = this.inner.lock().unwrap(); - let claims = open_id.verify_authorization_code(code, &private_auth_state)?; - - Ok(to_value(&claims)?) - } -}