all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Shannon Sterz <s.sterz@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [RFC PATCH] apt: add keys as option for proxmox repositories
Date: Fri, 11 Jul 2025 15:39:17 +0200	[thread overview]
Message-ID: <20250711133917.251291-1-s.sterz@proxmox.com> (raw)

Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
---

sending this as rfc for now as i could not do any in-depth testing yet,
but cargo {check,clippy,test} are all happy (or at least not less happy
than before).

 proxmox-apt/src/repositories/repository.rs |  2 +-
 proxmox-apt/src/repositories/standard.rs   | 24 +++++++++++++++-------
 2 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/proxmox-apt/src/repositories/repository.rs b/proxmox-apt/src/repositories/repository.rs
index a1263e89..24e7943b 100644
--- a/proxmox-apt/src/repositories/repository.rs
+++ b/proxmox-apt/src/repositories/repository.rs
@@ -122,7 +122,7 @@ impl APTRepositoryImpl for APTRepository {
         product: &str,
         suite: &str,
     ) -> bool {
-        let (package_type, handle_uris, component) = handle.info(product);
+        let (package_type, handle_uris, component, _key) = handle.info(product);

         let mut found_uri = false;

diff --git a/proxmox-apt/src/repositories/standard.rs b/proxmox-apt/src/repositories/standard.rs
index 7eef0502..3dfb917b 100644
--- a/proxmox-apt/src/repositories/standard.rs
+++ b/proxmox-apt/src/repositories/standard.rs
@@ -1,6 +1,6 @@
 use proxmox_apt_api_types::{
-    APTRepository, APTRepositoryFileType, APTRepositoryHandle, APTRepositoryPackageType,
-    APTStandardRepository,
+    APTRepository, APTRepositoryFileType, APTRepositoryHandle, APTRepositoryOption,
+    APTRepositoryPackageType, APTStandardRepository,
 };

 use crate::repositories::DebianCodename;
@@ -27,10 +27,11 @@ pub trait APTRepositoryHandleImpl {
     fn name(self) -> String;
     /// Get the standard file path for the repository referenced by the handle.
     fn path(self, product: &str, suite: &str) -> String;
-    /// Get package type, possible URIs and the component associated with the handle.
+    /// Get package type, possible URIs, the component associated with the handle and the
+    /// associated signing key.
     ///
     /// The first URI is the preferred one.
-    fn info(self, product: &str) -> (APTRepositoryPackageType, Vec<String>, String);
+    fn info(self, product: &str) -> (APTRepositoryPackageType, Vec<String>, String, &str);
     /// Get the standard repository referenced by the handle.
     ///
     /// An URI in the result is not '/'-terminated (under the assumption that no valid
@@ -111,7 +112,7 @@ impl APTRepositoryHandleImpl for APTRepositoryHandle {
         }
     }

-    fn info(self, product: &str) -> (APTRepositoryPackageType, Vec<String>, String) {
+    fn info(self, product: &str) -> (APTRepositoryPackageType, Vec<String>, String, &str) {
         match self {
             APTRepositoryHandle::Enterprise => (
                 APTRepositoryPackageType::Deb,
@@ -123,6 +124,7 @@ impl APTRepositoryHandleImpl for APTRepositoryHandle {
                     _ => vec![format!("https://enterprise.proxmox.com/debian/{product}")],
                 },
                 format!("{product}-enterprise"),
+                "/usr/share/keyrings/proxmox-archive-keyring.gpg",
             ),
             APTRepositoryHandle::NoSubscription => (
                 APTRepositoryPackageType::Deb,
@@ -134,6 +136,7 @@ impl APTRepositoryHandleImpl for APTRepositoryHandle {
                     _ => vec![format!("http://download.proxmox.com/debian/{product}")],
                 },
                 format!("{product}-no-subscription"),
+                "/usr/share/keyrings/proxmox-archive-keyring.gpg",
             ),
             APTRepositoryHandle::Test => (
                 APTRepositoryPackageType::Deb,
@@ -145,27 +148,31 @@ impl APTRepositoryHandleImpl for APTRepositoryHandle {
                     _ => vec![format!("http://download.proxmox.com/debian/{product}")],
                 },
                 format!("{product}-test"),
+                "/usr/share/keyrings/proxmox-archive-keyring.gpg",
             ),
             APTRepositoryHandle::CephSquidEnterprise => (
                 APTRepositoryPackageType::Deb,
                 vec!["https://enterprise.proxmox.com/debian/ceph-squid".to_string()],
                 "enterprise".to_string(),
+                "/usr/share/keyrings/proxmox-archive-keyring.gpg",
             ),
             APTRepositoryHandle::CephSquidNoSubscription => (
                 APTRepositoryPackageType::Deb,
                 vec!["http://download.proxmox.com/debian/ceph-squid".to_string()],
                 "no-subscription".to_string(),
+                "/usr/share/keyrings/proxmox-archive-keyring.gpg",
             ),
             APTRepositoryHandle::CephSquidTest => (
                 APTRepositoryPackageType::Deb,
                 vec!["http://download.proxmox.com/debian/ceph-squid".to_string()],
                 "test".to_string(),
+                "/usr/share/keyrings/proxmox-archive-keyring.gpg",
             ),
         }
     }

     fn to_repository(self, product: &str, suite: &str) -> APTRepository {
-        let (package_type, uris, component) = self.info(product);
+        let (package_type, uris, component, key) = self.info(product);

         let file_type = match DebianCodename::try_from(suite) {
             Ok(codename) if codename >= DebianCodename::Trixie => APTRepositoryFileType::Sources,
@@ -177,7 +184,10 @@ impl APTRepositoryHandleImpl for APTRepositoryHandle {
             uris: vec![uris.into_iter().next().unwrap()],
             suites: vec![suite.to_string()],
             components: vec![component],
-            options: vec![],
+            options: vec![APTRepositoryOption {
+                key: "Signed-By".into(),
+                values: vec![key.to_string()],
+            }],
             comment: String::new(),
             file_type,
             enabled: true,
--
2.39.5



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


             reply	other threads:[~2025-07-11 13:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-11 13:39 Shannon Sterz [this message]
2025-07-15 21:36 ` [pbs-devel] applied: " Thomas Lamprecht
2025-07-15 21:36   ` [pve-devel] applied: [pbs-devel] " Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250711133917.251291-1-s.sterz@proxmox.com \
    --to=s.sterz@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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