Purpose

Mainly documenting a few things I don't want to forget. Perhaps it's useful to others as well.

If you came here for FISHWORKS (which I'm pretty sure you didn't), click here

tisdag 14 december 2010

Nokia N900 Maemo key remap

Issue: The bar symbol is missing on the N900 keyboard:
bar symbol ("|"):
File: /usr/share/X11/xkb/symbols/nokia_vndr/rx-51

In section:
xkb_symbols "nordic_base" {

Change:
key { [ c, C, bar, sterling ] };

Issue: The N900/Maemo sends Keypad_Enter, not Enter. Causing various things to fail on a remote tmux ssh session:
.tmux.conf: bind -n KPEnter send-keys Enter

Thanks hakan. Source: http://www.madhacker.org/computerincar.htm

måndag 13 december 2010

Nokia N900 Maemo Telenor fMMS Settings

Nokia N900
Maemo 5
Version: 20.2010.36-2
fMMS 1.3.0

The fMMS Settings that work on my Nokia N900 with Swedish provider Telenor are:

Internet connection settings
Access point name: services.telenor.se
MMSC: http://mms/
User name:
Password:
HTTP proxy: 172.30.253.241
Port number: 8799

Network mode: Havoc

fredag 5 november 2010

Apache PHP TypesConfig and the Upload file security risk

Reading the Bacula Mailing List I stumbled upon an informative blog and happened to read one of the posts a bit more tentatively than the others:
How Apache PHPs setting exposes a security risk


Now, reading that Apache, when configured with AddType or AddHandler, will execute any file with ".php" anywhere in it's filename, I was a bit chocked.

First I verified it on my server which is a Debian Lenny with Apache2 and php5.

I created the files somewhere in my webroot:
1. foo.php
2. foo.php.bar

Both files execute by the php engine.

But it gets worse...

I then removed EVERYTHING regarding php from my Apache2 configuration and restarted the webserver - Obviously, I would get plain ascii source code output this time.

Continuing I readded "LoadModule php5_module /usr/lib/apache2/modules/libphp5.so".

What now? Both files still execute by the php engine! Even without AddType, AddHandler or SetHandler.

The PHP Manual talks about a solution to use instead of AddHandler:
http://se2.php.net/manual/en/install.unix.apache2.php

Action Point 8:
Tell Apache to parse certain extensions as PHP. For example, let's have Apache parse .php files as PHP. Instead of only using the Apache AddType directive, we want to avoid potentially dangerous uploads and created files such as exploit.php.jpg from being executed as PHP. Using this example, you could have any extension(s) parse as PHP by simply adding them. We'll add .php to demonstrate.
And it includes a snippet for a suggested practice:
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
Now, atleast in my case this doesn't help since a simple LoadModule activates the awesomeness of *.php*.

This is, I found, due to the Apache TypesConfig directive.
Debian Apache include: "TypesConfig /etc/mime.types" if mod_mime is loaded.
Contrary to the Apache documentation on TypesConfig, the extensions in that file are not actually extensions.... they're substrings!

My solution:
/etc/apache2/conf.d/php-safer.conf:
<FilesMatch "[^(\.php)]$">
php_admin_flag engine off
</FilesMatch>

torsdag 9 september 2010

because a quiet mysql import is no fun

time pv -c -N gz /tmp/mysqldump.sql.gz | gunzip -c | pv -c -N unpacked | perl -pe 'print STDERR ($_) unless m/^INSERT/i' | mysql-main

...
unpacked: 611MB 0:02:20 [4.41MB/s] [ <=> ]
gz: 69.6MB 0:02:20 [ 469kB/s] [> ] 0% ETA 9:56:01
...

måndag 6 september 2010

tisdag 31 augusti 2010

Todays fulhack: On Call Diversion script for Nagios

A little concept hack that'll be used in Nagios to set diversion for the on call number as well as control who gets sms and when.

(c) 2010 Fulhack Industries

The divert method in this one is done through Telenor but it could just as well be through a GSM modem or a Nokia/Ericsson phone connected via USB.
https://minasidor.telenor.se/


tisdag 13 juli 2010

ircd-seven start scripts

ircd:

#!/bin/bash
#
# /etc/rc.d/init.d/ircd
#
# IRCd-seven
# Script to start and stop IRCd-seven
# Author: Mikael Fridh
#
# chkconfig: 2345 90 10
# description: IRCd-seven is an IRC daemon
# processname: ircd
# config: /usr/local/ircd/etc/ircd.conf

# Source function library.
. /etc/init.d/functions

# Defaults
IRCD_USER=ircd

# Pull in settings:
[ -f /etc/sysconfig/ircd ] && [ . /etc/sysconfig/ircd ]

start() {
echo -n "Starting ircd: "
daemon --check ircd --user ${IRCD_USER} /usr/local/ircd/bin/ircd
echo
touch /var/lock/subsys/ircd
return 0
}

stop() {
echo -n "Shutting down ircd: "
killproc ircd
echo
rm -f /var/lock/subsys/ircd
return 0
}

case "$1" in
start)
start
;;
stop)
stop
;;
status)
status ircd
;;
restart)
stop
start
;;
reload)
echo -n "Sending ircd the HUP signal ..."
killproc ircd "-HUP"
echo
;;
condrestart)
[ -f /var/lock/subsys/ircd ] && restart || :
;;
*)
echo "Usage: ircd {start|stop|status|reload|restart|condrestart}"
exit 1
;;
esac
exit $?

