Skip to content

Instantly share code, notes, and snippets.

View haraldh's full-sized avatar
☀️
🍻

Harald Hoyer haraldh

☀️
🍻
View GitHub Profile
const NUM_RUNS: usize = 10;
fn run_self(exe: &str) -> usize {
use std::process::Command;
let mut set = std::collections::HashSet::new();
let mut cmd = Command::new(exe);
cmd.arg("--report");
(0..NUM_RUNS).for_each(|_| {
set.insert(cmd.output().expect("failed to execute process").stdout);
%rename cpp_options old_cpp_options
*cpp_options:
-nostdinc -isystem -isystem include%s %(old_cpp_options)
*cc1:
%(cc1_cpu) %{static-pie:-fPIE} -nostdinc -isystem -isystem include%s
*link_libgcc:
-L -L .%s
diff --git a/enarx-keep-sev/src/kvmvm.rs b/enarx-keep-sev/src/kvmvm.rs
index eed3b80..5ea0ae7 100644
--- a/enarx-keep-sev/src/kvmvm.rs
+++ b/enarx-keep-sev/src/kvmvm.rs
@@ -235,9 +235,9 @@ impl KvmVm {
failure::bail!(msg.to_string());
}
- let guest_code: VirtAddr = VirtAddr::new(elf_file.header.pt2.entry_point());
let mut load_addr: Option<VirtAddr> = None;
use x86_64::structures::paging::PageTableFlags;
#[repr(C, align(4096))]
pub struct Pagetable([u64; 512]);
#[link_section = ".pmldata"]
#[no_mangle]
pub static PML4T: Pagetable = Pagetable([0; 512]);
#[link_section = ".pmldata"]
@haraldh
haraldh / Rust Cheatsheet.md
Last active February 14, 2020 06:39
Rust Cheatsheet
fn convert(res: Result<Option<T>, E>) -> Result<Option<U>, E> where U : TryFrom<T, Error=E>
{
  res.and_then(|it| it.map(U::try_from).transpose())
}
@haraldh
haraldh / README.md
Last active December 16, 2023 22:09
podman-remote with ssh certificates

Restrict podman-remote access to podman with ssh certficates.

On the local machine, create a certificate CA.

$ ssh-keygen -f my_ssh_cert_authority
$ cat my_ssh_cert_authority.pub 
ssh-rsa AAAAB3NzaC1yc…

Login to the remote machine and add the CA to .ssh/authorized_keys

@haraldh
haraldh / closure_vec.rs
Last active October 21, 2019 08:47
Rust Closure Vec
type Mutator<T, R> = Box<dyn for<'a> Fn(&'a mut T) -> R + 'static>;
fn mutator<T, R, F>(f: F) -> Mutator<T, R>
where
F: for<'a> Fn(&'a mut T) -> R + 'static
{
Box::new(f) as Mutator<T, R>
}
type Validator<T, R> = Box<dyn for<'a> Fn(&'a T) -> R + 'static>;
@haraldh
haraldh / org.surfsite.access.varlink
Last active August 22, 2018 09:56
RFC: interface org.surfsite.access

Keybase proof

I hereby claim:

  • I am haraldh on github.
  • I am haraldhoyer (https://keybase.io/haraldhoyer) on keybase.
  • I have a public key ASD6KZy4D2yMtf2UGBRDBS7tuckvlI1AVs0pn_Ifc3VkbAo

To claim this, I am signing this object: