apt: allow changelog retrieval from enterprise repo
If a package is or will be installed from the enterprise repo, retrieve the changelog from there as well (securely via HTTPS and authenticated with the subcription key). Extends the get_string method to take additional headers, in this case used for 'Authorization'. Hyper does not have built-in basic auth support AFAICT but it's simple enough to just build the header manually. Take the opportunity and also set the User-Agent sensibly for GET requests, just like for POST. Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
This commit is contained in:
committed by
Thomas Lamprecht
parent
ed1329ecf7
commit
137a6ebcad
@ -128,8 +128,13 @@ fn get_changelog_url(
|
||||
None => bail!("incompatible filename, doesn't match regex")
|
||||
};
|
||||
|
||||
return Ok(format!("http://download.proxmox.com/{}/{}_{}.changelog",
|
||||
base, package, version));
|
||||
if component == "pbs-enterprise" {
|
||||
return Ok(format!("https://enterprise.proxmox.com/{}/{}_{}.changelog",
|
||||
base, package, version));
|
||||
} else {
|
||||
return Ok(format!("http://download.proxmox.com/{}/{}_{}.changelog",
|
||||
base, package, version));
|
||||
}
|
||||
}
|
||||
|
||||
bail!("unknown origin ({}) or component ({})", origin, component)
|
||||
|
@ -2,6 +2,7 @@ use anyhow::{Error, format_err, bail};
|
||||
use lazy_static::lazy_static;
|
||||
use std::task::{Context, Poll};
|
||||
use std::os::unix::io::AsRawFd;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use hyper::{Uri, Body};
|
||||
use hyper::client::{Client, HttpConnector};
|
||||
@ -26,8 +27,21 @@ lazy_static! {
|
||||
};
|
||||
}
|
||||
|
||||
pub async fn get_string(uri: &str) -> Result<String, Error> {
|
||||
let res = HTTP_CLIENT.get(uri.parse()?).await?;
|
||||
pub async fn get_string(uri: &str, extra_headers: Option<&HashMap<String, String>>) -> Result<String, Error> {
|
||||
let mut request = Request::builder()
|
||||
.method("GET")
|
||||
.uri(uri)
|
||||
.header("User-Agent", "proxmox-backup-client/1.0");
|
||||
|
||||
if let Some(hs) = extra_headers {
|
||||
for (h, v) in hs.iter() {
|
||||
request = request.header(h, v);
|
||||
}
|
||||
}
|
||||
|
||||
let request = request.body(Body::empty())?;
|
||||
|
||||
let res = HTTP_CLIENT.request(request).await?;
|
||||
|
||||
let status = res.status();
|
||||
if !status.is_success() {
|
||||
|
Reference in New Issue
Block a user