March 2008 Archive

Samba smbtree Problems

March 31st, 2008

I don’t use Samba much but tonight I had reason to use the smbtree command. Unfortunately the command returned nothing.
After further investigation using the debug option I see that the reason is that I have no file called /var/lib/samba/unexpected.tdb. The actual debug output is here.

# smbtree -N -d 2
added interface ip=172.16.5.187 bcast=172.16.255.255 nmask=255.255.0.0
tdb(unnamed): tdb_open_ex: could not open file /var/lib/samba/unexpected.tdb: No such file or directory

The last line is repeated about 30 times before the command fails. Looking in /var/lib/samba shows that, as reported, the file does not exist.

$ ls -1 /var/lib/samba/
account_policy.tdb
brlock.tdb
browse.dat
connections.tdb
gencache.tdb
group_mapping.tdb
idmap_cache.tdb
locking.tdb
messages.tdb
netsamlogon_cache.tdb
ntdrivers.tdb
ntforms.tdb
ntprinters.tdb
perfmon
printing
private
registry.tdb
scripts
sessionid.tdb
winbindd_cache.tdb
winbindd_privileged

Next I tried using yum to remove and reinstall samba but without any luck. This command certainly used to work but that may have been Fedora 7 (I’m using Fedora 8) as, like I said, I haven’t tried this for a while.
Googling for this problem returns many people with the same issue but no solution. At least Fedora 9 comes out soon so maybe it will fix itself by then but this sort of thing that I just can’t solve really bugs me.

Remotely Shutdown Synology Disk Stations

March 27th, 2008

The normal command I use to shutdown a Linux box would be to run something like this as root:

# /sbin/shutdown -h now

If you have Telnet or SSH access to your Disk Station then you will find this command is not available. Instead you should run the command:

# poweroff

Or to reboot

# reboot

For a full list of the commands see the Basic Commands Synology Wiki page

Firefox Windows Authentication

March 27th, 2008

If you want to use Firefox to access a corporate intranet then you will need to enable Windows Authentication. Simply enter about:config in the location bar and locate the following key:

network.automatic-ntlm-auth.trusted-uris

Enter the domains you wish to access separated by commas. For example, if your intranet was located at http://intranet/ then you would just enter the value ‘intranet’ (without quotes).

My Synology Disk Station

March 25th, 2008

I bought a Synology DS-106e last year and I’ve been very impressed by the device. It’s certainly not the cheapest NAS device on the market but in my opinion it’s well worth the money considering it’s performance and features. I installed a  320GB Seagate Barracuda 7200.10 hard drive in mine since I’m mainly backing up data files and don’t use large multimedia files.

The performance is great but the best part is the support provided by Synology. Even though my Disk Station is last years model they continue to release firmware upgrades that can be applied to any model.

For example they recently released a new management interface that supports, amongst other things, SSL/TLS over FTP and HTTPS web connections. On top of that there’s a patch available on their support page that enables SSH or Telnet connections into the Disk Station.

I’ve just been testing the SSH support that this evening, backing up some data using rsync over SSH, also connecting directly over SSH to tidy up some files and it works like a dream.

Synology seems to be one company that, unlike many others, allows advanced users open access to the product instead of locking down the system. Even though my server only has 32MB of RAM it essentially means that I have my own Linux box at a cut down price with none of the hassle of making my own server.

On top of that it uses very little power and is almost silent in use, just a slight hum from the hard drive. In the future I’ll definitely consider upgrading to a two disk device that supports RAID1 for extra security.

Windows Recovery Partitions

March 23rd, 2008

It seems to be the trend these days not to include Recovery CDs but instead to use a ‘hidden’ partition on the hard disk containing the recovery software. This is usually accessible by pressing a specific key combination on boot.

My girlfriends new HP computer is the same but I also see there is bundled backup software to enable a backup CD or DVD to be created. My point is that I wonder how many users actually create a backup disk so the computer can be restored to it’s factory state.

Having had my laptop hard drive fail last year I know that if I only had the original OS on a partition then everything would have been lost, requiring a call to the support line of the manufacturer concerned.

I know the arguments for having a recovery partiton but bearing in mind that DVDs cost vitrually nothing to manufacture it seems a pretty cheap cost saving measure on the part of computer manufacturers not to ship these DVDs with the computer as well as having the partition.

Can Wireless-N Deliver the Goods

March 22nd, 2008

I bought my current laptop, an Acer Travelmate 800, in June 2003. Yes it’s an antique by todays standards but it was one of the first with built in wireless connectivity.

