Skip to content

Instantly share code, notes, and snippets.

View antranigv's full-sized avatar
🦇
I'm your worst nightmare...

Antranig Vartanian antranigv

🦇
I'm your worst nightmare...
View GitHub Profile
@antranigv
antranigv / getpwd.c
Last active April 21, 2024 19:40
Get current working directory of a process in FreeBSD in C using libprocstat [no error handling]
// cc getpwd.c -l procstat -o getpwd
#include <sys/param.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/un.h>
#include <sys/user.h>
#include <sys/queue.h>
#include <sys/socket.h>
#include <libprocstat.h>
[global]
# adjust this to your network/netmask
remote announce = 172.16.100.0/24
security = user
encrypt passwords = yes
ea support = No
kernel share modes = No
mangled names = no
path = /usr/local/timemachine/%U
@antranigv
antranigv / gist:5acb4fffb1c8d52c8b8d8013ddecd4f7
Created July 24, 2023 22:30
Devuan Linux Jail on FreeBSD 13.2
root@srv0:/etc/jail.conf.d # cat linux0.conf
# vim: set syntax=sh:
exec.clean;
allow.raw_sockets;
mount.devfs;
linux0 {
$id = "2";
devfs_ruleset = 10;
$bridge = "bridge10";
@antranigv
antranigv / jailua.lua
Created March 16, 2023 03:11
FreeBSD jailua for Jail management
#!/usr/libexec/flua
local ucl = require('ucl')
local jail = require('jail')
function usage()
print(arg[0] .. " [ list | create jail.ucl | remove jail.ucl [jname] ]")
end
if #arg < 1 then
usage()
#!/bin/sh
add::fds()
{
COMMAND="fds,$1:$COMMAND"
}
run::fds()
{
procstat --libxo=xml -w 5 -f "$1" &
#!/bin/sh
#
# PROVIDE: khosenk
# REQUIRE: networking
# KEYWORD:
. /etc/rc.subr
name="khosenk"
rcvar="khosenk_enable"
use_synth :piano
use_bpm 94
define :intro do
play :C5
sleep 0.5
play :E5
sleep 0.5
play :A5
sleep 0.5
# cat /etc/jail.conf
exec.start = "/bin/sh /etc/rc";
exec.stop = "/bin/sh /etc/rc.shutdown";
exec.clean;
allow.raw_sockets;
allow.mount.tmpfs;
mount.devfs;
base {
@antranigv
antranigv / portconfig
Created June 25, 2017 17:57
config ports in FreeBSD. v0.001
#!/bin/sh
if [ "$2" = "show" ]; then
make -C /usr/ports/$1 showconfig ;
exit
fi
make -C /usr/ports/$1 config
MODULE subsum;
IMPORT Out, Modules;
VAR s : POINTER TO ARRAY OF LONGINT; i : LONGINT;
PROCEDURE Check ( a : ARRAY OF LONGINT ) : BOOLEAN;
VAR i , sum : LONGINT;
BEGIN
sum := 0;