Skip to content

Instantly share code, notes, and snippets.

View andoriyu's full-sized avatar
🏠
Working from home

Andrey Snow andoriyu

🏠
Working from home
View GitHub Profile
//
// Created by andoriyu on 4/17/22.
//
#include "fuckery.h"
#include <stdio.h>
extern nvlist_t * fuckery_make_nvlist(const char *name, nvlist_t *list) {
FILE *fp1, *fp2, *fp3;
fp1 = fopen("/tmp/fp1.txt", "w+");
@andoriyu
andoriyu / README.md
Created February 15, 2022 05:23 — forked from hiway/README.md
Creating a single process FreeBSD (12.1) Jail

How to jail a single process web server on FreeBSD 12.1

You may have found many great resources on how to set up jails on latest FreeBSD, however there is scant information on how to go about creating a barebones jail with nothing but the one process that you want to isolate.

I was curious if I could contain a statically compiled web server that I wrote while learning Rust all by itself in a jail instead of having a full userland.

=>> Building deskutils/gnome-contacts
build started at Thu Oct 1 23:41:46 PDT 2020
port directory: /usr/ports/deskutils/gnome-contacts
package name: gnome-contacts-3.38
building for: FreeBSD freebsd_12_1-amd64-system-nimble-job-01 12.1-RELEASE-p9 FreeBSD 12.1-RELEASE-p9 amd64
maintained by: gnome@FreeBSD.org
Makefile ident: $FreeBSD: head/deskutils/gnome-contacts/Makefile 550494 2020-09-29 12:07:28Z bapt $
Poudriere version: 3.3.99.20200326
Host OSVERSION: 1201000
Jail OSVERSION: 1201000
andoriyu@fulcrum:/usr/local/etc/poudriere.d % cat build-eden.sh
#!/bin/sh
PORTS="system"
ZSET="eden"
JAIL="freebsd_12_1-amd64"
poudriere bulk -J 4:16 -j ${JAIL} -p $PORTS -z $ZSET -f /usr/local/etc/poudriere.d/eden.pkg.d/00
andoriyu@fulcrum:/usr/local/etc/poudriere.d % sudo ps ax | grep poud
==4658== Memcheck, a memory error detector
==4658== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==4658== Using Valgrind-3.14.0 and LibVEX; rerun with -h for copyright info
==4658== Command: ./target/debug/uclicious-c0965233f696e227 raw::parser::test::basic_vars_handler
==4658==
==4658== Syscall param statx(file_name) points to unaddressable byte(s)
==4658== at 0x498AF59: syscall (syscall.S:38)
==4658== by 0x1CB85B: statx (weak.rs:90)
==4658== by 0x1CB85B: std::sys::unix::fs::try_statx (fs.rs:122)
==4658== by 0x1C67EE: std::sys::unix::fs::stat (fs.rs:1035)
running 1 test
==4644== Thread 2 raw::parser::tes:
==4644== Invalid write of size 2
==4644== at 0x483C9DB: memmove (vg_replace_strmem.c:1270)
==4644== by 0x1A77E7: ucl_expand_single_variable (ucl_parser.c:466)
==4644== by 0x1A7998: ucl_expand_variable (ucl_parser.c:540)
==4644== by 0x1A7B5C: ucl_copy_or_store_ptr (ucl_parser.c:604)
==4644== by 0x1AA886: ucl_parse_value (ucl_parser.c:1707)
==4644== by 0x1AC7B0: ucl_state_machine (ucl_parser.c:2461)
==4644== by 0x1AEA44: ucl_parser_add_chunk_full (ucl_parser.c:2947)
running 1 test
==4623== Thread 2 variable_handler:
==4623== Invalid write of size 2
==4623== at 0x483C9DB: memmove (vg_replace_strmem.c:1270)
==4623== by 0x1A77E7: ucl_expand_single_variable (ucl_parser.c:466)
==4623== by 0x1A7998: ucl_expand_variable (ucl_parser.c:540)
==4623== by 0x1A7B5C: ucl_copy_or_store_ptr (ucl_parser.c:604)
==4623== by 0x1AA886: ucl_parse_value (ucl_parser.c:1707)
==4623== by 0x1AC7B0: ucl_state_machine (ucl_parser.c:2461)
#include "libucl/include/ucl.h"
#include <sys/types.h>
#include <unistd.h>
bool handler(const unsigned char *data, size_t len,
unsigned char **replace, size_t *replace_len, bool *need_free, void* ud) {
write(1, data, len);
if (memcmp(data, "WAT", len)) {
---- raw::parser::test::basic_vars_handler stdout ----
[src/raw/parser.rs:256] (data, len) = (
0x0000000801c98052,
3,
)
[src/raw/parser.rs:265] &var = "WWW"
[src/raw/parser.rs:268] test.as_bytes() = [
97,
115,
100,
=>> Building archivers/zstd
build started at Fri Mar 27 00:21:49 PDT 2020
port directory: /usr/ports/archivers/zstd
package name: zstd-1.4.4_1
building for: FreeBSD live-system-nimble-job-02 12.1-RELEASE-p3 FreeBSD 12.1-RELEASE-p3 1201000 amd64
maintained by: sunpoet@FreeBSD.org
Makefile ident: $FreeBSD: head/archivers/zstd/Makefile 527189 2020-02-26 20:46:28Z sunpoet $
Poudriere version: 3.3.99.20200324
Host OSVERSION: 1201000
Jail OSVERSION: 1201000