Monday, July 16, 2007

Nicer fonts with Fedora 4

This is a reproduction of a page I gound on the internet. Here is the <a href="http://cri.ch/linux/docs/sk0017.html">original page</a>.

Nicer fonts for Fedora Core 4

Author: Sven Knispel
Updated: 01-11-2005
Feedback welcome: linux@cri.ch
Free service provided by: www.cri.ch

Ever since I am using Fedora Core I have been complaining about the poor rendering of fonts: they look ugly and unsharp.
One week ago I switched my desktop PC from Windows to Linux and I really couldn't stand it so I started a little research.

The reason of the poor rendering is that FreeType is compiled by default with the bytecode interpreter switched off. I didn't find the real reason for that but it seems related to some patent issues.
Fortunately it is quite simple to turn the bytecode interpreter on by recompiling freetype after a slight change.
This article is about recompiling freetype with the bytecode interpreter switched on:

* get the source rpm
* make the required changed
* recompile and install the modified freetype version


1. Getting the sources

First we must heck for current version of freetype:
# rpm --query freetype
# freetype-2.1.9-2
Then download the sources, e.g. from rpm.bone: http://rpm.pbone.net/index.php3/stat/4/idpl/1981137/com/freetype-2.1.9-2.i386.rpm.html
(I suggest downloading the binary rpm as well in case of dammage as we will freshen the installed one)
Install the sources:
sudo rpm -ivh ./Desktop/freetype-2.1.9-2.src.rpm
2. Enabling the bytecode interpreter

Change to the directory /usr/src/redhat/SPECS and edit freetype.spec.
What we are looking for is: %define without_bytecode_interpreter 1 and we want to replace it by: %define without_bytecode_interpreter 0 in order to enable the bytecode interpreter.
3. Rebuild and install

After having changed the code we need to rebuild the RPMs:
rpmbuild -bb freetype.spec (if you get errors make sure that XFree86-devel is installed as freetype depends on it)
If the build was successfull the result can be found in /usr/src/redhat/RPMS/i386/: [~]$ cd /usr/src/redhat/RPMS/i386/
[i386]$ ls -l
total 3268
-rw-r--r-- 1 root root 824001 Oct 21 15:28 freetype-2.1.9-2.i386.rpm
-rw-r--r-- 1 root root 1781435 Oct 21 15:28 freetype-debuginfo-2.1.9-2.i386.rpm
-rw-r--r-- 1 root root 105464 Oct 21 15:28 freetype-demos-2.1.9-2.i386.rpm
-rw-r--r-- 1 root root 585133 Oct 21 15:28 freetype-devel-2.1.9-2.i386.rpm
-rw-r--r-- 1 root root 25476 Oct 21 15:28 freetype-utils-2.1.9-2.i386.rpm
Now check for the ones you need to reinstall with rpm --query <package-name> (e.g. rpm --query freetype-devel) and reinstall whatever is required with the force option as they are already installed in the original version: rpm -Uvh --force freetype-2.1.9-2.i386.rpm
rpm -Uvh --force freetype-devel-2.1.9-2.i386.rpm
That's it!
Now just restart X and enjoy...
4. Settings

If you use a TFT I recommend deactivating anti-aliasing for even crisper fonts.
4. Results

And here is the comparison before and after:
before after
5. Consistent font for all applications (updated 31.10.2005)

If you are using KDE you may have noticed that the settings from KDE are not inherited to Qt applications. Especially Firefox kept showing bigger fonts not corresponding to me KDE font-settings.

After some research I found out how to force the fonts for non KDE applications:

* the gnome font-settings must be changed. This can be done by exectuting gnome-font-properties and select e.g. Tahoma 8 as default font
* under KDE the gnome-settings-daemon mus be started: this can be done e.g. by adding a symlink to /usr/libexec/gnome-settings-daemon from ~/.kde/Autostart (ln -s /usr/libexec/gnome-settings-daemon ~/.kde/Autostart/gnome-settings-daemon)


After these changes all my apps have neat and consistent fonts...

Capturing DV video from camcoder

