Finally I decided that it will be a good idea to keep all of my OpenSource contributions into git projects and also to put them online.
Until now I had only the Patches page.

And today while finalizing the MySQL Resource Agent for Heartbeat I have installed gitweb and I’ll try to add all of my contributions there.

Posted by HackMan
Dated: 9th February 2010
Filled Under: Linux-HA, Technology
Comments: Post the 1st one!

Finally I got the new video screen and we tested it yesterday. 2.4 meters is the optimal screen size for my projector and our living room.
You can watch from any angle, the picture is at least 4 times bigger then our 47′ TV. There are some problems now with the quality of the movies that we watch. XviD on Projector is like screener on Laptop :)
But all 720p movies are crystal clear, like you are in a movie theater and even better.

The only problem yesterday was that we ran out of beer :(

Posted by HackMan
Dated: 3rd February 2010
Filled Under: Uncategorized
Comments: Post the 1st one!

I had to build a mail server for one client. So I decided to use postfix + dovecot as a combination for the setup.
After a week of usage, my client called and asked for per user quotas. Since the setup is with virtual users this required some changes. So here I’ll try to outline what I have done to setup the system.

First of all you should have to know that I setup the machine to be working with postfix + mysql + postfixadmin + dovecot. So the first step I took was to alter the database and add user ids there:


ALTER TABLE mailbox ADD COLUMN uid int NOT NULL AUTO_INCREMENT AFTER active, ADD KEY (uid);

Since on the machine there are already a lot of UIDs allocated from 0 to 1000 I decided that I will use UIDs over 30000 for this setup. But since the machine was in use for a week now, the above query populated the uid column with values. So what you do is, select the last UID from the table and update the AUTO_INCREMENT counter to the value you have + 30000. Here is how you could do it:


ALTER TABLE mailbox AUTO_INCREMENT=30173;
UPDATE mailbox SET uid=uid+30000;

Ok, so we have updated the database and we have the new UIDs that we have to use on the machine. The next step is to update the UIDs on the filesystem, so you enter your mail storage dir(mine is /var/vmail) and run this to fix the permissions:

mysql -e 'SELECT uid,maildir FROM mailbox' postfix|while read uid dir; do chown -R $uid $dir; done

The following steps are configurations for postfix and dovecot.

Since the current configuration for postfix was with static UID/GID maps for all users, now I had to update that. In the main.cf you will usually find these lines:

virtual_uid_maps = static:110
virtual_gid_maps = static:110

These are the static uid/gid maps. So we change ONLY the UID maps to:

virtual_uid_maps = proxy:mysql:/etc/postfix/mysql-virtual-uid-maps.cf

After you have done this you have to create the uid-maps.cf…:

user = postfix
password = *********
dbname = postfix
hosts = localhost
query = SELECT uid FROM mailbox WHERE username='%s' AND active = true

Now restart postfix and you have finished with it…

So what we have left to do is fix dovecot configuration:

in the protocol imap section you have to add this line:
mail_plugins = quota imap_quota
In the protocol pop3 section you have to add this line:
mail_plugins = quota
Then in the plugin section you have to add this line:
quota = fs:user

The last change is to the user_query for dovecot. You have to change this:
user_query = SELECT CONCAT('/var/vmail/',maildir) AS home, '110' AS uid, '110' AS gid, CONCAT('maildir:',CONCAT('/var/vmail/',maildir)) AS mail, CONCAT('maildir:storage=', ROUND( mailbox.quota / 1024 ) ) AS quota_rule FROM mailbox WHERE username = '%u'

To that:
user_query = SELECT CONCAT('/var/vmail/',maildir) AS home, uid, '110' AS gid, CONCAT('maildir:',CONCAT('/var/vmail/',maildir)) AS mail, CONCAT('maildir:storage=', ROUND( mailbox.quota / 1024 ) ) AS quota_rule FROM mailbox WHERE username = '%u'

Now after restart of dovecot you have everything setup and running.

And some plus is the automated quota handling. By adding one simple line to cron you can update the fs quota for all users:
mysql -e 'SELECT uid,ROUND(quota/1024),ROUND(quota/1024),"0","0" FROM mailbox' postfix|setquota -B /

Now you control the quota for all these users from the postfixadmin panel :)

Quite nice and quite easy. It took me 2hours to read all the documentation for that and to implement it.

Posted by HackMan
Dated: 30th January 2010
Filled Under: Linux General, Technology
Comments: Post the 1st one!

Finally the books I ordered in the beginning of December have arrived :)

  • Advanced Programing in the Unix Environment
  • Unix Network Programing Volumes 1 and 2

I think that these books are the bibles of network programing and they should be a must read for any C developer.

I have also ordered these two:

  • Myths of Security
  • The Art of Lean Software Development

I’m pretty excited about the Unix Network programing volume 1 since it is third edition and I have read only the second. In the third they cover the SCTP which is a very nice protocol. I actually implemented SCTP in OpenVPN and the book will help me understand just how many mistakes I have made in my implementation :)

Posted by HackMan
Dated: 6th January 2010
Filled Under: Uncategorized
Comments: Post the 1st one!

Just before Christmas, Bulgarian law makers decided that it is a very good idea to approve the changes in the Law for Electronic messages. What they approve was that they need surveillance. What they didn’t think was how they will have this surveillance! So what we will have is a big version of Big Brother but with many smaller accomplices and a lot of people peaking in Big Brothers database…

I just found one initiative which asks every Bulgarian citizen to act and call all those who voted for this madness and try to make them vote against. I will surely make my 100 calls! Here is the list of all phone numbers:

http://jackie.hopto.org/blog/(Bulgarian)

