Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrew Fresh afresh1

View GitHub Profile
@afresh1
afresh1 / vmctl-ssh
Created May 4, 2022
Provide a helper to ssh into an OpenBSD vmm vm by name without knowing what IP vmm assigned. It doesn't allow scp or things like that, haven't figured out how yet.
View vmctl-ssh
#!/usr/bin/perl
use v5.30;
use warnings;
use OpenBSD::Pledge;
use OpenBSD::Unveil;
# Copyright (c) 2021 Andrew Hewus Fresh <andrew@afresh1.com>
#
# Permission to use, copy, modify, and distribute this software for any
@afresh1
afresh1 / force_rsync.sh
Created Aug 25, 2021
A script to use as an SSH ForceCommand that only lets root connect to run rsync in the way FreeNAS/TrueNAS does it.
View force_rsync.sh
#!/bin/sh
expect='rsync --server --sender -logDtprze.LsfxC . /'
dir="/${SSH_ORIGINAL_COMMAND#$expect}"
# Try without compression
if [ "$dir" = "/${SSH_ORIGINAL_COMMAND}" ]; then
expect='rsync --server --sender -logDtpre.LsfxC . /'
dir="/${SSH_ORIGINAL_COMMAND#$expect}"
fi
@afresh1
afresh1 / clean-dupes.pl
Last active Dec 22, 2021
A perl duplicate file finder based on size and hash. Uses only core perl modules.
View clean-dupes.pl
#!/usr/bin/env perl
use v5.16;
use warnings;
#
# Copyright (c) 2021 Andrew Hewus Fresh <andrew@afresh1.com>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
View future-of-perl-response.md

I thought perhaps you might like to hear my somewhat unique perspective, although definitely not saying anything others haven't already said. My perspective comes from my three hats, as a perl hobbyist and CPAN author, the maintainer of /usr/bin/perl in OpenBSD, and as someone who has written perl professionally for just short of ten years (the fifteen before that I wrote more and more perl as a sysadmin).

Overall, I think the plan is excellent and hope it mostly moves forward. There's only one tiny issue that might keep me from coming along for the ride.

tl;dr: if the default, without concious indication of something else, for bin/perl is anything but a "best effort at perl5" I believe I, and many other people will be stuck on perl5 forever and never be able to use v7, or v8, or anything later.

First, I should probably explain what I mean by a "best effort perl5". It is the thing we have gotten from perl on code without "use v5;" specified, likely since perl 5 was first released. Most things work, s

@afresh1
afresh1 / dyndns-matches
Last active Jan 18, 2021
Some helpers to set dynamic dns on an OpenBSD firewall on namecheap.com. Usage is `dyndns-matches $interface $host $domain || namecheap-dyndns $host $domain` (with your namecheap dyndns password in /etc/namecheap-dyndns). Should be suitable for putting in cron.
View dyndns-matches
#!/bin/sh
set -e
if=$1
host=$2
domain=$3
lastip="/tmp/dyndns-$host-$domain"
ttl=3600
@afresh1
afresh1 / vmctl-ssh
Last active Dec 22, 2021
A helper to look up the IP for and ssh into an OpenBSD vmd vm that uses the standard tap interface in a bridge setup. Lots of setups this won't work for, but the one where vmd provides the IP seems to work OK.
View vmctl-ssh
#!/usr/bin/perl
use v5.30;
use warnings;
use OpenBSD::Pledge;
use OpenBSD::Unveil;
# Copyright (c) 2021 Andrew Hewus Fresh <andrew@afresh1.com>
#
# Permission to use, copy, modify, and distribute this software for any
@afresh1
afresh1 / make_remote
Last active Jan 11, 2021
Helper to generate an /etc/remote file from a template by looking up a serial port from its serial number. If you don't know which `dv=` device to use, specify an `iSerial=$serial` instead.
View make_remote
#!/usr/bin/perl
use v5.30;
use warnings;
%ENV = ();
use OpenBSD::Pledge;
use OpenBSD::Unveil;
# Copyright (c) 2020 Andrew Hewus Fresh <andrew@afresh1.com>
@afresh1
afresh1 / oget
Last active Dec 13, 2020
Helper to download OpenBSD dist files (mostly bsd.rd) and verify them with signify.
View oget
#!/usr/bin/perl -T
use v5.16;
use warnings;
delete $ENV{PATH};
delete $ENV{ENV};
use OpenBSD::Unveil;
use OpenBSD::Pledge;
@afresh1
afresh1 / vfs-sysctl_hw_sensors-discovery
Created Jul 22, 2020
A perl script to convert OpenBSD's `sysctl hw.sensors` output into something that might be useful for Zabbix.
View vfs-sysctl_hw_sensors-discovery
#!/usr/bin/perl -T
use v5.16;
use warnings;
use OpenBSD::Pledge qw< pledge >;
use JSON::PP qw<>;
# Copyright (c) 2020 Andrew Hewus Fresh <andrew@afresh1.com>
#
# Permission to use, copy, modify, and distribute this software for any
@afresh1
afresh1 / openbsd-httpd-fastcgi-notes.md
Created Jul 12, 2020
Notes on how OpenBSD's httpd handles its FastCGI parameters. Debugging it with slowcgi.
View openbsd-httpd-fastcgi-notes.md

These examples all live in a default server block in your httpd.conf(5).

server "default" {
	listen on * port 80
	... # all the location blocks can together right here
}

We'll be using slowcgi(8) as the example, because with the -d flag it helpfully spits out the FastCGI environment it got from httpd(8) and what it's planning to do with that.