Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrew Fresh afresh1

View GitHub Profile
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 Jan 16, 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.

@afresh1
afresh1 / fill-chroot.sh
Last active Jun 7, 2020
fill-chroot - Add files and their needed libs to a chroot directory
View fill-chroot.sh
#!/bin/sh
chroot=/var/www # ${PWD}
copy_recurse() {
file=$1
[ -e "${chroot}${file}" ] && return
mkdir -p $( dirname "${chroot}${file}" )
cp -p "$file" "${chroot}${file}"
@afresh1
afresh1 / teetime
Last active Apr 16, 2020
A perl implementation of "tee" that prefixes each line to the teed file with a timestamp relative to the start of ths script.
View teetime
#!/usr/bin/perl
use strict;
use warnings;
use v5.10;
use Time::HiRes qw< gettimeofday tv_interval >;
# Copyright (c) 2020 Andrew Hewus Fresh <andrew@afresh1.com>
#
# Permission to use, copy, modify, and distribute this software for any
@afresh1
afresh1 / 6rd_config.sh
Last active Dec 7, 2019
Calculates a 6rd IP and default gateway and outputs them in an OpenBSD hostname.gif0 format from an IPv4 address, with optional mask, the v4 destination, a 6rd prefix with length. See also this gist: https://gist.github.com/afresh1/791343380b4410687d51fdd94f20bd42
View 6rd_config.sh
#!/bin/ksh
set -e
set -f -u -C
# Copyright (c) 2019 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.
#