Posted by HackMan
Dated: 5th January 2010
Filled Under: Uncategorized
Comments: 4 Comments

Before Christmas I had ordered an Eposn EMP-TW700 projector for home. On 30th it finally came. So we watched one movie with it and my father managed to bring down the screen :) So after a second installation yesterday, now I finally have my own home theater… It looks good but during the day you can watch movies with dark scenes :( Still the TV is the better option for that.

Posted by HackMan
Dated: 2nd January 2010
Filled Under: Uncategorized
Comments: Post the 1st one!

Pfiuuu, today I finally finished my Exam generator. I added generating PDF files from the DB. Until now I was generating only txt support. Now I can generate new variants of a test whenever I want, just with one execution of the script. I also made a web version so I can generate variants of the tests directly from my home servers without direct access to the questions DB. The only thing that is missing now is stored every generated variation of the exams into DB for later use/verification. Maybe in future I’ll add this to the DB and to the script. It will be useful for the upcoming years.

I’m thinking of putting the code online, but since it is a really bad written Perl code for now I’ll save my self the embarrassment :)

Posted by HackMan
Dated: 2nd January 2010
Filled Under: Technology
Comments: 2 Comments

I’m going to FOSDEM 2010. This will be my first visit of the event but I’m sure I’ll like it.

I proposed 2 talks for the conference so it is also possible that I will also speak there :)

I'm going to FOSDEM, the Free and Open Source Software Developers' European Meeting

Posted by HackMan
Dated: 27th December 2009
Filled Under: Uncategorized
Comments: Post the 1st one!

Yesterday I bout AzBox Premium HD Satellite receiver. The receiver is very nice, you can watch YouTube directly from it. You have a web browser, e-mail client and I can watch all of our movies directly from the storage. It has a HDD bay and WiFi. You can record shows from the TV to the local disk or to a remote storage very easily. I’m happy with most of its functionality, but the most funny thing is that I can not watch satellite TV because it is amazingly hard to configure the CCcam client on this device. It took me and my brother the better part of the day to install and configure the client on this receiver.

So it is a very nice receiver, but if you use it with shared card, be prepared for problems and headaches :)

Posted by HackMan
Dated: 25th December 2009
Filled Under: Technology
Comments: Post the 1st one!

If for some reason, anyone who is reading is unfortunate enough to have cPanel on some of his servers you have to know that /scripts/mysqlup doesn’t upgrade the mysql database to the new format offered by 5.0.X.
What this means is that, even if you have mysql 5.0.x running, you can not make use of stored procedures or views.

Since we have migrated around 30 servers to mysql 5.0.x I want to share with you how you can fix the problem without even restarting the MySQL:

Here are the queries which will update your mysql database to the new standard for MySQL 5.0.x:

ALTER TABLE mysql.user ADD `Create_view_priv` enum('N','Y') character set utf8 NOT NULL default 'N';
ALTER TABLE mysql.user ADD `Show_view_priv` enum('N','Y') character set utf8 NOT NULL default 'N';
ALTER TABLE mysql.user ADD `Create_routine_priv` enum('N','Y') character set utf8 NOT NULL default 'N';
ALTER TABLE mysql.user ADD `Alter_routine_priv` enum('N','Y') character set utf8 NOT NULL default 'N';
ALTER TABLE mysql.user ADD `Create_user_priv` enum('N','Y') character set utf8 NOT NULL default 'N';
ALTER TABLE mysql.user ADD `max_user_connections` int(11) unsigned NOT NULL default 0;

ALTER TABLE mysql.user MODIFY Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Repl_client_priv;
ALTER TABLE mysql.user MODIFY Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_view_priv;
ALTER TABLE mysql.user MODIFY Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Show_view_priv;
ALTER TABLE mysql.user MODIFY Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_routine_priv;
ALTER TABLE mysql.user MODIFY Create_user_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Alter_routine_priv;

UPDATE mysql.user SET Create_user_priv='Y', Create_view_priv='Y', Show_view_priv='Y', Create_routine_priv='Y', Alter_routine_priv='Y' WHERE User='root';

ALTER TABLE mysql.host ADD `Create_view_priv` enum('N','Y') character set utf8 NOT NULL default 'N';
ALTER TABLE mysql.host ADD `Show_view_priv` enum('N','Y') character set utf8 NOT NULL default 'N';
ALTER TABLE mysql.host ADD `Create_routine_priv` enum('N','Y') character set utf8 NOT NULL default 'N';
ALTER TABLE mysql.host ADD `Alter_routine_priv` enum('N','Y') character set utf8 NOT NULL default 'N';
ALTER TABLE mysql.host ADD `Execute_priv` enum('N','Y') character set utf8 NOT NULL default 'N';

ALTER TABLE mysql.db ADD `Create_view_priv` enum('N','Y') character set utf8 NOT NULL default 'N';
ALTER TABLE mysql.db ADD `Show_view_priv` enum('N','Y') character set utf8 NOT NULL default 'N';
ALTER TABLE mysql.db ADD `Create_routine_priv` enum('N','Y') character set utf8 NOT NULL default 'N';
ALTER TABLE mysql.db ADD `Alter_routine_priv` enum('N','Y') character set utf8 NOT NULL default 'N';
ALTER TABLE mysql.db ADD `Execute_priv` enum('N','Y') character set utf8 NOT NULL default 'N';

FLUSH PRIVILEGES;

Keep in mind that you have to use this exact sequence. If you change the order of any of the columns and you will not achieve the desired result. In fact if you change the order of the columns of any of the tables in the mysql database you will probably have big problems, as MySQL is not using column names internally, only column numbers :)

Posted by HackMan
Dated: 15th December 2009
Filled Under: Uncategorized
Comments: Post the 1st one!