green/blue labels

This commit is contained in:
Aiden McClelland
2021-10-02 16:56:02 -06:00
committed by Aiden McClelland
parent f995b5a12a
commit 6f1cd49b1b
3 changed files with 21 additions and 16 deletions

View File

@@ -3,6 +3,8 @@ use std::time::Duration;
use rpc_toolkit::command;
use serde::{Deserialize, Serialize};
use tokio::fs::File;
use tokio::io::AsyncWriteExt;
use tokio::process::Command;
use torut::onion::TorSecretKeyV3;
@@ -98,9 +100,11 @@ pub async fn execute_inner(
)
.execute(&mut sqlite_pool.acquire().await?)
.await?;
tokio::fs::write("/embassy-os/disk.guid", &guid)
.await
.with_ctx(|_| (crate::ErrorKind::Filesystem, "/embassy-os/disk.guid"))?;
let mut guid_file = File::create("/embassy-os/disk.guid").await?;
guid_file.write_all(guid.as_bytes()).await?;
guid_file.sync_all().await?;
crate::disk::main::export(&ctx.zfs_pool_name).await?;
ctx.shutdown.send(()).expect("failed to shutdown");
Ok(SetupResult {

View File

@@ -14,13 +14,14 @@ sudo losetup -d $LOOPDEV
# Label the filesystems
sudo fatlabel ${OUTPUT_DEVICE}p1 system-boot
sudo fatlabel ${OUTPUT_DEVICE}p2 EMBASSY
sudo e2label ${OUTPUT_DEVICE}p3 writable
sudo e2label ${OUTPUT_DEVICE}p4 reserved
sudo e2label ${OUTPUT_DEVICE}p3 green
sudo e2label ${OUTPUT_DEVICE}p4 blue
# Mount the boot partition and config
mkdir -p /tmp/eos-mnt
sudo mount ${OUTPUT_DEVICE}p1 /tmp/eos-mnt
sudo sed -i 's/LABEL=writable/LABEL=green/g' /tmp/eos-mnt/cmdline.txt
cat /tmp/eos-mnt/config.txt | grep -v "dtoverlay=" | sudo tee /tmp/eos-mnt/config.txt.tmp
echo "dtoverlay=pwm-2chan" | sudo tee -a /tmp/eos-mnt/config.txt.tmp
sudo mv /tmp/eos-mnt/config.txt.tmp /tmp/eos-mnt/config.txt
@@ -55,4 +56,4 @@ sudo cp ./build/initialization.sh /tmp/eos-mnt/usr/local/bin
sudo cp ./build/initialization.service /tmp/eos-mnt/etc/systemd/system/initialization.service
sudo ln -s /etc/systemd/system/initialization.service /tmp/eos-mnt/etc/systemd/system/multi-user.target.wants/initialization.service
sudo umount /tmp/eos-mnt
sudo umount /tmp/eos-mnt

View File

@@ -44,13 +44,13 @@ export class HttpService {
this.fullUrl + httpOpts.url :
httpOpts.url
const encryptedBody = await AES_CTR.encryptPbkdf2(this.productKey, encodeUtf8( JSON.stringify(httpOpts.body)))
const encryptedBody = await AES_CTR.encryptPbkdf2(this.productKey, encodeUtf8(JSON.stringify(httpOpts.body)))
const options = {
responseType: 'arraybuffer',
body: encryptedBody.buffer,
observe: 'events',
reportProgress: false,
headers: {
'Content-Encoding': 'aesctr256',
'Content-Type': 'application/json'
@@ -59,15 +59,15 @@ export class HttpService {
const req = this.http.post(url, options.body, options)
return (withTimeout(req, 60000))
return (req)
.toPromise()
.then(res => AES_CTR.decryptPbkdf2(this.productKey, (res as any).body as ArrayBuffer))
.then(res => JSON.parse(res))
.catch(e => {
if(!e.status && !e.statusText) {
if (!e.status && !e.statusText) {
throw new EncryptionError(e)
} else {
throw new HttpError(e)
throw new HttpError(e)
}
})
}
@@ -100,11 +100,11 @@ function EncryptionError (e: HttpErrorResponse): void {
this.details = null
}
function isRpcError<Error, Result> (arg: { error: Error } | { result: Result}): arg is { error: Error } {
function isRpcError<Error, Result> (arg: { error: Error } | { result: Result }): arg is { error: Error } {
return !!(arg as any).error
}
function isRpcSuccess<Error, Result> (arg: { error: Error } | { result: Result}): arg is { result: Result } {
function isRpcSuccess<Error, Result> (arg: { error: Error } | { result: Result }): arg is { result: Result } {
return !!(arg as any).result
}
@@ -180,7 +180,7 @@ type AES_CTR = {
}
export const AES_CTR: AES_CTR = {
encryptPbkdf2: async (secretKey: string, messageBuffer: Uint8Array) => {
encryptPbkdf2: async (secretKey: string, messageBuffer: Uint8Array) => {
const salt = window.crypto.getRandomValues(new Uint8Array(16))
const counter = window.crypto.getRandomValues(new Uint8Array(16))
@@ -188,9 +188,9 @@ export const AES_CTR: AES_CTR = {
const aesCtr = new aesjs.ModeOfOperation.ctr(key, new aesjs.Counter(counter));
const encryptedBytes = aesCtr.encrypt(messageBuffer);
return new Uint8Array([...counter,...salt,...encryptedBytes])
return new Uint8Array([...counter, ...salt, ...encryptedBytes])
},
decryptPbkdf2: async (secretKey: string, arr: ArrayBuffer) => {
decryptPbkdf2: async (secretKey: string, arr: ArrayBuffer) => {
const buff = new Uint8Array(arr)
const counter = buff.slice(0, 16)
const salt = buff.slice(16, 32)