After spending few weeks in Taiwan at my family in law's place, I had to transfer some videos I took with my Bro's miniDV video camera. I found very usefull information on how to set up Linux <a href="https://www.redhat.com/archives/fedora-list/2004-December/msg06925.html">here</a>. To make sure these information won't go away, I extracted what I have used from this link and present them below :

As root:
$ cd /dev/
$ ./MAKEDEV raw1394
$ mknod -m 666 /dev/dv1394 c 171 32
$ chmod 666 raw1394

Then add DAG to your yum repository list:
$ cat /etc/yum.repos.d/dag.repo
[dag]
name=Dag RPM Repository for Fedora Core
baseurl=http://apt.sw.be/fedora/$releasever/en/$basearch/dag

Then install kino and associated tools:
$ yum install kino
$ yum install dvgrab

Then plug in the card and the cam camcorder, set the camera to the
"play" mode, and load the necessary modules:
$ modprobe ieee1394
$ modprobe ohci1394
$ modprobe raw1394 dv1394

Finally, as a normal user:
$ dvgrab file001

and you should start getting file transfers from the camcorder.

More info is available at the following places:

http://kino.schirmacher.de/
http://www.linux1394.org/
http://www.syba.com/us/en/product/43/05/04/index.html
http://www.linux1394.org/hcl.php?class_id=3
http://www.linux1394.org/hcl.php?class_id=1

Exec statement in KDE

A very nice feature of KDE environment is to personalized servicemenu (right click in Knoqueror). You can define an action to do but I was looking for arguments to pass by to the command. I found them <a href="http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-0.9.4.html">here</a>

Recognized fields are as follows:
%f A single file name, even if multiple files are selected. The system reading the desktop entry should recognize that the program in question cannot handle multiple file arguments, and it should should probably spawn and execute multiple copies of a program for each selected file if the program is not able to handle additional file arguments. If files are not on the local file system (i.e. are on HTTP or FTP locations), the files will be copied to the local file system and %f will be expanded to point at the temporary file. Used for programs that do not understand the URL syntax.
%F A list of files. Use for apps that can open several local files at once.
%u A single URL.
%U A list of URLs.
%d Directory containing the file that would be passed in a %f field.
%D List of directories containing the files that would be passed in to a %F field.
%n A single filename (without path).
%N A list of filenames (without paths).
%i The Icon field of the desktop entry expanded as two parameters, first --icon and then the contents of the Icon field. Should not expand as any parameters if the Icon field is empty or missing.
%c The translated Name field associated with the desktop entry.
%k The location of the desktop file as either a URI (if for example gotten from the vfolder system) or a local filename or empty if no location is known.
%v The name of the Device entry in the desktop file.

a tree view of directories

Working in a production environment, we often need to find out which directories take up all space. At first, I was using the command df -k . | sort -u but the output is not very easy to look at. I decided to create a small perl script that would display the size of all the directories in the current location. Here is an exemple :

<img width='450' height='379' border='0' hspace='5' src='/blog/uploads/jbdu01.gif' alt='' />

You can also call the script with a depth argument. If you want to have the size of 2 subdir levels (current level and one sub level), call the script with 2 :

<img width='499' height='464' border='0' hspace='5' src='/blog/uploads/jbdu02.gif' alt='' />


This is a very simple script but it helps me a lot. That's why I decided to publish it on my blog. Use it as you wish !!! It works as is on Linux (Fedora core 3 and 4), AIX 4.X and 5.X, and Solaris 8 and 9.

<a href="/blog/uploads/jbdu" title="jbdu" target="_blank">You can download the code from here.

How to run Lotus Notes with Wine

