filter out usb stick during install (#1974)

* filter out usb stick during install

* remove duplicate error kind

* clean out newline
This commit is contained in:
Aiden McClelland
2022-11-26 15:10:39 -07:00
parent 2336e36314
commit 96f77a6275
6 changed files with 48 additions and 35 deletions

View File

@@ -147,21 +147,21 @@ impl EmbassyCertResolver {
let private_keys = package_cert_data
.0
.private_key_to_der()
.map_err(|err| Error::new(eyre!("err {}", err), crate::ErrorKind::BytesError))?;
.map_err(|err| Error::new(eyre!("{}", err), crate::ErrorKind::OpenSsl))?;
let mut full_rustls_certs = Vec::new();
for cert in x509_cert_chain.iter() {
let cert =
Certificate(cert.to_der().map_err(|err| {
Error::new(eyre!("err: {}", err), crate::ErrorKind::BytesError)
})?);
let cert = Certificate(
cert.to_der()
.map_err(|err| Error::new(eyre!("{}", err), crate::ErrorKind::OpenSsl))?,
);
full_rustls_certs.push(cert);
}
let pre_sign_key = PrivateKey(private_keys);
let actual_sign_key = any_supported_type(&pre_sign_key)
.map_err(|err| Error::new(eyre!("{}", err), crate::ErrorKind::SignError))?;
.map_err(|err| Error::new(eyre!("{}", err), crate::ErrorKind::OpenSsl))?;
let cert_key = CertifiedKey::new(full_rustls_certs, actual_sign_key);

View File

@@ -15,7 +15,7 @@ pub fn host_addr_fqdn(req: &Request<Body>) -> Result<ResourceFqdn, Error> {
Some(host) => {
let host_str = host
.to_str()
.map_err(|e| Error::new(eyre!("{}", e), crate::ErrorKind::AsciiError))?
.map_err(|e| Error::new(eyre!("{}", e), crate::ErrorKind::Ascii))?
.to_string();
let host_uri: ResourceFqdn = host_str.split(':').next().unwrap().parse()?;
@@ -23,7 +23,10 @@ pub fn host_addr_fqdn(req: &Request<Body>) -> Result<ResourceFqdn, Error> {
Ok(host_uri)
}
None => Err(Error::new(eyre!("No Host"), crate::ErrorKind::NoHost)),
None => Err(Error::new(
eyre!("No Host header"),
crate::ErrorKind::MissingHeader,
)),
}
}

View File

@@ -346,13 +346,13 @@ impl ProxyControllerInner {
removed_server.shutdown.send(()).map_err(|_| {
Error::new(
eyre!("Hyper server did not quit properly"),
crate::ErrorKind::JoinError,
crate::ErrorKind::Unknown,
)
})?;
removed_server
.handle
.await
.with_kind(crate::ErrorKind::JoinError)?;
.with_kind(crate::ErrorKind::Unknown)?;
self.docker_interfaces.remove(&package.clone());
self.docker_iface_lookups
.remove(&(package.clone(), interface_id));

View File

@@ -37,7 +37,23 @@ pub fn disk() -> Result<(), Error> {
#[command(display(display_none))]
pub async fn list() -> Result<Vec<DiskInfo>, Error> {
crate::disk::util::list(&Default::default()).await
let skip = Path::new(
&String::from_utf8(
Command::new("grub-probe-default")
.arg("-t")
.arg("disk")
.arg("/cdrom")
.invoke(crate::ErrorKind::Grub)
.await?,
)?
.trim(),
)
.to_owned();
Ok(crate::disk::util::list(&Default::default())
.await?
.into_iter()
.filter(|i| &*i.logicalname != skip)
.collect())
}
pub async fn find_wifi_iface() -> Result<Option<String>, Error> {
@@ -253,14 +269,14 @@ pub async fn execute(
Command::new("chroot")
.arg(&current)
.arg("systemd-machine-id-setup")
.invoke(crate::ErrorKind::Unknown) // TODO systemd
.invoke(crate::ErrorKind::Systemd)
.await?;
Command::new("chroot")
.arg(&current)
.arg("ssh-keygen")
.arg("-A")
.invoke(crate::ErrorKind::Unknown) // TODO ssh
.invoke(crate::ErrorKind::OpenSsh)
.await?;
let dev = MountGuard::mount(&Bind::new("/dev"), current.join("dev"), ReadWrite).await?;
@@ -270,14 +286,14 @@ pub async fn execute(
Command::new("chroot")
.arg(&current)
.arg("update-grub")
.invoke(crate::ErrorKind::Unknown) // TODO grub
.invoke(crate::ErrorKind::Grub)
.await?;
Command::new("chroot")
.arg(&current)
.arg("grub-install")
.arg("--target=i386-pc")
.arg(&disk.logicalname)
.invoke(crate::ErrorKind::Unknown) // TODO grub
.invoke(crate::ErrorKind::Grub)
.await?;
dev.unmount().await?;

View File

@@ -108,7 +108,7 @@ impl HttpReader {
"{} HTTP range downloading not supported with this unit {value}",
http_url
),
crate::ErrorKind::HttpRange,
crate::ErrorKind::MissingHeader,
));
}
}
@@ -121,7 +121,7 @@ impl HttpReader {
"{} HTTP range downloading not supported with this url",
http_url
),
crate::ErrorKind::HttpRange,
crate::ErrorKind::MissingHeader,
))
}
};
@@ -136,7 +136,7 @@ impl HttpReader {
None => {
return Err(Error::new(
eyre!("No content length headers for {}", http_url),
crate::ErrorKind::ContentLength,
crate::ErrorKind::MissingHeader,
))
}
};

View File

@@ -70,14 +70,11 @@ pub enum ErrorKind {
Javascript = 59,
Pem = 60,
TLSInit = 61,
HttpRange = 62,
ContentLength = 63,
BytesError = 64,
InvalidIP = 65,
JoinError = 66,
AsciiError = 67,
NoHost = 68,
SignError = 69,
Ascii = 62,
MissingHeader = 63,
Grub = 64,
Systemd = 65,
OpenSsh = 66,
}
impl ErrorKind {
pub fn as_str(&self) -> &'static str {
@@ -143,15 +140,12 @@ impl ErrorKind {
LanPortConflict => "Incompatible LAN Port Configuration",
Javascript => "Javascript Engine Error",
Pem => "PEM Encoding Error",
TLSInit => "TLS Backend Initialize Error",
HttpRange => "No Support for Web Server HTTP Ranges",
ContentLength => "Request has no content length header",
BytesError => "Could not get the bytes for this request",
InvalidIP => "Could not parse this IP address",
JoinError => "Join Handle Error",
AsciiError => "Could not parse ascii text",
NoHost => "No Host header ",
SignError => "Signing error",
TLSInit => "TLS Backend Initialization Error",
Ascii => "ASCII Parse Error",
MissingHeader => "Missing Header",
Grub => "Grub Error",
Systemd => "Systemd Error",
OpenSsh => "OpenSSH Error",
}
}
}