torsdag 1 juli 2010

Wrote an article (howto) on incorporating vmware view in Ubuntu LTSP

I wrote this a couple weeks ago;
http://help.ubuntu.com/community/UbuntuLTSP/VMWareViewVDI

In short; Allows you to create a thin client out of any commodity hardware PC, for use with a Vmware View Server.

LTSP is a really nice project... kudos to ThinStation, but I got way better performance out of VMWare View on Ubuntu than on ThinStation... mainly due to poor graphics driver support in ThinStation.

onsdag 21 april 2010

xorg.conf ModeLine for HP2159v

So I got a new Desktop Computer (Dell Precision 380) and a Monitor: HP2159v, a 21.5" Full-HD monitor, it's perfectly fine, nice picture quality. Downside - the only connector is VGA, no DVI, no HDMI. I'm happy with whatever I get since I've exclusively been using laptops for 6 years now.

This config got 1920x1080 resolution going for me:

Section "Monitor"
Identifier "HP2159v"
# 1920x1080 59.96 Hz (CVT 2.07M9) hsync: 67.16 kHz; pclk: 173.00 MHz
HorizSync 24.0 - 94.0
VertRefresh 50.0 - 76.0
Modeline "1920x1080" 173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync
EndSection

Section "Screen"
Identifier "Default Screen"
Monitor "HP2159v"
Device "Configured Video Device"
DefaultDepth 24
SubSection "Display"
Depth 24
Modes "1920x1080" "1024x768"
EndSubSection
EndSection

Section "Module"
Load "glx"
EndSection

Section "Device"
# nVidia Corporation NV41GL [Quadro FX 1400] (rev a2)
Identifier "Configured Video Device"
Driver "nvidia"
Option "NoLogo" "True"
EndSection

söndag 21 februari 2010

Stream sound from Windows to Linux with LiveInCode and PulseAudio

My OS's: Debian 5.0 Lenny / Windows Vista Home Premium.

Debian 5.0 (Lenny):
1. sudo apt-get install pulseaudio alsa-utils
2. sudo alsamixer -Dhw crank volume, unmute ...
3. pulseaudio --log-target=stderr
4. alsamixer -Dpulse crank, unmute ...


Windows Vista, configure Recording Mixer.:
1. Go to Recording Devices -> Recording.
2. Right click a free area in the recording device list -> mark "Show Disabled Devices"
3. Now enable "Stereo Mix".

Windows Vista, the Levels I chose for minimum distortion.
Click Properties on "Stereo Mix". Choose "Levels". Crank Stereo Mix to 100.
Set the Main output Level to 50.
Next, I jacked a headphone jack (3.5mm) into my laptops headphone outlet in order to physically mute it.

Windows Vista, software:
1. Install Cygwin.
2. Install LineInCode: http://liveincode.rm.pp.ru/
3. Put lineco.exe in your path for simplicity.
4. Launch cygwin, run linco.sh after putting the following in it:

linco.exe --flag-files -B 16 -C 2 -R 48000 | ssh mikaelf@host.internal.example.com "pacat --rate=48000 --playback"

Now all your audio is "routed" to your Linux Machine!
Note: I used SSH public keys for the ssh connection.

Next, wrap the linco.exe line in a while [ 1 ]; do linco ...; sleep 60; done to make it autorestarting in case you lose connection to your sound server.

Things to note:
You might be using 44.1Khz rate all over, make sure you adapt your settings and scripts so the rate matches on both hosts.

References: