home.dataforce.org.uk Dataforce's Blog

1Jan/110

Happy New Year

Posted by Dataforce

<Obligatory happy new year post goes here>

Filed under: General No Comments
21Nov/102

A tale of two monitors

Posted by Dataforce

So, a while back (just under 3 years ago) I obtained 2 of Hyundai’s W240D monitors. These monitors had (I believe) PVA panels and worked fine for most of their life so far.

A while back they both developed a problem, as evident in the video below:

So, as they were still under warranty I contacted Hyundai/RepairTech and arranged for these to be repaired. Hyundai sent the parts to RepairTech, who collected the units, repaired them and sent them back.

And this was the result:

So quite obviously they have come back with different panels from each other – but also different panels than I sent them in with.

One of them now has a TN panel, and one of them now has a panel that flickers when being videoed.

I sent the TN panel back (as it was clearly no where near what I sent in) and after a while it came back – still with a TN panel, but without a working stand. I sent it back again, and after eventually getting Hyundai involved I now have it back with a PVA panel.

The problem I find now, is that the second one (the one I had considered to be fine after the initial repair) is clearly not using the same panel technology, after searching and discovering the service menu, it became obvious why.

As you can see one of them has an RTC control, for TN or IPS panels, as its not a TN panel we can assume that is is an IPS panel.

So now I have 2 monitors, which previously were able to show images identically, that now show everything (subtly) differently – which isn’t what I wanted. (I bought 2 at the same time from the same place in order to get them the same)

I’ve invested in a colour calibrator to try and bring them closer together, but I know I own’t be able to get them the same. The PVA monitor also has no ability to change the colour values on the monitor itself when using DVI and not in service mode (Video).

For most people, there wouldn’t be any problem with this – not everyone cares about panel technology, or that 2 monitors side by side are the same (not everyone even has 2 of the same model side-by-side anyway), but now I find myself with a dilemma, that needs to be resolved quickly. (The warranty period on the IPS monitor runs out on 2nd December)

- I could just accept it and move on and let it annoy me. (How often do I have both monitors showing things that are similar enough for the differences to be obvious?)

- I could contact RepairTech again and request that they swap out the one with an IPS Panel for one with a PVA Panel (Is it really acceptable during a repair to fundamentally change the product? And do I really want the whole hassle of dealing with RepairTech again?)

- I could sell both of the monitors and buy 2 new different identical monitors (This of course means finding acceptable replacements which is a chore in itself)

Choices, Choices, Choices.

I think I’m going to contact RepairTech to try and get this sorted properly, I had PVA panels, I should have PVA panels, even if it means dealing with RepairTech again. I can then look at the option of replacing the 2 monitors in the future when they have to be replaced, rather than doing it just for the sake of getting them to be the same.

Filed under: General 2 Comments
24Sep/100

Greasemonkey script for hp.com forums

Posted by Dataforce

If you’ve ever visited the hp.com forums you’ll know that any links in the post get enclosed by a call to “javascript:openExternal(”)” in the href rather than doing it properly in onClick. Amongst other things, this breaks the ability to middle click to open links in new tabs.

This finally annoyed me enough today and as a result, I now use the following greasemonkey script:

// ==UserScript==
// @name           Stupid HP.COM Links
// @namespace      http://shanemcc.co.uk/
// @include        *hp.com*
// ==/UserScript==

var a = document.getElementsByTagName("A");
for (var i = 0; i < a.length; i++){
	var href = a.href;
	href = href.replace(/javascript:openExternal\('([^']+)'\)/i, '$1');

	a.href = href;
}

This will make the links no longer have the call to openExternal around them, and thus make them middle-click friendly.

Filed under: General No Comments
10Aug/102

Ubuntu on HP Compaq Mini 311c-1030SA

Posted by Dataforce

311c 1030SA Ubuntu on HP Compaq Mini 311c 1030SA

HP Compaq Mini 311c-1030SA

I recently purchased a HP Compaq Mini 311c-1030SA with nvidia ION and built in 3G, unfortunately the 3G card is a “UN2400″ which isn’t supported right out of the box as it requires proprietary firmware.

This post is mostly notes for myself on getting the UN2400 3G card inside it working enough to use.

This post assumes that the netbook is running ubuntu maverick (which is currently in alpha but seems to work just fine) as it has gobi_loader as a package and a kernel which supports it.

When I installed ubuntu on here, I kept the original windows partition in case it was needed. I’m glad I did otherwise this would have been more awkward as some files from the windows installation are needed to get this working.

