20090805
git-daemon on debian vserver
Annoyingly git-daemon-run requires runit on debian, but runit will fail to install properly in a debian vserver because it doesn't have init.
One solution is to reconfigure vserver to use plain init style.
However I didn't want to this because I don't want to take down my vserver just yet. So here is the required line for /etc/inetd.conf:
git stream tcp nowait nobody /usr/bin/git git daemon --inetd /var/git-repos
Cheers,
Steve
20090607
Dealing with rkhunter warnings
rkhunter often warns on file property changes after upgrade and such, and sometimes you just aren't sure whether it is due to recent upgrades, or because you really were compromised. The following script was written to compare the checksum of all files rkhunter warns about against the originals in a debian repository.
The latest version of this is available in my script.git respos.
#!/bin/bash
desc="
This script will verify whether files for which rkhunter has logged a
warning for is still valid. It does this by finding which debian package
it came out of, and downloads them, unpacks them, then checks
the checksums.
Run it by supplying a rkhunter log file as first argument
"
HASHER="sha256sum"
IFS="
"
function find_suspect_files
{
echo "parsing $1 for suspect files" 1>&2
grep -1 Warning "$1"| grep File | sed 's|.*File: ||'
}
function find_packages
{
echo "finding packages" 1>&2
for suspect_file in $1
do
package=$(dpkg -S $suspect_file|awk '{print $1}'|sed 's/.$//')
echo "suspect file $suspect_file found in $package" 1>&2
echo $package
done
}
function make_aptitude_args
{
echo "generating aptitude arguments" 1>&2
for package in $1
do
version=$(dpkg -p $package | grep Version | awk '{print $2}')
echo $package=$version
done
}
function cleanup
{
echo "cleaning up"
popd
rm -rf tmp
exit $1
}
function setup
{
echo "setting up"
rm -rf tmp
mkdir tmp
pushd tmp
}
if [ $# -ne 1 ];
then
echo "$desc"
exit 1
fi
suspect_files=$(find_suspect_files "$1")
packages=$(find_packages "$suspect_files" | sort | uniq)
if [ -z "$packages" ];
then
echo "***WARNING****"
echo "No packages contain any of the suspect files!"
cleanup 1
fi
aptitude_args=$(make_aptitude_args "$packages")
setup
echo "downloading packages"
aptitude download $aptitude_args 1>/dev/null
if [ $? -ne 0 ];
then
echo "aptitude download failed!"
echo "args=$aptitude_args"
cleanup 1
fi
echo "unpacking"
for deb_file in *.deb
do
ar -x $deb_file
tar zxf data.tar.gz
rm -rf data.tar.gz control.tar.gz
done
for suspect_file in $suspect_files
do
if [ ! -f ".$suspect_file" ]
then
echo "***WARNING****"
echo "For some reason .$suspect_file does not exis!"
continue
fi
echo -n "verifying $suspect_file... "
suspect_sum=$($HASHER $suspect_file | awk '{print $1}')
clean_sum=$($HASHER ".$suspect_file" | awk '{print $1}')
if [ $suspect_sum == $clean_sum ];
then
echo "OK"
else
echo
echo "***WARNING****"
echo "Checksum mistmatch for $suspect_file!!!"
echo "Should be: $clean_sum"
echo "Is: $suspect_sum"
fi
done
cleanup
Cheers,
Steve
20080920
A relatively pain free Linux/OS X VNC setup
Ever since I got my 2nd monitor, I been using VNC to work on my laptop. Leopard's inbuilt VNC server isn't really VNC compliant, and has many issues when used with a normal VNC client. I have found Vine server to be an excellent replacement. The client side is a little interesting. RealVNC didn't work too well for me, in that often the screen would stop responding, or it would not receive key events. The best setup I have found is to use tightvnc with the following Vine server settings:
- Devices
- Keyboard Layout: US
- Keyboard Events: User Session Events
The client and server will happily share the clipboard if you enable it. Settings are accessed via F8 in the client, and via Preferences in the server. The client is smart enough to synchronise clipboards only when it loses focus - which would be you switching away to say, paste a url into firefox. All in all it is a fairly painless experience.
Cheers,Steve
Labels: computer, howto, linux, oss, osx, software
20080731
iwconfig not setting essid?
If iwconfig wlan0 essid blah is seemingly not working when connecting to a open wireless network, then try
iwconfig wlan0 essid blahiwconfig wlan0 key openiwconfig wlan0 enc off
The above seems to work for me by turning off encryption. It would appear with encryption enabled, iwconfig won't work for a open network because of some magic or other. If it still doesn't work, then try stick the above in your /etc/network/interfaces and prefix the commands with "wireless-", like so:
allow-hotplug wlan0
iface wlan0 inet dhcp
wireless-essid blah
wireless-key open
wireless-enc off
Hope this help some people, it drove me nuts!
Cheers,Steve
Labels: computer, linux, software
20080724
grub, xfs, debian
Running grub-install with a XFS partition will likely fail - there is a reason lilo is used when XFS is root! The issue is grub-install creates the stage files in /boot/grub, which grub then expects to find when it accesses the disk directly using its own file system drivers. For most file systems sync is sufficient to force this to be true, but not with XFS - unless grubs's XFS drivers replays the journal, grub won't find the files. The detailed why of this is covered in this thread. To get around this, one needs to effectively replace sync with mount -r -o remount /; mount -w -o remount /. A quick a nasty way to get grub going with XFS partition is as follows:
- init 1 # need single user mode to be able to remount root
- cp /usr/sbin/grub-install /tmp # make a copy of grub-install to butcher
- vim /tmp/grub-install
- # now butcher grub-install as follows:
- # 1. find the line that says "Sync to prevent GRUB from not finding stage files
- # 2. deleted everything after sync
- # 3. add exit 0 after sync for good measures
- /tmp/grub-install # invoke our amputated grub-install to just produce the stage files
- mount -r -o remount / # flush everything by mount as read only
- mount -w -o remount / # remount since grub needs it to be rw
- grub # invoke the grub shell
- root (hdx,y) # manually specify the disk x partition y where /boot/grub/* is located
- setup (hdx) # install grub into the disk x's MBR. DO NOT specify a partition number, XFS's sector 0 is NOT reserved for boot loaders!!
- quit # exit grub
- reboot # should work now
Cheers,
Steve
Labels: computer, linux, oss, software
20080716
unoffical libfg repository
I have set up an unofficial git respository for libfg patches and new swig generated python interface, as Gavin Baker (the author) appears to be busy with other things. This is a maintance only repository as far as libfg goes - I don't plan on adding any more features (since all the ones I need are there already). I will however work to produce a more pythonic interface to libfg, as the swig generated interface is a straight port of C api into Python.
Currently the repository contains the following fixes and enhancements:
- RGB565 and RGB555 patch by Adalbert Prokop
- fg_new_compatible_frame patch by echoline
- mmap fix by me
- swig generated Python interface by me
If you have a patch against libfg, please post it at the libfg project's page first, and then to me if Gavin does not respond. I do not intend to take over development of libfg, and it is my hope Gavin will in the future make this obselete/redundant.
Cheers,
Steve
Labels: c, code, computer, linux, oss, python, software
20080505
Death by *nix
20080328
eeepc, likes and dislikes
Likes:
- nice and small
- all the hardware works, including sleep/suspend
- runs debian based OS by default
- can run an external monitor at decent resolution
Dislikes:
- uses fastinit which only boots into single user mode, so user "user" is always logged in. Endless frustration playing with X11 startup in vain to get a multiuser login screen
- when kmixer shows a speaker with a cross on top, it means built in speakers will be used. When it is a speaker with no cross on top, it means headphone jack will be used. Talk about counter-intuitive.
- keyboard truly sucks
Cheers,
Steve
Labels: computer, linux, oss, rant, software
20080215
Allow only virtual users to login to proftpd
Locate the AuthOrder line in your proftpd.conf and change it to:
AuthOrder mod_auth_file.c
Cheers,
Steve
20080119
Programming 16F84As with piklab-prog and JDM programmer
Finally got around to using piklab-prog to program my surplus 16F84As. The command line options are a little confusing, so here is what I used:
piklab-prog -d 16F84A -t /dev/ttyS0 -p direct -h 'JDM classic' -c program led_test.hex
For some reason there is a hardware option which doesn't work for me and is not documented in the man page. piklab-prog seems to magically detect that I am using a JDM classic programmer, so all is well :-)
Cheers,
Steve
Labels: 16f84, electronics, linux, pic
20080107
Finally, PIC under Linux made Easy
I have been looking for software to work with my PIC-PG2 programmer under Linux for a while now. Previously I have been using windows and PICPROG which while nice, still involved messing with windows and stuff. The situation back then (around 2006) was bleak - there were no up to-date and actively maintained Linux software for PIC developers. Now there is.
PikLab is a fantastic piece of work which does for Linux what MPLAB does for Windows. Big thanks to Nicolas Hadacek and Alain Gibaud and all contributors for producing a much needed piece of software.
Cheers,
Steve
20070621
The importance of backspace
Update - 23/6/07: Turns out, screen doesn't like TERM=xterm-color. Setting TERM to xterm in my .bash_profile fixed everything - none of the hacks below is required! Incidentally, if you want unicode support for a particular language in irssi, you need to have the locales for that language installed - at least Chinese characters didn't work for me until I installed them on debian. Then restart irssi and the screen session it is running in for good measures.
Life is all about the small things. Whilst we have big things to occupy ourselves with, the small things is what make life worth living.
One of these small things is backspace. For me, backspace is important because I am the kind of person who needs to fix what I type a lot - be it code, messages, articles. When backspace doesn't work, my inner child cries.
When I switched to using iTerm, my backspace stopped working in irssi. Thankfully a kind soul posted the solution to this problem: modify the mapping for backspace in your keyboard profile (Bookmarks->Manage Profiles...) so it sends a hexadecimal 0x8.
Horrah!
Happiness, until I tried to edit something in vim. backspace deleted stuff in vim. Inner child sheds more tears. Googling revealed some recent changes to vim in version 4 which caused this. Solution is to append the following to vimrc:
inoremap ^? ^H set t_kb=^H set t_kD=^?
Happy inner child again.
Cheers,
Steve
Labels: linux
