File synchronisation utilities

Posted on September 3, 2010
Filed Under Windows, programming | 1 Comment

There have been many different utilities available for years to perform this task, and previously under Linux I just wrote my own scripts. I now find myself at a point where I am in need of a Windows based application, preferably one that runs equally well on all windows platforms, including 32 and 64 bit varieties.

After some digging, and reading of many different reviews of applications, I decided to give the Microsoft SyncToy a try. This is one of those Microsoft power toys that internal developers create and MS make available free of charge and without warranty. In the past, these “pet projects” have delivered some good results. This one looks promising, more so because it is based on the Microsoft Sync Framework, a .NET based application framework that allows synchronisation between multiple machines, disks and services.

SyncToy doesnt appear to offer any http based sync at the moment, and if you are looking for online data storage, it probably isnt for you, but if you are looking to keep multiple machines in sync and dont mind doing it manually, it is worth a look. For me, its biggest use is synchronising source code. I really ought to get a SVN repository running instead, but that adds a bunch of other complications and for a lone developer, is probably way overkill for my needs.

Code indenting OCD

Posted on September 2, 2010
Filed Under programming | Leave a Comment

Is this just me?

When I adopt someone elses code to maintain, or re-use some code from online, I find that as I work through the code, adapting it, adopting it, and modifying it to fit my needs, I have to reformat it to my own style of indenting. It doesnt matter whether its Java, C#, Visual Basic or any other programming language. Without the correct form of indentation, the code seems much to hard to read and digest. And although I could probably write some small application to do the auto indentation bit, I read the code while tidying, almost line by line, giving me a better understanding of it.

I do however, refrain from changing object and method names to fit with my own naming conventions – at least most of the time! Single line “if” statements with curly braces for the action are another matter entirely!

Is this a form of OCD? And am I the only one to do this? Answers on the back of a postcard please!

Buying a new laptop or netbook?

Posted on September 2, 2010
Filed Under General | 5 Comments

I recently started looking at getting a new netbook, mainly for convenience and the ability to use it at home or work. The main criteria was that it needed to be cheap, transportable, a decent battery life, at least 1GB RAM and a minimum screen resolution of 1024 wide.

Initially, I checked out EBay.co.uk, but there seems a little madness on there. Most netbooks and laptops are priced fairly close to their purchase price, meaning that what may seem a bargain often isnt. In addition, those that do appear to be sensibly priced, often have some kind of damage listed towards the bottom of the listing page – buyer beware!

Next, I started checking out online stores. Netbooks have moved on since I last looked at them. The linux variants seem to have almost disappeared. Sub £100 models all now seem to run Windows CE. I didnt like this as a smartphone operating system, so it definitely did not appeal to me. Once you move beyond this, the Windows XP and Windows 7 variants start around £190 for a real low spec model and some are over £400. To me, this completed misses the point of a netbook.

I had a look at some real world stores, some, such as PC World (and Tescos) offer a £50 trade in for your old (possibly non working) laptop when buying a new laptop, but not netbooks, as long as it has an optical drive or was built by one of the listed manufacturers they will be happy to take it. This may be a result of the European Electronic Waste directives, though the motivation wasnt entirely clear. Some stores will provide a written and signed certificate stating that all internal hard disks will be wiped, which will reassure anyone worried about identity theft.

Given that it is coming to the end of the school sales period and the Christmas sales are likely to begin soon, stores are beginning to clear out old stock in preparation for new ranges.

In the end, my choice came down to a £240 netbook, or (with sale price deductions and the $50 off) £290 for a laptop with 3 times as much memory, bigger screen and far bigger internal disk. No prizes for guessing which I opted for. Time will tell whether it meets my needs for long battery life and trasportability.

Smartphones and malicious applications

Posted on August 11, 2010
Filed Under programming | 1 Comment

It has long been a concern that viruses would make their way onto mobile phones, but the reality has that very few were ever written and their method for spreading was cumbersome and unwieldy, limiting their ability to replicate and minimising any damage that could be done.

With the increasing uptake of smartphones – iPhone, Blackberry, Android, etc – and the available software development kits, along with App Stores to distribute the code,  it was only a matter of time before viruses or other malicious code began to appear. A recent BBC Technology article describes a test that demonstrates how simple it is to add malicious code to a seemingly benign application.

An article today in The Register, the popular UK technology news website, describes Trojan-SMS.AndroidOS.FakePlayer-A, which disguises itself as a media application and sends SMS messages to premium rate numbers.

From now on, if you have a smartphone of any type, paying additional care to what you download and install!

Creating an email gateway and spam filter, part #2

Posted on May 31, 2010
Filed Under Linux | 2 Comments

Continuing from part 1, we now need to configure mailscanner, start the programs and check that everything is working correctly.

