mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 04:01:58 +00:00
use product key instead of id for drive verification
This commit is contained in:
committed by
Aiden McClelland
parent
7c26b18c73
commit
fd37bbf712
@@ -93,21 +93,22 @@ pub async fn attach(
|
|||||||
#[arg] guid: Arc<String>,
|
#[arg] guid: Arc<String>,
|
||||||
) -> Result<SetupResult, Error> {
|
) -> Result<SetupResult, Error> {
|
||||||
crate::disk::main::import(&*guid, &ctx.datadir, DEFAULT_PASSWORD).await?;
|
crate::disk::main::import(&*guid, &ctx.datadir, DEFAULT_PASSWORD).await?;
|
||||||
init(
|
let product_key_path = Path::new("/embassy-data/main/product_key.txt");
|
||||||
&RpcContextConfig::load(ctx.config_path.as_ref()).await?,
|
if tokio::fs::metadata(product_key_path).await.is_ok() {
|
||||||
&get_product_key().await?,
|
let pkey = tokio::fs::read_to_string(product_key_path).await?;
|
||||||
)
|
if pkey.trim() != &*ctx.product_key().await? {
|
||||||
.await?;
|
crate::disk::main::export(&*guid, &ctx.datadir).await?;
|
||||||
let product_id_path = Path::new("/embassy-data/main/product_id.txt");
|
|
||||||
if tokio::fs::metadata(product_id_path).await.is_ok() {
|
|
||||||
let pid = tokio::fs::read_to_string(product_id_path).await?;
|
|
||||||
if pid != crate::hostname::derive_id(&*ctx.product_key().await?) {
|
|
||||||
return Err(Error::new(
|
return Err(Error::new(
|
||||||
eyre!("The EmbassyOS product key does not match the supplied drive"),
|
eyre!("The EmbassyOS product key does not match the supplied drive"),
|
||||||
ErrorKind::ProductKeyMismatch,
|
ErrorKind::ProductKeyMismatch,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
init(
|
||||||
|
&RpcContextConfig::load(ctx.config_path.as_ref()).await?,
|
||||||
|
&*ctx.product_key().await?,
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
*ctx.disk_guid.write().await = Some(guid.clone());
|
*ctx.disk_guid.write().await = Some(guid.clone());
|
||||||
let secrets = ctx.secret_store().await?;
|
let secrets = ctx.secret_store().await?;
|
||||||
let tor_key = crate::net::tor::os_key(&mut secrets.acquire().await?).await?;
|
let tor_key = crate::net::tor::os_key(&mut secrets.acquire().await?).await?;
|
||||||
@@ -252,8 +253,8 @@ pub async fn complete(#[context] ctx: SetupContext) -> Result<(), Error> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
tokio::fs::write(
|
tokio::fs::write(
|
||||||
Path::new("/embassy-data/main/product_id.txt"),
|
Path::new("/embassy-data/main/product_key.txt"),
|
||||||
crate::hostname::derive_id(&*ctx.product_key().await?),
|
&*ctx.product_key().await?,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
let secrets = ctx.secret_store().await?;
|
let secrets = ctx.secret_store().await?;
|
||||||
|
|||||||
Reference in New Issue
Block a user