Felix J. Ogris' private homepage: some stuff about homemade software, FreeBSD, Linux, computers, and hacking in general.
Somewhat more nosy? Mailto www@ogris.de.
You're viewing this webpage using the good old IPv4 protocol.
[2024-04-16] 499.ipdb is a helper for geolocation access on your FreeBSD firewall. It atomically loads the ip ranges of given countries to an ipfw firewall table. You run 499.ipdb weekly by periodic and as cron job during system boot. It either requires sysutils/ipdbtools from ports to directly download and compile ip geolocation data from a regional Internet registry, or may download the output from a central host that also runs 499.ipdb regularly.
[2024-03-20] text2png.py outputs a given text as scrambled picture in png format.
[2024-03-13]
graypold version 11 supports SQLite database backends. Please see the provided readme.txt. Also note that the config option for the graylisting unix socket has changed:
OLD: listen_graypol = /var/run/graypold_graypol.sock
NEW: listen_graylist = /var/run/graypold_graylist.sock
[2024-03-07]
ovpn.py version 2 displays transferred bytes human readable with suffixed kB, MB, and so, and right-aligns integer values. Here's a screenshot:
.
[2024-03-03]
[2024-02-25]
$ ssh USER@REMOTEHOST 'tcpdump -i INTERFACE -U -s 0 -w -' | wireshark -i - -k
# ifconfig vdsl vlan 7 vlandev igb0 upOn FreeBSD 13, the parameters could be given in any order, e.g.:
# ifconfig vdsl vlandev igb0 vlan 7 up
[2024-02-24] Updating a FreeBSD system bumped to FreeBSD 14.
[2024-02-17] First rule of WSGI programming: You do not use global variables. Thus, LogBlitz version 17.
# pkg install gitup # cp -aiv /usr/local/etc/gitup.conf.sample /usr/local/etc/gitup.confIf you have already installed ports locally, then you might build gitup from source:
# make -C /usr/port/net/gitup install clean # cp -aiv /usr/local/etc/gitup.conf.sample /usr/local/etc/gitup.confKeeping your ports copy up to date is trivial:
# gitup portsgitup will not proceed if a .git directory exists. Thus, if you have cloned your copy of the ports tree using the official git client, then remove /usr/ports/.git first:
# rm -r /usr/ports/.git
[2024-01-08] LogBlitz version 16 can be served by a WSGI server, too.
[2023-12-20]
[2023-12-16] New version of pocgi.py fixes two bugs: Standard input was not opened in binary mode, and parsed values were not comparable to strings.
# pkg install git # git clone --depth 1 https://git.FreeBSD.org/ports.git /usr/portsTo keep the ports tree tidy afterwards, I use these 3 commands for now:
# cd /usr/ports # git pull --depth 1 # git reset --hard origin # git clean -dfx
[2023-12-08]
[2023-12-03] pocgi.py (plain old cgi) aims to be a replacement for Python's cgi library, which was deprecated in 3.11 and will be removed in 3.13 (see PEP 594).
[2023-11-25] formdata.py shows how to do multipart/form-data HTTP POST uploads with Python's urllib only.
[2023-11-05] Benchmarked two additional devices for video encoding speed.
[2023-09-16] I benchmarked my graphic cards for video encoding speed and kept the results as my personal reference.
[2023-09-15]
[2023-09-13]
$ sqlite3 /tmp/counter.sqlite "CREATE TABLE IF NOT EXISTS counter (id INT NOT NULL PRIMARY KEY); INSERT INTO counter SELECT 0 WHERE (SELECT COUNT(*) FROM counter)=0;"
#!/usr/bin/python import sqlite3 con = sqlite3.connect("/tmp/counter.sqlite", isolation_level=None) cur = con.cursor() (next_id,) = cur.execute("UPDATE counter SET id=id+1 RETURNING id").fetchone() con.close() print(next_id)Perl counterpart:
#!/usr/bin/perl -w use strict; use warnings; use DBI; my $dbh = DBI->connect("DBI:SQLite:dbname=/tmp/counter.sqlite", "", "", { AutoCommit => 1, RaiseError => 1 }); my ($next_id) = $dbh->selectrow_array("UPDATE counter SET id=id+1 RETURNING id"); $dbh->disconnect(); print "$next_id\n";Of course you have to initialise the database and the counter table upfront, e.g. by using the sqlite3 command line tool:
$ sqlite3 /tmp/counter.sqlite "CREATE TABLE counter (id INT NOT NULL PRIMARY KEY); INSERT INTO counter VALUES (0);"A bonus variant written in C:
/* Compile with: * cc -W -Wall -O3 -pipe -s -o counter counter.c -lsqlite3 */ #include <stdio.h> #include <err.h> #include <sqlite3.h> int main () { const char sql[] = "UPDATE counter SET id=id+1 RETURNING id"; sqlite3 *db; sqlite3_stmt *stmt; int next_id; if (sqlite3_open("/tmp/counter.sqlite", &db) != SQLITE_OK) errx(1, "sqlite3_open: %s", db ? sqlite3_errmsg(db) : "Generic SQLite error"); if (sqlite3_prepare_v2(db, sql, sizeof(sql), &stmt, NULL) != SQLITE_OK) errx(1, "sqlite3_prepare_v2: %s", sqlite3_errmsg(db)); if (sqlite3_step(stmt) != SQLITE_ROW) errx(1, "sqlite3_step: %s", sqlite3_errmsg(db)); next_id = sqlite3_column_int(stmt, 0); if (sqlite3_finalize(stmt) != SQLITE_OK) errx(1, "sqlite3_finalize: %s", sqlite3_errmsg(db)); if (sqlite3_close_v2(db) != SQLITE_OK) errx(1, "sqlite3_close_v2: %s", sqlite3_errmsg(db)); printf("%i\n", next_id); return 0; }
[2023-09-09]
[2023-09-08]
$ git --no-pager log -1 --until "2023-06-22" $ git --no-pager log -1 --until "last year"You can then use the commit hash from the above outputs for further processing, e.g.:
$ git diff --stat <commit hash>
import datetime, zoneinfo print(datetime.datetime.now().astimezone(zoneinfo.ZoneInfo("Europe/Lisbon")).isoformat())
{ local $ENV{TZ} = "Europe/Lisbon"; print scalar localtime(); }
TZ="Europe/Lisbon" date
setenv TZ "Europe/Lisbon" date unsetenv TZ
/* * compile with: * cc -W -Wall -O3 -s -pipe -o dtlisbon dtlisbon.c */ #include <stdlib.h> #include <err.h> #include <time.h> #include <stdio.h> int main () { char *oldtz, datetime[64]; time_t now = time(NULL); oldtz = getenv("Europe/Lisbon"); if (setenv("TZ", "Europe/Lisbon", 1)) err(1, "setenv"); strftime(datetime, sizeof(datetime), "%F %T %Z", localtime(&now)); puts(datetime); if (oldtz && setenv("TZ", oldtz, 1)) err(1, "setenv"); return 0; }
SELECT now() at time zone 'Europe/Lisbon';
[2023-08-09] rrdquery.pl version 4 (obviously) comes with version numbering, an example section, and fixes two bugs, where a "IS NULL" predicate wasn't parsed correctly and an aggregate function was always expected.
[2023-08-03] dnskey2id.pl shows how to derive the key id for a given DNSSEC dnskey in Perl. Inspired by a Python snippet I found on https://lists.isc.org/pipermail/bind-users/2010-October/081724.html.
[2023-07-27] LogBlitz version 15 reduces the number and size of http cookies, and displays the number and size of the selected logfiles.
[2023-05-23] ampctrld version 2 lowers the number of addresses to listen on to a maximum of 16.
# ifconfig vtnet0 vhid 31 advskew 100 peer 192.168.0.29 pass foobar 192.168.0.31/24 aliasOf course you have to load the carp module before: kldload carp. Then, ifconfig vtnet0 prints:
# sysrc kld_list+=carp # sysrc ifconfig_vtnet0_alias0="vhid 31 advskew 100 peer 192.168.0.29 pass foobar 192.168.0.31/24"
[2023-04-25] New version of kvmlib allows you to use a different QEMU executable than qemu-system-x86_64, and exits with an error message if you use the cdrom command without a path to an ISO file.
L /var/tmp - - - - /tmpFor further details, you'll have to read the man page of systemd-tmpfiles.
# su - cyrus % sbin/reconstruct -nrGR user.username.#calendars % sbin/reconstruct -rGR user.username.#calendars