Before doing anything, boot the windows partition and connect to 3G from the HP Connection manager (This generates some log files which we need). Also change the settings on the 3G card not to turn off on shutdown. (Not sure if the last bit is needed but I did it anyway from reading other posts online about this card.)

Now back in ubuntu, lets make this work:

# Install gobi-loader
sudo apt-get install gobi-loader

# Create missing directory
sudo mkdir -p /lib/firmware/gobi

# Use full paths for gobi_loader
sudo sed -i 's@"gobi_loader@"/lib/udev/gobi_loader@' /lib/udev/rules.d/60-gobi.rules

# Mount windows partition
sudo mkdir /mnt/windows
sudo mount /dev/sda1 /mnt/windows

# The HP Connect software comes with some pppd and chat scripts already for us.
sudo cp "/mnt/windows/Documents and Settings/All Users/HP/HPCM/WWAN/ppprc" /etc/ppp/peers/hpcm
sudo cp "/mnt/windows/Documents and Settings/All Users/HP/HPCM/WWAN/chat" /etc/ppp/hpcm-chat

# Update file path and add us to the dip group
sudo sed -i 's@~/chat@/etc/ppp/hpcm-chat@' /etc/ppp/peers/hpcm
sudo usermod -a -G dip `id -nu`

# Find which images were push to the card so we can copy them
sudo iconv --from-code UTF-16 --to-code UTF-8 "/mnt/windows/Documents and Settings/All Users/Application Data/QUALCOMM/QDLService2k/QDLService2kHP.txt" | grep -i "sending image"

This produces something like:

08/04/2010 23:09:55.093 [01840] QDL sending image file: C:\Program Files\Qualcomm\Images\HP\UMTS\AMSS.mbn
08/04/2010 23:10:00.281 [01840] Sending image file: C:\Program Files\Qualcomm\Images\HP\UMTS\Apps.mbn
08/04/2010 23:10:02.046 [01840] Sending image file: C:\Program Files\Qualcomm\Images\HP\4\UQCN.mbn

Copy the images referenced in the log file:

sudo cp /mnt/windows/Program\ Files/QUALCOMM/Images/HP/UMTS/amss.mbn /lib/firmware/gobi/
sudo cp /mnt/windows/Program\ Files/QUALCOMM/Images/HP/UMTS/apps.mbn /lib/firmware/gobi/
sudo cp /mnt/windows/Program\ Files/QUALCOMM/Images/HP/4/UQCN.mbn /lib/firmware/gobi/

Next you’ll want to stop modemmanager corrupting the firmware whilst it is being uploaded by blacklisting the non-modem version of the device:

echo 'ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="241d", ENV{ID_MM_DEVICE_IGNORE}="1"' >> /lib/udev/rules.d/77-mm-usb-device-blacklist-custom.rules

Now restart the machine so that udev picks up the device and uploads the firmware to it.

Once restarted you should be able to connect to the mobile broadband like so:

pon hpcm

In maverick network-manager understands that this card is a mobile broadband card, so it should be possible to configure it rather than using the ppp/chat scripts from hpcm but using the scripts is a good way to test if it works, and they have in them the information required by network-manager.

I just stick with pon/poff however as NetworkManager on KDE doesn’t seem to even bother to try and connect (I’ve had success with nm-applet tho so I might just use that). In KDE, I’ve found that KNetworkManager isn’t the best at using this device (or my work VPN), so I use nm-applet to configure and use this device unless I don’t have a working X session (a common occurrence when using beta versions of ubuntu!).


Now, for the ION chip.

Firstly install the nvidia driver from jockey (also install the broadcom STA driver for wireless) and restart.

Now:

apt-get install vlc libva1 vdpau-va-driver nvidia-185-libvdpau pkg-config
nvidia-xconfig
shutdown -r now

Now this should be all thats needed, but it doesn’t appear to work right now, VLC video playback of h264 is still unwatchable, I shall keep trying.

Update: Using the final-release version of Maverick I have got this working in VLC. Open VLC, go to Tools > Preferences and go to “Input & Codecs” and enable “GPU Acceleration”.

Update 2: Unfortunately, the final release version of Maverick has This Bug which stops the 3G card working all the time.

Update 3: After updating this netbook to natty, the 3G bug still exists. Unfortunately I have yet to get round to git-bisecting against the kernel, as I don’t fancy compiling multiple kernels on a netbook!

Update 4: As a result of the bug report I submitted about this bug, I was directed to another bug report which described the same problem on a slightly different Qualcomm based device. (Modem requires firmware to be loaded and swaps device IDs before/after, modem works 1 in 20 times, etc). The alternative bug report suggests that modemmanager is actually at fault rather than the kernel.

