The Daily Build

Icon

Software Development, version 3.0

Tightening UFW Firewall Rules to Limit SSH Access

The auth.log on one of my servers (really, on all of the servers I have access to) is full of stuff like this: Dec 8 03:19:33 localhost sshd[4718]: User root from 10.1.2.3 not allowed [...] Dec 8 03:19:35 localhost sshd[4721]: Invalid user db2inst1 from 10.1.2.3 Dec 8 03:19:38 localhost sshd[4723]: User root from 10.1.2.3 not [...]

Read the rest of this entry »

Using SSH for IPv6-enabled HTTP Proxying

My ISP has apparently made no progress whatsoever with IPv6, but I’ve got an IPv6 enabled VPS. SSH makes it trivial to use that VPS as a SOCKS5 proxy. Just do: ssh -D 8080 myvps.example.com Then set your browser’s SOCKS proxy to localhost:8080. In Firefox on Linux, this is Edit > Preferences > Advanced > [...]

Read the rest of this entry »

Use Linux to build win32 installers for Python apps

A python-based project I’m working on has a win32 user that I need to support. Until yesterday I’ve been moving to a win32 laptop in order to run python setup.py bdist_wininst so I can produce a self-installing executable. Then I discovered how trivial it is to use wine to do the job: Install wine. (sudo [...]

Read the rest of this entry »

An Interesting pid File Race

ISC’s dhcpd uses this code to check for an already-running daemon: /* Read previous pid file. */ if ((i = open (path_dhcpd_pid, O_RDONLY)) >= 0) { status = read (i, pbuf, (sizeof pbuf) – 1); close (i); if (status > 0) { pbuf [status] = 0; pid = atoi (pbuf); /* If the previous server [...]

Read the rest of this entry »

Hassle Free Way to Kill Sudo’d Jobs

Every now and then I have to run a foreground job under sudo that doesn’t want to die when I hit ^C. Then it’s a hassle to ^Z, get the pid of the sudo job, and sudo kill that pid. So I wrote a little script (or a template for scripts) that runs the sudo [...]

Read the rest of this entry »

Using Python’s ctypes to Call Into C Libraries

The ctypes module makes loading and calling into a dynamic library incredibly easy.

Read the rest of this entry »