MailScanner

Within /etc/MailScanner/MailScanner.conf, make the following changes:

Run As User = postfix
Run As Group = postfix
Incoming Queue Dir = /var/spool/postfix/hold
Outgoing Queue Dir = /var/spool/postfix/incoming
MTA = postfix

You will need to modify the directory permission to allow the postfix user to write to /var/spool/MailScanner/incoming and /var/spool/MailScanner/quarantine:

chown postfix.postfix /var/spool/MailScanner/incoming
chown postfix.postfix /var/spool/MailScanner/quarantine

Enabling the mailscanner

Uncomment the following line in /etc/default/mailscanner

run_mailscanner=1

Starting the services
To start the services, run the following two commands:

/etc/init.d/postfix start
/etc/init.d/mailscanner start

Testing
Finally, before redirecting inbound SMTP to your new mail gateway, test it thoroughly. You can do this by using the command “telnet localhost 25″. See here for an example of using telnet to test SMTP.

Creating an email gateway and spam filter, part #1

Posted on May 31, 2010
Filed Under Linux | Leave a Comment

Often it is necessary and recommended to place a mail gateway to trap viruses and spam on the way into your network. There are various off the shelf solutions and there are hardware appliances that can be bought to provide these security features. A free alternative is to use a Linux based system that runs PostFix as a mail service and MailScanner, ClamAV and SpamAssassin to check each message as it flows into your network and that is the subject of today’s blog.

For my purposes, I created a virtual machine with 256MB of memory and an 8GB disk, running an Ubuntu 10 32 bit server install. During installation, I opted for postfix to be installed as the email service. By default, the server is configured to use DHCP for its IP settings, so I changed this to a static address by editing /etc/network/interfaces as follows:

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.1.252
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1

Either run /etc/init.d/networking restart or do a quick reboot for the changes to take effect.

The next step is to install some missing components using apt-get. First, use “sudo -i” to change user to the root superuser, then run the following:

apt-get install openssh-server openssh-client
apt-get install mailscanner
apt-get install spamassassin
apt-get install clamav

Postfix

The majority of the configuration for Postfix is done within /etc/postfix/main.cf. Mine looks like this:

myhostname = mailgate.mydomain1.co.uk
mydomain = mydomain1.co.uk
mydestination =
local_recipient_maps =
local_transport = error:local mail delivery is disabled
myorigin = birkbeck.org.uk
mynetworks = 192.168.1.0/24, 127.0.0.0/8
parent_domain_matches_subdomains = debug_peer_list, smtpd_access_maps
relay_domains = mydomain1.co.uk, mydomain2.eu, mydomain3.com
smtpd_recipient_restrictions = permit_mynetworks, reject_unauth_destination
transport_maps = hash:/etc/postfix/transport
relay_recipient_maps = hash:/etc/postfix/relay_recipients
show_user_unknown_table_name = no
virtual_alias_maps = hash:/etc/postfix/virtual
header_checks = regexp:/etc/postfix/header_checks

In /etc/postfix/transport we specify where mail for each relay domain will be forwarded to.

mydomain1.co.uk smtp:[192.168.1.253]
mydomain2.eu smtp:[192.168.1.253]
mydomain3.com smtp:[192.168.1.253]

With /etc/postfix/relay_recipients, we specify each internal email address that we will accept and relay mail for. It is possible to not implement this feature, but it is a useful check.

fred@mydomain1.co.uk OK
wilma@mydomain1.co.uk OK
barney@mydomain1.co.uk OK
fred@mydomain2.eu OK
sales@mydomain3.com OK

Here we alias local delivery addresses to ones on our relay domains using /etc/postfix/virtual. It is a requirement to have both a postmaster and an abuse address.

postmaster barney@mydomain1.co.uk
abuse barney@mydomain1.co.uk

With the three files created, we must run them through postmap to create the hashes of them:

postmap hash:/etc/postfix/transport
postmap hash:/etc/postfix/relay_recipients
postmap hash:/etc/postfix/virtual

In preparation for MailScanner, we must create a /etc/postfix/header_checks file to contain the regular expression it will check for, the file itself contains a single line as follows:

/^Received:/ HOLD

Within /etc/postfix/master.cf, we must comment out the following line to disallow local email delivery:

#local unix – n n – – local

That is the postfix configuration completed. Part #2 will cover the configuration of MailScanner and the other components.

Blackberry code signature keys on Windows 7 64 bit

Posted on May 31, 2010
Filed Under Blackberry, Windows, programming | Leave a Comment

After a week or say waiting for RIM, my new application signature keys finally arrived.

Under Windows 7, it was necessary to find the Eclipse executable, and modify the properties so that the program was set for XP Compatibility mode. I imagine that this is due to UAC and as a normal user, the tool does not have permissions to write to c:\Program Files.

With the latest version of the Eclipse plugins, the keys are installed from under Window -> Preferences and then Blackberry Java Plugin -> Signature Tool -> Install New Keys. The original keys are only valid on the machine they are installed on, so if you plan on migrating to a new development environment, you ought to note the turnaround time of approximately one week. In addition, you must have the original 10 digit PINcode, part of the installation of the keys involves the keys being validated by RIM – without the PIN code this will not work.

BES Express installation

Posted on May 31, 2010
Filed Under Blackberry, Windows Server | Leave a Comment

Following on from SBS 2003, I decided to take BES Express for a test run.

Again I used a virtual machine to run it in, this time a stock Windows 2003 install, following RIMs recommendations for 1.5GB RAM and a single processor and 20GB hard disk.

In the same was that full BES for Exchange requires a specific user account, we’ll call it besadmin, to be setup for the BES install and for the services to run as.  I created a domain user account for BESX and configured the following attributes:

It’s worth noting here, that the standard SBS create user wizard creates a user account that does not inherit permissions, causing the Send as and Receive as permissions above to not propagate down to the users. In my case, I manually granted besadmin the Send as and Receive as permissions to each user security permissions for each test blackberry user.

Then, on the server destined to run the BES services, whilst logged as a domain admin, the following steps were required:

Once this was done I was ready to login using my BES service account. Before beginning the installation, I downloaded and installed the latest version of MAPI and CDO. Install of the BES Express software was a breeze, I took all the default options and used the SRP ID, Auth Key and CAL provided when I signed up for BES Express.

Once all that was done, I was ready to logon to the administration web interface, create my users and then logon to the web desktop (which has to be in Internet Explorer to run the ActiveX control) and my device activated.

One thing to keep an eye on if you have not used BES before. Logging is verbose and can begin to eat a considerable amount of diskspace. The log files themselves are plain text syslog format, so check the available disk space from time to time and archive/purge old logs from c:\program files\research in motion\blackberry enterprise server\logs.

SBS2003 under VirtualBox on Windows 7 64 bit

Posted on May 31, 2010
Filed Under Windows, Windows Server | Leave a Comment

A fresh install of VirtualBox was followed by a fairly straightforward install of Small Business Server 2003. The two hurdles to overcome for me were as follows:

Once installed, the standard wizard based setup begins, allowing a new, standalone Active Directory to be created and then Exchange to be installed.

One thing that always frustrates me about SBS is that user creation using the wizards places the user within MyBusiness\Users\SBSUsers, rather than the normal Users container, and it also turns of inheritance of permissions by default. Something to bear in mind when I do a test install of BES Express later.

Performance wise, it seems to run adequately with a VM configured for 1.5GB RAM and a single processor on a quad core, 6GB machine. Nice.

Virtualisation using VirtualBox under Windows

Posted on April 11, 2010
Filed Under Windows | Leave a Comment

With a new quad core motherboard installed, running with 6GB of memory, I decided to see what free virtualisation options were available under Windows. The main two contenders appear to be VMWare (whose VMPlayer is free but lacks all the management tools for creating virtual machines) or VirtualBox, which was created by Sun Microsystems and moved into Open Source some time back. VirtualBox runs on many Unix platforms and on Macs, a version is also available for Windows, so I decided to give it a try under a 64 bit version of Windows 7. This seemed timely, as the new testlab machines are due next week with a similar specification and will come preinstalled with Windows 7 (hopefully they will be 64 bit versions but I guess we will have to wait and see).

As I run an Ubuntu (virtual) web server for a number of my sites, I decided to see whether this could be migrated across. From the old linux environment, I needed to convert my KVM .img file into an intermediate file format using the command:

qemu-img convert oldDiskImage.img intermediateDiskImage.bin

To do this, I had to pull down qemu from the repositories (sudo apt-get install qemu). For an 8GB disk image it took about 5 minutes to do the conversion. I had planned to copy the image to an external FAT32 USB disk but the image was to large for this, so I took a different approach . Once I rebooted into windows and downloaded Ext2IFS . To install this, I had to modify the properties of the downloaded executable to set the compatibility mode to Vista SP2 (it would not install without this). After the installation, an extra item appears in Control Panel, allowing Linux ext2 partitions to be mounted under a drive letter in Windows – superb !

The next step was copying the image across to a Windows 7 native partition and converting from the intermediate disk image format to a VirtualBox VDI file. This is done using the vboxmanage command line as follows:

C:\Program Files\Sun\VirtualBox\VBoxManage ddconvert intermediateDiskImage.bin unixserver.vdi

Then the VirtualBox GUI can be used to create a new VM for Linux/Ubuntu, pointing at the comverted VDI file.

keep looking »