Hacker’s Diary

Avatar

My Knowledge Database

RoundCube Theme - Cobalt

This theme is based on Cobalt theme for Thunderbird created by Bodizzle.

I use this theme myself with Thunderbird. I like it so much, so I decided to spend some time to extract icons and create a RoundCube theme. My RoundCube includes features, which are not available in default version, thus the icons are still included in package.

RoundCube Theme - Cobalt

RoundCube Theme - Cobalt

The guy who created this theme for Thunderbird, has lost his job recently. So if you like this theme, consider donating him some bucks. Bodizzle’s Blog.

Download here: cobalt-01

Bookmark and Share

[HowTo] Bind9+MySQL on Debian

Tired of editing Bind zone files? Or you want to create UI for your clients, so they can edit their zones? It can’t be easier, than when you have your zones in MySQL database.

Here I will explain how to install Bind with MySQL database support. After patching, Bind will be able to use both, MySQL tables and zone files.

Installing packages and getting sources

Get MySQL BIND SDB driver from http://mysql-bind.sourceforge.net/

If you don’t have a Bind server yet, it would be nice to install it. This will create startup scripts, sample configs, etc.

apt-get install bind

Now set up all other packages need:

apt-get install mysql-server-5.0 mysql-client libmysql++-dev dpkg-dev

Now, get source of your existing Bind package (the current version is bind9-9.3.4):

apt-get source bind

Untar both packages, bind9_9.3.4.orig.tar.gz and mysql-bind.tar.gz

There is already a README with mysql-bind package, but I’ll explain here as well.

Copy file mysqldb.c from mysql-bind package to “bind9-9.3.4/bin/named/mysqldb.c” and
mysqldb.h to “bind9-9.3.4/bin/named/include/named/mysqldb.h

Patching Bind source files

Edit: bind9-9.3.4/bin/named/Makefile.in

Under comment “# Add database drivers here.” set these:

DBDRIVER_OBJS = mysqldb.@O@
DBDRIVER_SRCS = mysqldb.c
DBDRIVER_INCLUDES = -I’/usr/include/mysql’
DBDRIVER_LIBS = -L’/usr/lib/mysql’ -lmysqlclient

Where:
DBDRIVER_INCLUES is output of “mysql_config –cflags
DBDDRIVER_LIBS is output of “mysql_config –libs

Edit: bind9-9.3.4/bin/named/main.c

Add “#include <named/mysqldb.h>” in the beginning of the file, right after this comment “* Include header files for database drivers here.“.

Add “mysqldb_init();” right before “ns_server_create(some params);” and “mysqldb_clear();” after “ns_server_destroy(some params);“.
You’ll see comments like “* Add calls to register/unregister sdb drivers here.

Compiling Bind

Now go to bind9-9.3.4 and configure.

“sysconfdir”, “prefix” and “localstatedir” should much your current configuration. If you installed bind via APT, then these should be the right ones:

./configure –sysconfdir=/etc/bind –prefix=/usr –localstatedir=/var/run/bind
make
make install

Now if you restart Bind (/etc/init.d/bind9 restart), it should run without problems.

Creating database and inserting sample data

mysql> create database bind;

mysql> use bind;

I will create a subzone of hackersdiary.com, test.hackersdiary.com

mysql> CREATE TABLE test_hackersdiary_com (
name varchar(255) default NULL,
ttl int(11) default NULL,
rdtype varchar(255) default NULL,
rdata varchar(255) default NULL
) TYPE=MyISAM;

mysql> INSERT INTO test_hackersdiary_com VALUES (’test.hackersdiary.com’, 3600, ‘SOA’, ‘ns.hackersdiary.com. tom.hackersdiary.com. 200902051 28800 7200 86400 28800′);
mysql> INSERT INTO test_hackersdiary_com VALUES (’test.hackersdiary.com’, 3600, ‘NS’, ‘ns.hackersdiary.com.’);
mysql> INSERT INTO test_hackersdiary_com VALUES (’test.hackersdiary.com’, 3600, ‘NS’, ‘ns2.hackersdiary.com.’);
mysql> INSERT INTO test_hackersdiary_com VALUES (’test.hackersdiary.com’, 3600, ‘MX’, ‘10 mail.test.hackersdiary.com.’);
mysql> INSERT INTO test_hackersdiary_com VALUES (’mail.test.hackersdiary.com’, 3600, ‘A’, ‘127.0.0.1′);