As such, the following solution does fix the problem:

echo 'ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="241d", ENV{ID_MM_DEVICE_IGNORE}="1"' >> /lib/udev/rules.d/77-mm-usb-device-blacklist-custom.rules

followed by restarting. (In theory, killing modemmanager, loading the firmware and restarting modemmanager will also work)

modemmanager now no longer corrupts the firmware as it is being uploaded and the device is fully usable. I’m still wondering what changed between the kernel 2.6.35-14 and 2.6.35-17 versions in maverick that caused this to stop working, but I’m glad to finally have a solution to this.

I have updated the post to include this step in the process of getting this working.


I did originally get the 3g card working on lucid which was a bit more awkward (it involved recompiling some drivers to allow gobi_loader) but I switched to maverick as it was easier (and also I wanted VLC support for the ION chip which has recently been added in maverick)

I used these instructions to make it work on lucid in the past.

Filed under: General 2 Comments
6Aug/100

Sending SMS with a Huawei E220

Posted by Dataforce

Today I decided to play with an old Huawei E220 I have lying around.

After getting it setup and recognised in linux by following the first 5 steps from http://ubuntuforums.org/showthread.php?p=3656717

After this, restarting udev (`restart udev`) and replugging the device makes it ready to use.

Part of the testing I was doing, was to send text-messages using the device (as a way of sending status messages out-of-band if an internet connection isn’t available.) and threw together this quick script that relies on `expect` and `kermit`:

#!/usr/bin/expect -f
####################################################
# Copyright (c) 2010 Shane Mc Cormack
####################################################
# This script is used to send text messages using
# any AT-Compatible SMS-Capable serial device.
####################################################

if {[llength $argv] < 3} {
	puts "Usage: $argv0 '<device>' '<number>' '<message>'";
	puts "<number> should be in international format.";
	exit 1;
}

set device [lindex $argv 0]
set number [lindex $argv 1]
set message [lindex $argv 2]

set escape "\x1C";

set timeout 25
match_max 100000

puts "Spawning: /usr/bin/kermit -b 9600 -8 -l ${device} -C "set exit warning off,set carrier-watch off,connect,exit""
spawn /usr/bin/kermit -b 9600 -8 -l ${device} -C "set exit warning off,set carrier-watch off,connect,exit"

expect -- "----------------------------------------------------" { send "AT+CMGF=1\r\n" }
expect -- "OK" { send "AT+CMGS="${number}"\r" }
expect -- ">" { send "${message}\032" }

expect -- "OK" {
	puts "";
	send "${escape}";
	send "c"
}

Usage is simple:

[09:51:22] [shane@ShanePc:~/3gsms]$ ./sendSMS.sh /dev/ttyUSB0 "+447XXXXXXXXX" "Test message from CLI"
Spawning: /usr/bin/kermit -b 9600 -8 -l /dev/ttyUSB0 -C "set exit warning off,set carrier-watch off,connect,exit"
spawn /usr/bin/kermit -b 9600 -8 -l /dev/ttyUSB0 -C set exit warning off,set carrier-watch off,connect,exit
Connecting to /dev/ttyUSB0, speed 9600
 Escape character: Ctrl-\ (ASCII 28, FS): enabled
Type the escape character followed by C to get back,
or followed by ? to see other options.
----------------------------------------------------
AT+CMGF=1
OK
AT+CMGS="+447XXXXXXXXX"
> Test message from CLI

+CMGS: 11

OK

[09:51:31] [shane@ShanePc:~/3gsms]$

Perfect.

Filed under: General No Comments
30Jun/100

Dealing with customers

Posted by Dataforce

Ah customers are a great thing, they do give equal parts endless source of entertainment and annoyance, I'm afraid this post is going to be a bit of a rant however.

Having recently (February) changed job I now find myself as Linux Systems Engineer for a local Hosting Company, a job which so far I am really enjoying.

Part of the job is dealing with support for clients who often have no clue about hosting, websites, domains or computers in general - and yet they sell themselves to others as experts in the field. (Their solutions are often copy/pasted websites from elsewhere changed for different information and then they tell their clients to deal with us directly if there is any issues. Bad developer, BAD!

Often I find myself repeating the same thing to a customer who claims to be technically competent (or to a client to relay to their supposedly technical designer.) Obviously officially I have to be polite and professional (which I am) however often one wishes to be able to send an email along the lines of:

Lets assume a fictional customer "Joe User", who has instructed us to contact his "technical" developer, Bob.

Hi Bob,

You do appear to be a bit of a fuckwit.

I relish this opportunity to send you the same information for the 5th time. Maybe we can even try for a 6th?

Once again here I can paste for you the contents of my first email which I sent to Joe and copied you in on:

----------------------------------------
Hi Joe,

Here are your login details for your website:

Server: ftp.someserver.com
Username: JoeUser123
Password: xOe0#aro5f

--
Shane Mc Cormack
----------------------------------------

I hope that maybe this will help you this time, I will keep these details in my clipboard ready for your next email. May I interest you in some "Arse" and "Elbow" labels to assist you in other future endeavours?

--
Shane Mc Cormack

Alas this would almost certainly amount to some kind of disciplinary and/or being fired, which would not be good at all so there will be no (public) calling specific customers as fuckits, despite how true it may or may not be.

It later transpired that this person also then went on to try and FTP on port 22.. A common mistake I'm sure. Even after pasting his FTP Client log files to us he failed to spot this error which we spotted in about 2 seconds.

As with many of our customers, I do feel sorry for anyone who hired this person for anything technical.

Filed under: General No Comments
27Jun/100

WordPress

Posted by Dataforce

I have recently decided to switch this site to use wordpress rather than the custom code that was here before.

This will allow me to edit/post to the site using my phone, which will probably allow me to update it more often.

I am working on migrating everything from the old site to the new site and trying to find a theme I like. Hopefully I will have everything working soon. Should anything be missing that you would like brought back leave a comment and let me know and I'll see what I can do.

Unfortunately for anyone reading this using RSS, I'm afraid the recent posts will duplicate themselves as the IDs in the RSS feed will have changed.

Filed under: General No Comments
3Mar/100

Ident Server

Posted by Dataforce

I recently encountered a problem on a server that I manage where by the oidentd server didn't seem to be working.

Manual tests worked, but connecting to IRC Servers didn't.

I tried switching oidentd with ident2 and the same problem.

After switching back, and a bit of debugging later it appeared that the problem was that the IRC Servers were expecting spaces in the ident reply, whereas oidentd wasn't giving them.

I then quickly threw together an xinet.d-powered ident server with support for spoofing.

First the xinet.d config:

service ident
{
	disable = no
	socket_type = stream
	protocol = tcp
	wait = no
	user = root
	server = /root/identServer.php
	nice = 10
}

Unfortunately yes, this does need to run as root otherwise it is unable to see what process is listening on a socket. In future I plan to change it to allow it to run without needing to be root (by using sudo for the netstat part)

Now for the code itself:

#!/usr/bin/php
<?php
	/**
	 * Simple PHP-Based inetd ident server, version 0.1.
	 * Copyright (c) 2010 - Shane "Dataforce" Mc Cormack
	 * This code is licensed under the MIT License, of which a copy can be found
	 * at http://www.opensource.org/licenses/mit-license.php
	 *
	 * The latest version of the code can be found at
	 * http://home.dataforce.org.uk/index.php?p=news&id=135
	 *
	 * This should be run from inetd, it will take input on stdin and write to stdout.
	 *
	 * By default users can spoof ident by having a .ident file in /home/<username>/.ident
	 * If this is present, it will be read.
	 * It should be a file with a format like so:
	 *
	 * <pid> <ident>
	 * <local host>:<local port>:<target host>:<target port> <ident>
	 *
	 * The first line that matches is used, any bit can be a * and it will always match,
	 * so "* user" is valid. In future more sophisticated matches will be permitted
	 * (eg 127.*) but for now its either all or nothing.
	 *
	 * Its worth noting that <target host> is the host that requests the ident, so if this
	 * is likely to be different than the host that was connected to, then "STRICT_HOST" will
	 * need to be set to false.
	 *
	 * At the moment <local host> is ignored, in future versions this might be changed, so
	 * it is still required.
	 *
	 * Lines with a ':' in them are assumed to be of the second format, and must contain
	 * all 4 sections or they will be ignored.
	 *
	 * Lines starting with a # are ignored.
	 *
	 * There are some special values that can be used as idents:
	 *    ! = Send an error instead.
	 *    * = Send the default ident.
	 *    ? = Send a random ident (In future a 3rd parameter will specify the format,
	 *        # for a number, @ for a letter, ? for either, but this is not implemented yet)
	 *
	 * In future there will also be support for /home/user/.ident.d/ directories, where
	 * every file will be read for the ident response untill one matches.
	 * This will allow multiple processes to create files rather than needing to
	 * lock and edit .ident
	 */

	// Allow spoofing idents.
	define('ALLOW_SPOOF', true);

	// Requesting host must be the same as the host that was connected to.
	define('STRICT_HOST', true);

	// Error to send when '!' is used as an ident.
	define('HIDE_ERROR', 'UNKNOWN-ERROR');

	openlog('simpleIdent', LOG_PID | LOG_ODELAY, LOG_DAEMON);

	$result = 'ERROR : UNKNOWN-ERROR' . "\n";

	$host = $_SERVER['REMOTE_HOST'];

	syslog(LOG_INFO, 'Connection from: '.$host);

	// Red in the line from the socket.
	$fh = @fopen('php://stdin', 'r');
	if ($fh) {
		$input = @fgets($fh);
		$line = trim($input);
		if ($input !== FALSE && !empty($line)) {
			$result = trim($input) . ' : ' . $result;
			// Get the data from it.
			$bits = explode(',', $line);
			$source = trim($bits[0]);
			$dest = isset($bits[1]) ? trim($bits[1]) : '';

			// Check if it is valid
			if (preg_match('/^[0-9]+$/', $source) && preg_match('/^[0-9]+$/', $dest)) {
				// Now actually look for this!
				$match = STRICT_HOST ? ":$source .*$host:$dest " : ":$source.*:$dest";

				$output = `netstat -napW 2>&1 | grep '$match' | awk '{print \$7}'`;

				$bits = explode('/', $output);
				$pid = $bits[0];

				if (preg_match('/^[0-9]+$/', $pid)) {
					$user = `ps -o ruser=SOME-REALLY-WIDE-USERNAMES-ARE-PERMITTED-HERE $pid | tail -n 1`;

					$senduser = trim($user);

					// Look for special ident file: /home/user/.ident this is an ini-format file.
					$file = '/home/'.trim($user).'/.ident';

					if (file_exists($file)) {
						$config = file($file, FILE_SKIP_EMPTY_LINES | FILE_IGNORE_NEW_LINES | FILE_TEXT);
						foreach ($config as $line) {
							// Ignore comments.
							$line = trim($line);
							if (substr($line, 1) == '#') { continue; }

							// Make sure line is valid.
							$bits = explode(' ', $line);
							if (count($bits) == 1) { continue; }

							// Check type of line
							if (strpos($bits[0], ':') !== FALSE) {
								// LocalHost:LocalPort:RemoteHost:RemotePort
								$match = explode(':', $bits[0]);
								if (count($match) != 4) { continue; }

								if (($match[1] == '*' || $match[1] == $source) &&
								    ($match[2] == '*' || $match[2] == $host) &&
								    ($match[3] == '*' || $match[3] == $dest)) {
									syslog(LOG_INFO, 'Spoof for '.$senduser.': '.$line);
									$senduser = $bits[1];
									break;
								}
							} else if ($bits[0] == '*' || $bits[0] == $pid) {
								syslog(LOG_INFO, 'Spoof for '.$senduser.': '.$line);
								$senduser = $bits[1];
							}
						}

						if ($senduser == "*") {
							$senduser = trim(user);
						} else if ($senduser == "?") {
							$senduser = 'user'.rand(1000,9999);
						}
					}

					if ($senduser != "!") {
						$result = $source . ', ' . $dest . ' : USERID : UNIX : ' . trim($senduser);
					} else {
						$result = $source . ', ' . $dest . ' : ERROR : ' . HIDE_ERROR;
					}
				}
			}
		}
	}

	echo $result;
	syslog(LOG_INFO, 'Result: '.$result);
	closelog();
	exit(0);
?>

I welcome any comments about this, or any improvements and hope that it will be useful for someone else.

Filed under: Code, General, irc No Comments
18Aug/093

Images Restored

Posted by Dataforce

With help from the "Wayback Machine" I've restored the majority of the images that were used publically on the site so things should mostly work now.

To clarify on the previous post, I had setup a chroot environment for testing stuff on the server, and had mounted /home inside the chroot aswell as at /home, when I deleted the chroot, it took /home with it.

Filed under: General 3 Comments
6Apr/090

I suck…

Posted by Dataforce

Due to an incredibly stupid mistake on my part, I accidentally managed to `rm -Rf` the /home directory on the server this site is hosted on (and lost about 200gb of data, including everything that was hosted under the home.dataforce.org.uk domain.)

As such this site will probably be horrible broken for some time (logins won't work, changing page style, any images or downloads) until I recover the up to date version of the scripts and as many of the files as possible. (Most of the actual content for the site is stored in mysql so none of that was lost, just the php scripts that pull it all together and anything non-page like).

If you came here looking for something that now gives you a 404, feel free to leave a comment here and I'll see if I can find what you were looking for.

Filed under: Code, General No Comments