Category Archives: Linux

Bttv Kworld tv tunner setup

Problem

Can't get a  Kworld KW-TV878RF ( bt878 chipset ) to work, tvtime-scanner doesn't detect any channel, dmesg shows the module as loaded ( running the  2.6.28-6-generic kernel on Ubuntu 9.04 alpha , but that's not the issue as it turned out ), but still no channel available.

Solution

Edit /etc/modprobe.d/bttv and add the following lines:

alias char-major-81 videodev
alias char-major-81-0 bttv
options bttv card=78 tuner=5 radio=1

The first two lines might not be needed but that's how I had them on gentoo, before I decided to install ubuntu.
The last line is actually telling the bttv drive the exact type of card you have.
For other cards the card number might be different.

Core dumps

I was working on qmail (patching it heavily ) and at one point I was getting a segmentation fault. Trying to trace it in a busy environment is hard, especially in qmail that is very modular and processes come and go away all the time.

So I thought a core dump could be the answer.The only problem was my system wouldn't dump the core of the processes where the 'segmentation fault' occurred. I have set the core size file high enough ( ulimit -c 10000000 ) in the qmail start script but still not core dump so I decided to do some research.

From core man page it seems like a core could not be dumped for a number of reasons:

  1. the process owner doesn't have write permission to the directory where the core file should be written.
  2. the core file size limits ( RLIMIT_CORE , RLIMIT_FSIZE ) are less then the size of the core that would be dumped
  3. the process was setuid and in this case dumping the core would depend on the setting in /proc/sys/fs/suid_dumpable ( proc(5) )
  4. the file being executed doesn't have read permission

In my case #2 and #4 were not an issue so it must have been #1 and/or #3 .

To make sure #1 was not an issue I created a directory /tmp/cores, made it 777 to make sure any process can write to it ( not safe in a multiuser environment but works ) and then set /proc/sys/kernel/core_pattern to /tmp/cores/core so now all core files would be in /tmp/cores instead of the process working directory as it is by default. It's also a good idea to make sure /proc/sys/kernel/core_uses_pid is set to 1 so the pid of the process will be appended to the core file name.

To fix #3 I set /proc/sys/fs/suid_dumpable to 2 . I restarted qmail and there I had the core in /tmp/cores .

exim and domainkeys on debian

This post if a follow up on one of my previous posts that described how you can create a custom exim package on debian.

In this post I will show you how to compile and configure exim with domainkeys support. The configuration will be only for signing outgoing emails but it's easy to make it verify signed messages if you read the exim DomainKeys documentation

To do this first follow the steps described in my previous post and between steps 7 and 8 do these steps :

  1. install libdomainkeys:
    download from: domainkeys.sourceforge.net , extract and make:

    1.  

    if it doesn't compile with errors about resolv do this:

    1.  

    to install just copy the static lib and the header files:

    cp libdomainkeys.a /usr/local/lib
    cp domainkeys.h dktrace.h  /usr/local/include
    

    and then cleanup :

    1.  
  2. Configure the exim custom package for domainkeys:
    add domainkeys support to exim makefile:

    1.  

    And now continue with step 8 in the previous post

When you're done all that's left to do is edit exim configuration to enable domain keys signing:

open /etc/exim4/exim4.conf  or /etc/exim4/exim4.conf.template  in an editor

look up for the remote_smtp transport definition and add the following configuration to it:

dk_domain = ${lc:${domain:$h_from:}}
dk_selector = default
dk_private_key = /etc/exim4/dk_keys/${dk_domain}_priv.key

Key management

create the directory that will hold the keys :

mkdir /etc/exim4/dk_keys

create the scripts that will generate and show the the keys :

  1.  

generate a key for a new domain:

  1.  

After you set the DNS TXT record you can test the new setup by sending an email from the newly configured domain to an account @ gmail or yahoo . At gmail view the new message and click on "details", it should show up as "signed-by: my_new_domain.tld" , yahoo will just show an icon with a key in the message header.

Recover plesk access

Here's a scenario: you're locked out of plesk admin, you forgot the password and can't recover cause your email address is not set in the contact details.

Still have ssh access as root (ssh keys or can still remember password for root ) ? Most of the time I use dsa keys for ssh authentication.
If you do then you can change the password for admin.

Plesk keeps it's password in the psa mysql database so you just have to change it in the psa.accounts table . But to have access to it you need access as root in mysql.
If you don't have the password for root ( most likely on plesk servers ) you'll have to stop mysql and start it without privilege verification.

  1.  

That would work on most linux distros , on some the stop script would be /etc/init.d/mysqld and on others the path to the mysql server might be /usr/libexec/mysqld .
use psa

Once you're logged in run this sql to change the password:

  1.  

Now get out of the mysql client ( CTRL+C) and restart mysql to have privilege verification back or else everyone would be able to do what you just did:

  1.  

Now you can login to plesk with the new password.

debian: building custom exim packages

This is a small howto that explains how to build custom exim4 packages on debian.

It was tested with both exim 4.63 ( on debian etch ) and exim 4.69 ( on debian testing/lenny ) .

I needed to build a custom exim email server that would be built with domainkeys and/or dkim support for signing outgoing messages.

So here are the 12 steps I took to get this done:

  1. Create a directory named exim where all activity will take place.
  2. Make sure you have the 'source' URIs in your source.list file.
    If you don't have them put them in  and then run apt-get update
  3. Install packages required for creating a custom package and building it:
    1.  
  4. Install exim4 source package:
    1.  
  5. unpack standard configuration files:
    1.  
  6. Define the new package name. In this step we just put the new package name in a variable and export it in the environment to make the next steps easier. You can use anything for the package name ( actually it's just a package name suffix ) but I recommend using 'custom' for the package name for one main reason: dependencies. Packages that depend on exim4-daemon-light or exim4-daemon-heavy (like sa-exim, mailx and maybe others ) already accept exim4-daemon-custom as a replacement so with this custom package you're not breaking any dependencies.
    Ex:

    1.  
  7. Edit configuration files. There should be 3 EDITME configuration files for exim and one for eximon, one for each package that will be built. Copy one of the exim EDITME file to EDITME.exim4-$your_pkg_name then edit the new file to set up the new options you want.
    Ex:

    1.  
  8. pack the configuration files so your new configuration will be saved and used at build time:
    1.  
  9. Create the custom package. This is required only if you use a package name other then 'custom':
    1.  
  10. Activate the new package in debian/rules. Edit debian/rules and look for the line where the extradaemonpackages variable is defined and add your package name ( exim4-daemon-$my_pkg_name ) to the list of packages defined there.
  11. Install build dependencies. You can skip this step if this is not the first time you build this package.
    1.  
  12. Build the packages:
    1.  
  13. Install the new package. if you already had some version of the exim4-daemon package installed you will have to remove it first and then you can install the custom package. The new package will be in the base directory created at step 1.
    Ex. (for amd64 etch exim 4.63-17 ) :

    1.  

This process went pretty well for both exim 4.63 and 4.69 on lenny. Exim 4.63 only had experiemental support for domainkeys ( not dkim ) and exim 4.69 on lenny had support for both but I was only able to build it after applying a small patch to exim to make it work with the latest version of libdkim ( 1.0.19 ) .

This post was intended to be a general howto about building a custom exim package. I will write more details about actually building exim with domainkeys and/or dkim in a future post.

realtek 8180 on kernel 2.6.23

To make RealTek 8180 wireless cards work in Linux you need the open source drivers from rtl8180-sa2400. Actually this driver supports more realtek cards not just 8180, you can get the list of supported devices from their homepage.

The only problem with those drivers is that they are a bit outdated. They were initially build sometime in 2005 at a time when the kernel version was 2.6.12 . Since then there were patches released to make those drivers work with newer kernels and the latest patch I found was for kernel 2.6.22.You can download the patch from sourceforge . I downloaded that and it just complied and installed without problems.

I loaded the following kernel modules in the exact order :

  1.  

At this point I got the card working but there was no security. I knew this card supports WEP encryption and I was trying to set up a link between the card and a linksys WRT54G router that can also do WEP. When I tried to set a key (WEP ) I the card told me setting a key was not supported by hardware and I got the following error in dmesg: rtl_ieee80211_crypt_wep: could not allocate crypto API arc4

This was very weird because I knew I already loaded the arc4 crypto module . Then why doesn't it work?
After digging a bit in the code I realize that the ecb module is also needed for kernel versions higher then 2.6.15.

After I loaded the ecb module I was able to set a key with iwconfig and the link was up.

To summarize...
in order get this driver working you have to compile your kernel with the following options:

-> Networking
-> Networking support (NET [=y])
-> Wireless
-> Improved Wireless API

for the wireless tools ( iwconfig ) to work
Device Drivers
-> Wireless LAN
I'm not sure if this one is really needed cause the rtl8180 drivers user their own 802.11 stack but it doesn't hurt to enable it as a module, and if you have other wireless devices or you want to ue your card as a host ap you may need tis anyway.

From the Cryptographic API make sure you select ARC4 and ECB

After you compile the kernel you need to load the modules like this:

  1.  

bring up the interface :

  1.  

and set the ESSID and key with iwconfig in order to connect it with the Access point

  1.  

If everything went well you should see something like: wlan0 802.11b linked when typing iwconfig
Next i will try to configure this card to be used as a Host AP.
Did any of you try that ? feel free to share your experiences in the comments.

Update:

There is a new project that forked the rtl8180 driver and ported it to the new 802.11 stack in 2.6.23 kernel. This new project was already included in 2.6.23 but at the moment only support for  rtl8185 is available. The project is rtl-wifi and you might want to watch their page for when they add support for 8180

Linux apps anywhere

LINA is a virtual machine that aims to run linux applications on any operating systems.

The concept is similar to the Java VM, write your application in C, C++ ( and other languages supported in the future ), compile it with LINA and it will run on Windows, Linux, Mac OSX and maybe other OS. You will be able to run command line programs as well as gui applications that rely on GTK or QT and they will look native to the OS were you will run them.
Of course there is some overhead that will make your applications around 2x slower, but they say the performance will improve.

LINA VM and the tools that will be used to compile applications will be released using a dual license similar to MySQL's licensing model: GPL for those that release their applications under GPL and commercial for those that want to release proprietary applications.

The developement seems to have started 4 years ago but nothing has been released yet. The plan is to release the virtual machine and compiler tools this month.

Yet another perfect server

A of howtos start like that "The perfect Server" or "The Perfect Descktop" or "The perfect Setup". Howtoforge has lots of howtos like that. Their latest "the perfect server" literally shows you, ( because the howto has more screenshots then words 🙂 ) how to install Centos 4.5 and the servers that you need for hosting sites with mysql, php, email ftp and a control panel - ISPConfig.

A howto for each version

This is not their first "the perfect server for centos" howto, they had one for centos 4.4 and one for centos 5.0. Wonder how much different is Centos 4.4 from 4.5 and more exactly how much different if the howto for 4.4 from the one for 4.5? Well they replaced the version everywhere in the text and luckily the install gui was similar so they did not have to change the screenshots :). For 5.0 they did not have so much luck, they had to change the screenshots, and a add some more.

Made for Robots

What I don't like about these kind of howtos is that they don't explain much about the software you're installing, and they don't tell you why you do what they tell you to do. At some point they show you a screenshot and the only text is "in the next screen click next". That's not very useful, you don't learn anything like that. If something goes wrong or if you're trying to set things up on a different distro or disfferent OS you will not know what to do unless you're lucky to find a similar howto for your distro.

One other thing I don't like is that they show you even how to install Centos. Why not do a separate howto just for that, this way I will not get bored by those installation screenshots and they would get more space for writing some more/good details about what they are doing.

the ubuntu buzz

there seems to be quite a buzz about ubuntu these days,. Digg and other similar sites are full of stories about "the perfect ubuntu setup", "the perfect ubuntu server" and others like that.

Well maybe not today cause now we have bigger problems.

We're shocked by engadget's / apple , iphone delay anouncement 🙂 , even though they also announced it was a mistake, basically fake news, apple fanboys seem to be still affected by it.

Another "big" problem seems to be with the Microsoft announcement that linux code infringes their patents ( come on ... you want more then novel and dell ? is red-hat the last one ? ) I think they also tried this back 2004 but this time they specified the exact number that each subsystem infringes ( kernel, email , gui ... ) so we're back at the old "linux contains code patented by microsoft FUD" but after this we sould see some more ubuntu stories.

Oh yes ubuntu is so hot, especially now that dell will ship desktops preinstalled with ubuntu.

I was never eager to try ubuntu, I don't know why but the whole "linux for human beings" didn't catch me. I guess I never knew linux was not for human beings before ubuntu.

Anyway few days ago I did my first ubuntu install. Can you believe that ? my first. and guess what ? I installed it on a brand new dell inspiron 1501 that had freedos pre installed.

First impression: ubuntu is not bad at all. But I didn't really get the chance to use it for more then one hour cause it was not my computer. My wife's friend just bought her computer and she wanted windows there but ended up with ubuntu 🙂 .

Good experiment, overall she liked it and still using it.

freebsd 7.0 outperforms linux

The development version of FreeBSD ( 7.0 ) seems to scale a lot better then linux on SMP systems.

A combination of latest freebsd scheduler ULE 2.0 that is built into FreeBSD 7.0, the libthr threading library and a patch (not commited, yet ? ) that addresses poor scalability of file descriptor locking and some other patches is what made a system with 8 core amd64 cpu and 16 GB of ram outperform linux by a factor of 4 in MySQL tests.

The tests were performed using sysbench OLTP benchmark, a tool designed for testing mysql performance.

Brief test results: Linux is actually a little ( ~ 2% ) faster then FreeBSD for less then 9 clients, but when the number of clients grows to 20 linux performance drops a lot and FreeBSD's performance stays the same.

More details about the test here:

http://people.freebsd.org/~kris/scaling/mysql.html