1. Download and install the 20041019 versions of the wine, libwine, and wine-utils binaries from this Sourceforge page (newer versions may have regression bug #2660).

2. Download and install the latest version of winesetuptk using apt-get or Synaptic.

3. Run winesetup (as you, not root) and accept the defaults.

4. Copy the Notes folder and all subfolders from a working copy of the Lotus Notes [6.5.1 or later] client on Windows to the equivalent directory in your wine installation (for example, if it was "c:\lotus\notes" under Windows, it should be copied to "~/.wine/c/lotus/notes" on Linux).

Make sure that your notes.ini file is in your Notes program directory (the same directory that nlnotes.exe is in). If it's not, you should find it (probably in the Windows directory) and copy it there.

Also, while you're looking at the notes.ini file, make sure that any AddinMenus= or EXTMGR_ADDINS= settings are commented out. They may not hurt anything if they're there, but you should definitely test without them first.

5. Copy mfc42.dll and msvcp60.dll from your "c:\windows\system32" directory in Windows to "~/.wine/c/windows/system" on Linux.

6. Add the following sections to your ~/.wine/config file:

[AppDefaults\\nlnotes.exe\\Version]
"Windows" = "win98"
[AppDefaults\\nlnotes.exe\\x11drv]
"Managed" = "Y"
"DesktopDoubleBuffered" = "Y"

If there are any other sections that were already there for [AppDefaults\\nlnotes.exe], [AppDefaults\\notes.exe], or [AppDefaults\\nhldaemn.exe], just comment them out. We don't need to override any DLLs or set screen resolution or anything with this setup.

Along those lines, make sure any global "Resolution=" settings are commented out. You don't need that either.

7. Try to run Notes. From a terminal window, type:

wine "c:\lotus\notes\nlnotes.exe"

Obviously, you should use whatever path you copied the Notes installation to (c:\lotus\notes, c:\Program Files\lotus\notes, whatever).

Using ssh keys with Filezilla

One of the best FTP client I used under windows is FileZilla. It is simple but works very well. You can download it <a href="http://filezilla.sourceforge.net/">here.</a>
It is great to connect to old FTP sites and can now be used to connect to site using FTP over ssh. It is pretty straight forward if you can login using user/password authentification but it is more tricky if you want to use public/private ssh keys.
The trick is that FileZilla uses modules from putty (the best free telnet/ssh client for windows) to authenticate using keys.

Here is the complete (I hope !) configuration of FileZilla and putty to use ssh keys.

1 ) download the components
Go to <a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html">putty download page</a> and download either putty.zip (which contains everything needed) or download the following components :
- PuTTY : The telnet/ssh client itself
- PuTTYgen : The ssh key generator
- Pageant : The ssh agent to handle passphrase ( I will explain it later ).

2 ) Generating your keys
The first step is to create your public/private key pair that you will be using to access sites. We will only consider RSA ssh keys in this document. Open PuTTYgen.<BR>


<img width='' height='' border='0' hspace='5' align='left' src='http://moon.homeunix.com:8080/blog/uploads/putty01.jpg' alt='' /><BR>


Click on "Generate". You will have to move your mouse to generate random numbers. When it 's finished you will see the following screen :<BR>


<img width='' height='' border='0' hspace='5' align='left' src='http://moon.homeunix.com:8080/blog/uploads/putty02.jpg' alt='' /><BR>


You can modify the Key Comment with whatever you want. It is a good idea to put something like : MyWindowsXP key.... This description is for you, it is not parsed by the ssh system.
The next field is extremelly important : <b>Please, USE A PASSPHRASE</b>.
When everything is done, click on "Save public key". It is a good idea to name your file id_rsa.pub. Although this is not mandatory (you can give any name you want), this would respect the standard name for rsa key file.
Then click on save private key. You can name this file id_rsa.
A quick explanation on these keys. The 2 keys you generated work together. You always keep you private key for yourself. You will never have to send it to somebody. It is your property so keep it secure ;-) ! You public key will have to be sent to every single system you access.

The key generation process if finished. You can close PuTTYgen.
Now is the right time to add your key to the destination account you want to access. Let's say you want to access host1 and account account1. You need to add (or the host administrator) your public key to the file account1@host1:~/.ssh/authorized_keys2.

3 ) configuring PuTTY
Open PuTTY and configure the host you want to access. Click on ssh->auth and browse to get your private key file :<BR>


<img width='' height='' border='0' hspace='5' align='left' src='http://moon.homeunix.com:8080/blog/uploads/putty04.jpg' alt='' /><BR>



Now click back to session, give it a name and save it.

4) Configuring Pageant
If you try to connect to your host using PuTTY and your key, the system will ask for your passphrase. Unfortunately, FileZilla does not ask for a passphrase. So we need the help of Pageant to provide it for you to FileZilla. Pageant is called an ssh-agent. It is used to store your key and your passphrase and give it to client like PuTTY and FileZilla. This is very convenient if you work with a lot of servers. You enter your key and passphrase once, and you can login to any host without typing it again. Each time you start a new session, PuTTY will get its authentification info directly from Pageant.
Let's configure Pageant. Run it and look for it in your task bar. It is the little icon of a computer with a hat on :
<BR>


<img width='' height='' border='0' hspace='5' align='left' src='http://moon.homeunix.com:8080/blog/uploads/Pageant01.jpg' alt='' />
<BR>


Right click on it add key. Browse to get your private key. It will then ask you for you passphrase.

5 ) Using FileZilla to connect to your site

Finally you can open FileZilla. Configure your session. You should be able to connect using FTP over ssh2 to your host.

Thursday, July 12, 2007

Sending out email through your provider with sasl authentification

Over the past years, ISPs started to require email client to authenticate before sending a mail through their mail server. This was an attempt to prevent spamming.
For that time on, no more default configuration of sendmail ! (which actually is much better ;-). Alhtough the configuration is not difficult, it took me sometimes to go through the voluminous mail documentation. Eventually I find out what to do to enable authentification and to remap my local sender email address (root@localhost.localdomain) to a more friendly address (jerome.boismartel@gmail.com).

When I installed my new server using Fedora Core 4, I had once again to figure out what to install and how to configure it. This is the steps I followed :

<b><u>1 ) Finding out what is currently on the system</u></b>
[root@localhost log]# rpm -qa | grep sasl
gnu-crypto-sasl-jdk1.4-2.0.1-1jpp_5fc
cyrus-sasl-devel-2.1.20-5
cyrus-sasl-md5-2.1.20-5
cyrus-sasl-plain-2.1.20-5
cyrus-sasl-2.1.20-5

Cyrus-sasl is the library that takes care of the authentification. As I discovered, it seems to be installed by default on the system (at least with my package selection).

I decided to use postfix as a replacement for sendmail. This is a much better mail system and it's easier to configure. You can find more about postfix <a href="http://www.postfix.org">here</a>.

<b><u>2 ) Installing missing components </u></b>
I could not find a postfix package on my system. So I called up the handy yum ! :
yum install postfix

<b><u>3 ) Configuration </u></b>
I edited the file /etc/postfix/main.cf to add the following lines :
smtp_sasl_auth_enable = yes
smtp_sasl_security_options = noanonymous
smtp_sasl_password_maps=static:<your account>:<your password>
smtp_use_tls = yes
smtp_generic_maps = hash:/etc/postfix/generic

This basically tells your system that your ISP requires authentification. On the third line, you specify your account name and your password.
The last line is not about athentification but it is about address remapping. As I said at the beginning of this text, I wanted my address to appear as if my email was sent from my main mail account : jerome.boismartel@gmail.com and not from root@localhost.localdomain.
To enable address remapping you need to add the last line. Then you add your mapping to /etc/postfix/generic. It is a simple text file that says : "If local address is root@localhost.localdomain, remap it to jerome.boismartel@gmail.com". Here is the file :
#cat /etc/postifx/generic
root@whatever jerome.boismartel@gmail.com

Now that you added your entry, you need to create a DB from that file. The postfix program will search the DB and not the text file. Issue the command :
postmap /etc/postfix/generic

Now you probably want to stop sendmail which is most probably running :
/etc/init.d/sendmail stop

It would be a good idea at that point to rename this startup script preventing it to start at the next reboot :
mv /etc/init.d/sendmail /etc/init.d/sendmail.old

You can now start your postfix mail :
/etc/init.d/postfix start

And send you first email to the world !
echo "SUBJECT:test" | sendmail <email>

This server was built using the latest release of Fedora Core 4. My previous server was running an old version of Redhat (7.2) and<u></u>