Now setup zone in “/etc/bind/named.conf.local

zone “test.hackersdiary.com” {
type master;
database “mysqldb bind test_hackersdiary_com localhost binduser bindpassword”;
};

Restart Bind (/etc/init.d/bind9 restart)

Testing zone

Now ask your nameserver to resolve mail.test.hackersdiary.com “dig mail.test.hackersdiary.com @ns.hackersdiary.com

You should get:
;; ANSWER SECTION:
mail.test.hackersdiary.com.     3600    IN      A       127.0.0.1

Now get PhpMyAdmin or create your own UI for zone editing. There is one ready to use dnsSQLpanel, but I haven’t tested it.

Comments? Problems? You’re welcome.

Bookmark and Share

[HowTo] Change Windows Remote Desktop port

1. Click Start, click Run, type Regedit.exe, and then click OK.
2. Locate the following key in the registry:
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\TerminalServer\WinStations\RDP-Tcp\PortNumber
3. On the Edit menu, click Modify, then switch Base to Decimal and enter your desired port number.

Restart your computer, to activate changes.

Bookmark and Share

[KB] The remote session was disconnected

Problem:

Often after upgrading client machines to XP Service Pack 3, I get problem while connecting to Terminal Server. The connection is refused with following error: “The remote session was disconnected because the terminal server client access licence stored on this computer has been modified.”

Solution:

1. Click Start, click Run, type Regedit.exe, and then click OK.
2. Locate the following key in the registry:
HKEY_LOCAL_MACHINE\Software\Microsoft\MSLicensing\Store\
3. Delete the TS CAL key, probably LICENSE001.

NOTE: Typically, LICENSE000 is the license for the operating system and LICENSE001 is the TS CAL. To verify this information, check to see whether the ProductID value is present; this value indicates the license for the operating system.
4. When the client attempts to reconnect to the Terminal server, it will request a new TS CAL.

If deleting the LICENSE000 or LICENSE00x key to troubleshoot connection failures does not let a client connect to a Terminal server, back up the whole MSLICENSING key, and then delete the whole key. Try to connect to a Terminal server. This causes the generation of a new hardware ID. This enables the client to request a new license, and to successfully connect. The MSLICENSING key and all subkeys are recreated.

Bookmark and Share

[HowTo] Debian killall: command not found

Last week our admin from Saint Petersburg’s office installed Debian on a new router-box. While playing and setting everything up, I noticed that there is no “killall” command. What to do?

Alternatively you can use “pkill”, like:

pkill apache

In my opinion works even better that killall. If you like the old favorite killall, just install the psmisc package:

apt-get install psmisc

Note: this packages also includes command like “pstree”, very useful.

Bookmark and Share

[HowTo] Find files that contain a given string

If you are searching in current folder, sometimes command like:

cat * | grep -i “string” *

will print the filename and a line that matched the string. But this will not “search” in subfolders, and will not work on some Linux distros.

The right (my) way would be:

find /path/to/folder -type f -exec grep “string” {} \; -print

This will print a line that matched the string, and filename on the next line.

Bookmark and Share

[HowTo] Change a hostname after Linux installation

I usually set hostname during Linux installation, but many people don’t. Then without a knowledge it could take some time to change it correctly.

Doing so:

hostname newhostname

will only change hostname temporary, after system reboot it will change back to what it was specified during installation.

So the right (my) way of changing hostname:

  • Some linux systems keep hostname record in /etc/sysconfig/network

    HOSTNAME=localhost.localdomain
  • Debian systems /etc/hostname
    localhost.localdomain
  • Additionally hostname is kept in /etc/sysctl.conf
    kernel.domainname = localdomain (usually uncommented)
    kernel.hostname = localhost

And at the end, don’t forget to add hostname to /etc/hosts file like this:

127.0.0.1       newhostname.localdomain       newhostname

or

127.0.0.1       newhostname

Otherwise services like Apache, Squid and many others won’t run correctly or won’t run at all if they can’t resolve the hostname either by hosts file or DNS server.

Bookmark and Share

[HowTo] Virtual Machines on Debian using XEN

This solution assumes you have already installed Debian Linux with minimum base system.

This solution is made for amd64 system. But others should be the same, just find the correct package for you system.

Setup

First install SSH, so it will be a lot easier to copy/paste commands in console

apt-get install ssh

Remove packages we don’t need

apt-get remove exim4 exim4-base lpr nfs-common portmap pidentd pcmcia-cs pppoe pppoeconf ppp pppconfig
apt-get install screen debootstrap iproute python python-twisted-core python-twisted-conch bridge-utils

XEN related packages

apt-get install xen-linux-system-2.6.18-6-xen-amd64
apt-get install xen-tools

If you wish to use XFS file system, you also need to install xfsprogs

apt-get install xfsprogs

Creating Virtual Machines

The best way of creating up virtual machines is using hard drives LVM volume, thus way you can easly increase partition size of partition where VM is.

Creating virtual machine using LVM volume vs0, and ext3 filesystem. VM will be running minimum base install of Debian Linux

xen-create-image –hostname=vm1.hackersdiary.com –size=4Gb –swap=512Mb –ide \
–ip=10.0.0.119 –netmask=255.255.255.0 –gateway=10.0.0.1 –force \
–lvm=vs0 –memory=512Mb –arch=amd64 –fs=ext3 –kernel=/boot/vmlinuz-2.6.18-6-xen-amd64 \
–debootstrap –dist=etch –mirror=http://ftp.ee.debian.org/debian/ –passwd \
–initrd=/boot/initrd.img-2.6.18-6-xen-amd64

This will create a 4Gb root partition, and 512Mb swap for VM. After the installation of base system, you will be required to input root password for your newly created VM.

To create XFS filesystem on VM, replace the –fs=ext3 with –fs=xfs
To use image files instead of LVM volumes replace –lvm=vs0 with –dir=/vm/images

Make VM to start automatically on boot

ln -s /etc/xen/vm1.hackersdiary.com.cfg /etc/xen/auto

Starting up VM manually

xm create -c /etc/xen/vm1.hackersdiary.com.cfg

To leave VM’s shell, type CTRL+] if you are at the console, or CTRL+5 if you’re connected to main debian using ssh

Shutting down VM

xm shutdown vm1.hackersdiary.com

Also awailable commands

xm reboot vm1.hackersdiary.com
xm list


How to increase VM’s partition size (Only if using LVM)

XFS Filesystem

lvextend -L+10G /dev/vs0/vm1.hackersdiary.com-disk
xm shutdown vm1.hackersdiary.com
mount /dev/vs0/vm1.hackersdiary.com-disk /vm/base
xfs_growfs /vm/base
umount /vm/base
xm create -c /etc/xen/vm1.hackersdiary.com.cfg

EXT3 Filesystem

lvextend -L+10G /dev/vs0/vm1.hackersdiary.com-disk
xm shutdown vm1.hackersdiary.com
resize2fs /dev/vs0/vm1.hackersdiary.com-disk
e2fsck -f /dev/vs0/vm1.hackersdiary.com-disk
xm create -c /etc/xen/vm1.hackersdiary.com.cfg

Comments? Problems? You’re welcome.

Bookmark and Share

PostBlocker for Postfix

What’s new in PostBlocker?

  • Queue release daemon (releases mail after 2 minutes of hold period)
  • Queue delete (if IP is blocked, Main daemon starts tool which deletes all mail coming from that IP and dies)

Current release: v0.4a

Bookmark and Share

RoundCube Webmail addon

My addon currently supports:

  • Forwards (mail forwarding to other accounts)
  • Spamfilter (set tag, kill, lover points for SpamAssassin)
  • Whitelist (used by Amavis)
  • Blacklist (used by Amavis)
  • Vacation autoreply

New version of addon is comming soon, as the roundcube project has moved quite a bit forward.

Bookmark and Share

Next,

Protect yourself

FREE Online Scanner - Detect more than 3 million threats

Some useful ads

Before you go

Going so soon? May these links be a guide to web enlightenment. Schwing!