Windows usernames with spaces and Samba

Recently I had an issue where a windows user needed access to a samba share on a unix machine. The problem was that the windows user had a username with a space in it (tisk tisk) and unix/samba couldn’t directly support that. A quick workaround is to define a usermap in your smb.conf like so:

[global]
username map = /usr/local/private/usermap.txt

In the usermap.txt you define the username as follows:

username = “User Name”

Where username is the local unix username and “User Name” is the broken windows username with the space. It’s important to quote the username, otherwise samba will treat it as two different usernames. This isn’t the only use for samba usermaps but I was unable to find a well documented example of supporting windows usernames with spaces in them so hopefully this will save someone else time in the future.

Blocking outbound SMTP

My ISP has adopted a policy of network filtering lately that gets on my nerves. They block all outbound SMTP from their broadband customers except to their mail exchangers. While I think this is a good policy to have as it blocks mail worms and spam they should at least ensure that their mail servers are not overloaded! Forcing me (the paying customer) to suffer because they can’t get it together enough to add some capacity to the mail infrastructure on their network is not a good idea when the local broadband market is so competative.

I mean, I realize that from time to time any large network is going to experience capacity issues, but the mail issue has been going on for months now. I’ve tried to tell their customer support people about it but I get the feeling that nothing’s going to be done about the issue.

In the meantime I’ve setup rinetd on my mail server to accept smtp connections on a non-standard port to avoid port 25 filtering all together.

The coolest application I’ve seen in a while

Do you have two systems on your desktop and two sets of keyboards and two (or three in my case) monitors? Want to use one keyboard and mouse on both systems without hardware? I’ve stumbled across a cool multi-platform app called Synergy that lets me use one keyboard and mouse on my Windows and Linux system at the same time!

The server app runs on my windows laptop (dual head) and the client side runs on my linux desktop. Now I can use the nice $120 Logitech wireless keyboard I have on both systems without any extra hardware. I simply move my mouse pointer over to the left hand side of my windows machine and it switches my keyboard over to the linux machine, without delay (although you can configure one). Very cool. It’s made my day for sure!

Using apache mod_rewrite to support multiple subdomains in the same virtual host

Here’s a trick for redirecting multiple subdomains like sub.domain.tld to www.domain.tld/sub.

ServerAdmin webmaster@servername.tld
DocumentRoot /home/www/domain.tld/html
DirectoryIndex index.php index.htm index.html
ServerName domain.tld
ServerAlias www.domain.tld
ServerAlias subdomain1.domain.tld
ServerAlias subdomain2.domain.tld
RewriteEngine On
RewriteCond %{HTTP_HOST} ^subdomain1\.domain\.tld$ [NC]
RewriteRule ^(.*)$ http://www.domain.tld/subdomain1$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^subdomain2\.domain\.tld$ [NC]
RewriteRule ^(.*)$ http://www.domain.tld/subdomain2$1 [R=301,L]

This comes in handy if you want to support multiple subdomains in the same apache virtual host. All the subdomain pages can then be stored under DocumentRoot without creating different virtual hosts.

Quick and dirty remote unix backups

So you need to backup a remote unix system but don’t have enough free disk space to tar locally and then tranfer? Try this!

ssh username@hostname.tld “tar -zcvf – / –exclude /proc –exclude /dev ” | cat > my-system-backup.tgz

This is a breakdown of what this does:

– Starts an ssh session with your remote system (hostname.tld)
– Executes tar -zcvf – / –exclude /proc –exclude /dev ( the exclude statements ensure we don’t grab bits we don’t want, /proc for sure)
– Since tar has – as the filename it pipes the output to the shell, which in turn is piped into cat
– The > redirects the output into a filename of your choice, the .tgz indicated Gzip’d tar file, you can name it whatever you like but .tgz is a standard.

The above command will backup the entire system but you can specify any path, a simple . will backup all your home dir contents on the remote system. I have found this handy on several occasions when I needed a quick and dirty backup of some files on a remote host. Backups to the remote hosts local disk aren’t much good if the system goes down!