It’s the original Intel Centrino platform with the Intel PRO Wireless 2100 3B Mini PCI Adapter (802.11b). At the same time I bought a Linksys Wireless Router and at the time this was the only wireless signal I could see from my flat. Needless to say I got no interference and although 802.11b maxed out at about 2 Mbits/s in the real world I always had a steady, stable connection.

Now it’s almost 5 years later and at any given time I see between 5 and 15 wireless routers broadcasting their SSIDs plus god knows how many others not broadcasting the SSID.

Visible SSIDs broadcasting

Even though I’ve since bought a new Netgear router these signals make my wireless connection almost useless. If I can connect at all the signal drops out about every 5 minutes and then reconnects, if I’m lucky. Other times it just drops the connection and stays disconnected until I manually intervene to force a reconnection.

After reading this column by Pc Pros John Honeyball I agree completely. Compared to my wired LAN, WLAN is a joke, the really annoying part is that I so much want it to work well.

I’m planning on upgrading to a new laptop this year, one with the wireless 802.11n standard (maybe out of Draft status by then) and I’m hoping that the interference issue has been somewhat improved with the advent of MIMO technology

My internet connection runs at about 10Mbits/s but I also have a NAS storage device that I use for backups and general storage so I would ideally like that my wireless connection will run at least as fast as my wired connection, at least 40-50 Mbits/s. From what I’ve read 802.11n can achieve this but having been disappointed in the past I’ll wait and see.

At the same time I’ll upgrade my router so all my network devices will also be using Gigabit Ethernet (bar my printer) so at least my wired network will be up to speed.

Using Unsafe Functions with JET Database Engine

March 21st, 2008

I recently developed an HTA Application written in Javascript that used ADO to retrieve and update data in an MS Access database.

One of the calls tried to open a stored query but failed with the error ‘Unkown function’. It turns out that the query contained the Nz VBA function to convert null values into some other, zero in my case.

This works fine when run from within MS Access but when called externally would fail due to the JET 4.0 database engines sandbox mode.

I could have changed the registry key to allow the function but that would only work on my computer so as a fix I replaced all the references to Nz with IIf statements, not an elegant solution but it works none the less.

Insert Random Numbers into MS Access Tables

March 21st, 2008

Sometimes for testing it’s useful to be able to insert random numbers into a table field. This is an easy way to do this in MS Access. First write a custom function that looks like this.

Function random(ID as Integer,min as Integer,max as Integer) As Integer
random = Int((max - min + 1) * Rnd + min)
End Function

The max and min are the lowest and highest random numbers you wish to generate, ID is a field from the table (it can be any field) you wish to insert the random number into.

Of course if your field is not an integer then you will have to change the ID as Integer part to ID as String for example.

The field is required so the function is called on every row, otherwise Access will just run the function once and then update every row with the same random number.
To call the function from SQL use this.

Update my_table set random_field=random(ID, 1, 10)

In this case I’ve used an Update statement to insert a number between 1 and 10 into the field called random_field but it works equally for for Insert statements.

Backup your MBR

March 21st, 2008

In relation to the post ‘Overwrite MBR from Linux’ this is how to take a backup and restore your current Master Boot Record (MBR) in case you accidentally wipe it. This assumes your main disk is called /dev/sda plus all command must be run as root.

To backup:

dd if=/dev/sda of=~/mbr.image  bs=512 count=1

This saves your MBR in your home directory and names it mbr.image

Now to restore:

dd if=~/mbr.image of=/dev/sda  bs=512 count=1

Updated Wordpress Theme

March 18th, 2008

After initially using the Digg 3 Column theme I decided to go for a more minimalistic theme. Inline with my main site having virtually no images I decided an image free theme would be best.

As a bonus this means faster page loads and smaller bandwidth on my web host. I also just like the simplicity of the new theme, it gives far more priority to the text which after all is what a blog is all about.

After some searching I found the White as Milk theme which then led me to Skimmed Milk, my current theme.

I use a XHTML 1.1 Doctype on my main site so I decided to try the same with my blog. It was actually surprisingly easy to do (including serving the page as Content-Type: application/xhtml+xml) and just required some minor edits of the functions.php file in the theme folder.

For my own sake I like the fact that in Mozilla browsers pages completely break if you send invalid markup using this content type, at least they are easy to notice and fix. I’m also so used to writing pages that conform to a XHTML 1.1 Doctype that most of my pages validate first time.