Skip to content

Instantly share code, notes, and snippets.

View FauxFaux's full-sized avatar

Chris West FauxFaux

View GitHub Profile
printf "[Service]\nSystemCallFilter=~fsync sync syncfs fdatasync msync sync_file_range\nSystemCallErrorNumber=0\n" \
| s env EDITOR='tee -a' systemctl edit [email protected]
// cc drop-privs-harder.c -o drop-privs-harder -lseccomp
#define _GNU_SOURCE
#include <stdio.h>
#include <unistd.h>
#include <sys/prctl.h>
#include <errno.h>
#include <seccomp.h>
@FauxFaux
FauxFaux / mmap_sigbus.c
Created April 12, 2017 23:43
Repairing a SIGBUS from an OOB read of an mmap'd file
#include <assert.h>
#include <stdio.h>
#include <stdint.h>
#include <stddef.h>
#include <stdlib.h>
#include <fcntl.h>
#include <signal.h>
#include <unistd.h>
@FauxFaux
FauxFaux / custom_error.rs
Created May 21, 2017 15:30
Creating and detecting a custom error type (~ `e instanceof Fooexception`)
use std::error;
use std::fmt;
use std::io;
#[derive(Debug)]
struct MyError {
}
impl error::Error for MyError {
fn description(&self) -> &str {
commit 9d2bf90676206957a502e9ec1c3cfe4f4b40b0cc
Author: Chris West (Faux) <[email protected]>
Date: Thu Jun 1 17:01:16 2017 +0000
dynamically allocate EVP_CTX
diff --git a/boxbackup-0.11.1~r2837/debian/control b/boxbackup-0.11.1~r2837/debian/control
index 5cbdba6..d422125 100644
--- a/boxbackup-0.11.1~r2837/debian/control
+++ b/boxbackup-0.11.1~r2837/debian/control
# grab a load of dbd txt files
# v the maximum size of log to download
./fetch-logs -m 5k --download --delete-outdated -t dbdtxt
# process the logs
cd logs
../has-only.py debian/dbdtxt/unstable/amd64/*
# read out some packages
CBP=$(python3 -c 'import yaml; print(" ".join(pkg for pkg,dat in yaml.load(open("suggested_notes.yml")).items() if "captures_build_path" in dat.get("issues", {})))')
#[macro_use]
extern crate error_chain;
use errors::*;
fn call_john() -> Result<()> {
john::useful()
.chain_err(|| "calling useful")
?;
Ok(())
use std::collections::HashMap;
use std::collections::hash_map;
#[derive(Debug)]
enum Node {
Dir(HashMap<String, Node>),
File
}
fn list_to_tree(from: Vec<Vec<String>>) -> HashMap<String, Node> {
use std::collections::HashMap;
use std::collections::hash_map;
#[derive(Debug)]
enum Node {
Dir(HashMap<String, Node>),
File
}
fn add(into: &mut HashMap<String, Node>, remaining: &[String]) {
cleanup() {
sudo umount a
rm a.img
sudo losetup -d /dev/loop0
}
set -eu
mkdir -p a
truncate -s 128k a.img
mkfs.ext4 a.img >/dev/null 2>&1