Sunday, May 06, 2007

We're Two Weeks out from UbuntuTrinux 0.1 (or how I defeated Unix98 ptys)

So the big new feature in the latest (050607) ubuntutrinux snapshot release is a working SSH2 server (courtesy of Dropbear.) Like Busybox, it has added a lot of features since I last built it back in 2003. There is now a small SSH client (ssh is symlinked to dbclient) and it includes some version of scp from OpenSSH. So scp (at least to Trinux boxes) works as well.

As the title suggests, we're getting close to an initial (0.1) release. I'm this close to finalizing the feature list. If you followed the link you see that goal for the 0.2 release is finishing the .yaml configuration file and 0.3 an IOS-like shell using the Ruby Cmd module. But back to Dropbear...

For others that might be want to include it (or get the Busybox telnetd server working) in a small distro, the key (but not terribly difficult) technical hurdle to overcome is to ensure the kernel had Unix98 pseudoterminal support and that the device files are present. I had the former, but not the latter.

Basically you need kernel support, the "multiplexer device" (/dev/ptmx), and a /dev/pts directory as you can see below:

trinux# ls -al /dev/ptmx
crw-rw-rw- 1 root root 5, 2 May 7 12:02 /dev/ptmx
trinux# ls -al /dev/pt
/dev/ptmx /dev/pts/
trinux# ls -al /dev/pts
drwxr-xr-x 2 root root 0 May 7 12:01 .
drwxr-xr-x 3 root root 0 May 7 12:01 ..
crw--w--w- 1 root root 136, 0 May 7 12:02 0
trinux# cat /proc/config.gz | gunzip | grep PTY
CONFIG_UNIX98_PTYS=y
CONFIG_LEGACY_PTYS=y
CONFIG_LEGACY_PTY_COUNT=256
The device files with the major number of 136 are created dynamically for each pair. The Linux Text Terminal Howto has good info on this. The kernel config file in /proc is nice, huh. I wonder if the BSDs have something like that. I doubt it.

And the dropbear logs show that I have a little more work to do but it works:


May 7 12:01:50 trinux authpriv.warn dropbear[1099]: Failed reading '/etc/dropbear/dropbear_rsa_host_key', disabling RSA
May 7 12:01:50 trinux authpriv.info dropbear[1100]: Running in background
May 7 12:02:08 trinux authpriv.info dropbear[1105]: Child connection from 10.0.2.2:51769
May 7 12:02:14 trinux authpriv.notice dropbear[1105]: password auth succeeded for 'root' from 10.0.2.2:51769
May 7 12:02:14 trinux authpriv.err dropbear[1106]: open /dev/tty failed - could not set controlling tty: No such file or directory
May 7 12:02:14 trinux authpriv.warn dropbear[1106]: lastlog_perform_login: Couldn't stat /var/log/lastlog: No such file or directory
May 7 12:02:14 trinux authpriv.warn dropbear[1106]: lastlog_openseek: /var/log/lastlog is not a file or directory!

No comments: