Welcome to maniacmartin, the personal site of Martin Smith.
I'm listening to The Gap Band – You Dropped A Bomb on Me

I'm cycling the length of the UK (1000 miles) for charity. Sponsor me now!


    23 December 2007

    Publisher 2000 BorderArt causing instant reboots

    Filed under: Computer — martin @ 4:04 pm

    I have discovered a most annoying bug with Microsoft Publisher 2000’s BorderArt feature.

    It all started when I was making a poster for dad on his Windows XP PC, using his version of Publisher 2000, the Office afterthought desktop publishing application. All of a sudden, dad’s PC rebooted instantly. That is to say it went straight from working to BIOS, with no errors and no visible shutdown sequence. Thinking it was probably a rural power blip, I just reloaded Publisher and remade the poster I had lost. However, by the third instant reboot, I began to see a pattern emerge, and tested it a final time to get some proof.

    Dad has virtually all Office settings on the default for Office 2000 Small Business Edition, and rarely ventures outside of Thunderbird, Firefox, Word and Publisher. He never even got round to working out what Excel does. In Publisher, If you make a rectangle shape, then click Format, Line/Border Style, More Styles…, a dialog box will appear.

    In the BorderArt tab, you can select one of many tacky picture borders for your rectangle.

    Except on dad’s PC, once you scroll about two-thirds of the way down the list of possible BorderArt types, the PC will instantly reboot as if you’ve hit the reset button. No errors, no blue screen of death (thanks to SP2 suppressing one maybe), nothing.

    Unfortunately I cannot do more extensive testing because the reboots are very annoying, and because I don’t have a pile of Windows boxes around to test on. However, I would be very interested to hear if this has happened to anybody else, and into any insights and possible fixes would be much appreciated.

    17 December 2007

    Random Topic Generator

    Filed under: Computer — Tags: — martin @ 1:18 am

    It happens way too often. You’re in an msn conversation with someone who’s really cool, then the conversation runs dry. But you really don’t want it to end. You could be completely random like me, and change the topic if the previous topic runs dry.

    /usr/share/dict/words contains a comprehensive list of wacky words (some that don’t look like real words to me, and many plurals that have apostrophes for no good reason). These could be potential topic ideas. It has many proper nouns, so first we must filter out words beginning with capital letters. Then take a random number, modulo the number of words, and find the nth element in the filtered list

    x=$RANDOM;let x%=`grep "^[:lower:]" /usr/share/dict/words | wc -l`; grep "^[:lower:]" /usr/share/dict/words | head -n$x | tail -n1

    13 December 2007

    Recovering Truncated or Corrupt Tar Archives

    Filed under: Computer — martin @ 8:07 pm

    I was unfortunate enough to use resize2fs to resize an ext3 partition. The result, which at first appeared OK, was a corrupt filesystem.

    Using SSHFS, I mapped ~martin on Andrew’s laptop to /media/sshfs on mine. I then told tar to make an archive of what was on my partition, and save it to the SSHFS. It errored out midway because of the severely corrupted filesystem, but I didn’t think it wouldn’t present a problem because the files in tars are simply stored back to back - it is a very basic archive tool.

    After running badblocks, which was all clear, then formatting the partition to ext3 again, I attempted to extract the tar. GNU tar consumed CPU cycles for ages without writing any files, then complained about corruption. I assume it was walking the tar to check it wasn’t corrupt. This, as you can imagine, is not very handy. I perused the manpage looking for a switch that would disable the scan and just extract what it can, upto the corruption, but I could not see such a switch

    I found a website that suggested finding where the last intact file in the tar ended, and feeding tar just that part of the file. They supplied a perl script to do the job.

    The problem is that this perl script was unbelievably slow, and had probably only been tested on small files, not my 30GB tar, so Andrew wrote this python script to do the same thing, using information from Wikipedia and from BestSolution’s perl script. Andrew’s version started searching from the end of the tar, not the beginning, because we knew that my tar was corrupt at the end.

    After a few minutes of watching it make a non-corrupt tar, we realised we were going to have to load the whole tar from the disk twice - once to repair it, and again to actually extract it. Surely a better way would be to just start extracting the truncated one, and give up when we get to the truncated file. Andrew’s Aerauntar does just that.

    Usage:
    python aerauntar.py archivename destinationfolder

    So the moral of the story is not to tar backups from corrupt filesystems, always pay attention to errors and never assume that a program will operate as you think it will.

    18 October 2007

    Fixing File Uploads after upgrading to PHP5

    Filed under: Computer — martin @ 1:21 pm

    As some of you may know, I upgraded from PHP4 to PHP5 recently. And it went smoothly - or so I thought. Now, it seems I overlooked the fact that the reference $HTTP_POST_FILES has been phased out. This has been replaced with $_FILES. This is great, since Zen Cart, custom scripts, old phpBB installations and other old php scripts where users can upload a fail now fail spectacularly as they access an empty array.

    First I wanted to write a perl script which I fed a list of files, but with 10GB of websites, this would take ages (and given a list , the number of arguments exceeded perls limit). So instead I ran this command from /var/www/vhosts
    find . -name '*.php' -exec perl -p -i -e 's/\$HTTP_POST_FILES/\$_FILES/g' {} \;
    find . -name '*.inc' -exec perl -p -i -e 's/\$HTTP_POST_FILES/\$_FILES/g' {} \;

    to spawn a new perl instance per file, without checking jpegs and stuff.

    4 October 2007

    Wildcard Parsing in Linux Shells

    Filed under: Computer — martin @ 10:11 pm

    I have just discovered a quirk in linux shells.

    When you issue a command with a wildcard, bash will replace the wildcard with a list of matching files. So when you type mogrify -resize 640x *.jpg
    on a folder containing beach.jpg, pc.jpg and college.jpg, the shell will rewrite that as
    mogrify -resize 640x beach.jpg college.jpg pc.jpg

    and mogrify is given the options -resize 640x beach.jpg college.jpg pc.jpg (filenames in alphabetical order)

    Now let us consider a folder with the following files: -r foo.bar foofolder barfolder
    where foofolder and barfolder are folders. Issuing a rm *, might, at first glance just delete the files and not the folders. But alas this is expanded to
    rm -r foo.bar foofolder barfolder
    and rm recieves these options -r foo.bar foofolder barfolder
    In fact, only the -r file will survive.

    OK, you say, but who has files beginning with hyphens? Well, it could happen. And some commands, like tar, dont need a hyphen at the beginning of their arguments.

    martin@xenon:~/tests$ ls
    folder -r
    martin@xenon:~/tests$ rm *
    martin@xenon:~/tests$ ls
    -r

    24 September 2007

    Andrew’s PHP unzip poem

    Filed under: Computer — martin @ 11:22 am

    When I thought I needed to recompile PHP 5 to get the unzip function for Installatron for Plesk Reloaded, Andrew helped me find yum install php-pecl-zip and everything all started to work.
    Andrew made this poem to summarise [line breaks added]:

    When PHP does not comply,
    think for a moment, and try not to cry,
    For if you see it needs a zip,
    you better go get yum here quick,
    Since compiling you really need not do,
    if you can just simply use the ’su’,
    And then when that command has run,
    you can sit back well and call it done.

    17 September 2007

    Running a command as a /bin/false user

    Filed under: Computer — martin @ 9:07 pm

    In case anyone else wants to run a command as a user whose default shell is set to /bin/false, type this:
    su -s command username

    If you want a shell:
    su -s bash username

    15 September 2007

    Moving to CentOS

    Filed under: Blog, Computer — martin @ 2:31 pm

    I’ve finally decided that enough is enough with DirectAdmin. It’s haphazard way of downloading tar.gzs and compiling from source to random places that it only knows is a sure way to make a disaster in the future. Not only does this make applying updates a cumbersome process, as it doesn’t use any sort of repository or anything, it also means that when something does go wrong it can take ages to track down.

    Amidst the ill-thought-out shell scripts, perl scripts and binary blobs, sometimes you can work out what its up to, sometimes not. And things being broken because of syntax errors (e.g. missing closing brackets) in a paid product is not something I really have time to sort out any more.

    Now, for all of you screaming “Use SSH with webmin/virtualmin”, I would love to, but other server users would be less than pleased to lose their shiny control panel, so that leaves cPanel and Plesk. I’ve decided to go with Plesk, because it looks shinierâ„¢ and is rumoured to be more secure and manage things better behind the scenes, even if its interface isn’t as intuitive as cPanel’s.

    Of course, control panel providers only truly support Redhat derivatives (the Debian etch build wouldn’t even install for me), so I’m moving my server to CentOS (even though I prefer Debian). At least it will work, which is the main thing.

    16 August 2007

    BBC iPlayer and Net Neutrality

    Filed under: Computer — martin @ 1:22 am

    I don’t know how closely you have been following the BBC’s controversial iPlayer that uses torrent-like peer-to-peer technology to distribute programmes aired on BBC TV to users over the internet, but a thorny issue was always the that 3rd-party production companies insisted on DRM being present to limit the number of days that the download will remain watchable to 30 days. That way they cash in on after-sales of DVDs.

    The major problem that quickly arose was that the BBC deployed Microsoft Windows Media Player DRM, restricting the content to users of the Microsoft Windows OS. The BBC Trust agrees that this is against their Royal Charter and apparently Mac and Linux clients are in the works.

    What I never got, is why they can’t release the content made in-house by the BBC themselves in a DRM-free format, and just apply 3rd-party produced content under DRM formats.

    Now ISPs (specifically Tiscali) are moaning that the iPlayer will suck up all their bandwidth and want to charge an extra fee! This is totally uncalled for. BBC pay their internet bill just like everyone else and will pay for the bandwidth used in seeding the programs (to use the torrent term). However the peer-to-peer transfers between end-users will not pass through BBC servers, so how is it fair to charge the BBC for this bandwidth. By that logic, we should be billing the RIAA for bandwidth used by torrents of MP3s.

    As we have started to see in USA, ISPs here are wanting to threaten net neutrality by cherry-picking which content they serve, and charging extra for other content (charging the consumer seems to be the American idea, whilst charging the provider seems to be what the British ISPs are pushing for).

    People use the internet signed up for that - the internet. Not bits of the internet which the ISP can provide cheaply. We should not let ISPs threaten net neutrality by limiting or charging extra for traffic of a certain protocol or originating from certain IPs. Net neutrality is the reason for the internet’s success. Without it ISPs would be free to charge for traffic originating from overseas for instance.

    ISPs should stop overselling bargain “unlimited” packages when they do not have the infrastructure to provide this for the advertised speed. (Just look at Orange and how much slower than advertised that runs at). Packages should be clearly advertised with the speed and bandwidth caps. If ISPs can’t make ends meet, they should charge per GB if needs be, but net neutrality must be kept. They can’t charge for traffic at both ends, then charge an extra fee to a company whose network the packets never go through (which is the case with all packets not from the seed server). Nor can they just traffic-shape it away, because unlike the majority of torrents, all BBC iPlayer content is completely legal.

    One idea that would reduce bandwidth usage would be for ISPs to have BBC caches (ie mirrors) in strategic POPs that they own. With a clever client with more complete IP data, it could be made to favour connecting to nearby iPlayers (geographically and on the same ISP), thus reducing backbone usage. This would be particularly beneficial to Tiscali, becuase many of their customers are on LLU exchanges.

    11 August 2007

    Random Drive

    Filed under: Blog, Computer — martin @ 10:56 am

    So it was just before 5pm yesterday and I was bored. After checking a few things on #friends, Donov and I set out on an adventure. Our drive took us through many places including Lincoln Rush Hour, the M1 and the entire width of the Peak District, including the Cat and Fiddle (A537 Buxton-Macclesfield - hilly and bendy with cliff edges and real fun to drive on).

    By sheer coincidence when we stopped to consult the map who should walk down the street but Compsoc’s treasurer David North. He seemed to recognise me but was unsure, so I waved :). The look was priceless, but of course I forgot my camera. David helpfully informed me, “I live here”.

    As it happens David was on a walk to burn off excess biscuits, which was lucky really as I forgot to write down his house number when I looked up his address in whois records.

    After talking about bambi, DNS propagation, CSS and other stuff we made our way back along the speed-camera-dense roads, stopping for a pizza. Mmmm pizza. And thus the adventure was overl

    « Newer PostsOlder Posts »