Tuesday, December 26, 2006

A Strange ICQ Message

Today, I received a very strange ICQ message from one of my friend:
Hi, you've just received a postcard.

To view the postcard click this link or copy it to your browser's address bar.
http://cards.vertionpilinhertunfendsa.com/1/show.xml?id=201e624becfd36e0b7663089da805de0

The postcard will be kept for 10 weeks.
The link in the message points to an executable file named "postcard_flash.exe". Why does a postcard need to be executable? It most likely is a virus or a worm. From the Internet, I found some information about this kind of virus:
http://www.sophos.com/security/analyses/w32mydoomal.html
A very "clever" worm which spreads via email and ICQ messages. The worm tries to disable the firewall, as well as anti-virus program. Moreover, the worm changes the HOST file to prevent the compromised computer connecting to anti-virus and security web sites.... So what! I am using Linux.

Thursday, December 21, 2006

C Macro Tricks

If you know C programming, you should know C macro as well. Macro is very powerful. However, it also makes the code difficult to read, especially macro with multi-level expansion. In complication of source code, the macro expansion is handled by "C Preprocessor". To do trouble-shooting on macro expansion, we can use the "-E" option in gcc. The "-E" option tells the compiler to stop after "C Preporcessor". With "-E" option the output file of gcc will be a text file containing the source code with all macro expanded and #include files merged.

Thursday, December 14, 2006

gdb stops at SIGPIPE

By default, gdb captures SIGPIPE of a process and pauses it. However, some program ignores SIGPIPE. So, the default behavour of gdb is not desired when debugging those program. To avoid gdb stopping in SIGPIPE, use the folloing command in gdb:
handle SIGPIPE nostop noprint pass

Saturday, December 09, 2006

Installing Solaris 10 x86 in VMWare


Yesterday, I tried to install Solaris 10 x86 in VMWare virtual machine. Overall, the installation was quite smooth. I faced a little problem in the harddisk partitioning stage. I selected "auto-layout" but failed at first time. Then, I went back one step and try "auto-layout" again and it worked for second time. Maybe there is a bug in the installation.
After installation, the resolution of X window was low. I had to run "/usr/X11/bin/xorgconfig" to config the resolution.
Next, I installed vmware-tool for Solaris. After installed the vmware-tool the NIC is changed from pcn0 to vmxnet0. So, I need to copy the hostname.pcn0 to hostname.vmxnet0 and dhcp.pcn0 to dhcp.vmxnet0.
Then, I tried to run mozilla to check the Internet connection. Unluckly, the browser always report unknown host. I have verified the "/etc/resolve.conf" for DNS setting. It is correct. I also tried to use "dig www.google.com" to resolve the IP address successfully. Finally, from forum of Internet, we had to modify the "/etc/nsswitch.conf" as well.... -.-"

Friday, December 08, 2006

Linux VPN Client for Cisco VPN Router

The desktop of my office is in private network behind a firewall. If I need to access the desktop of my office, I need to use VPN by connecting the Cisco VPN Router in my office. It is not a trivial task to connecting VPN router in Linux platform, and there are seems several ways:
  1. Use the official Cisco VPN Client for Linux. During the installation, it needs the kernel headers for module complication. It should work in most cases. However, this software package is not freely available and open source.
  2. VPNC is an open source VPNC client target for cisco3000 VPN Concentrator. It works well for me. However, some features are not supported, e.g. re-keying, digital certificate authentication....
  3. Openswan is an implementation of IPsec for Linux. It is not only a VPN client, it can act as VPN router. I found some document about how to use Openswan for connecting Cisco VPN router. However, it fails in my Ubuntu box :<.
There is some web pages mentions that the XAuth of Cisco VPN router is non-standard. No wonder open source software packages don't support it well.


Free Advertising for Your Blog

Here is some suggestion for advertising your blog. First you can register your blog to some blog directories:
Second, you can reply posts in some popular newsgroups and forums. Include your blog's info in the signature of your replies.
Third, ask your friends to add the link of your blog in their homepage or blog.
The more web pages pointing to your blog, the higher ranking you can get in Google's search engine. To know the ranking of your homepage for some specific keywords in search engines, you can visit http://www.googlerankings.com/index.php. Now, it supports Google, MSN Search, Yahoo and Ask Search.

Friday, December 01, 2006

Ubuntu with Compiz

Compiz is a window manager with amusing visual effects. You can find some screen captures in YouTube. Yesterday, I installed Compiz in my Ubuntu (Edgy) Linux and it works great. The following the screen capture of my desktop:



The following is the How-to about installing Compiz in Ubuntu:
http://gandalfn.wordpress.com/howto/howto-compiz-aiglx-on-edgy/

Sunday, November 26, 2006

Rename a JPG File to Photo Taking Time

If you use DC to take photos, the file names are in form of a prefix following by a sequence number. This form of file name is meaningless and not convenient for looking up. Recently, I found a tools called jhead which can rename JPG files to their photo taking time in a batch. To do the batch renaming, just issue a single command:
jhead -n%Y%m%d-%H%M%S *.jpg
jhead is more than a file rename util. It is a exif Jpeg header and thumbnail manipulator utitliy. Please visit jhead's web site for details: http://www.sentex.net/~mwandel/jhead/

Friday, November 24, 2006

STL list size() method is slow

In STL list, the size() method is o(n), where n is number of elements in the list. The implementation of size() is by traversing the linked list and counting the nodes one by one. So, it sounds stupid.
I have written a simple program to test the performance of size() method in STL list and STL vector. For a STL list with 10M integers, it takes 0.17 sec. to get the size. However, for a STL vector with 10M integers, it takes 0.4 micro sec to get the size() in same machine.
There are some suggestions:
  1. Use vector instead of list.
  2. If the application need to check whether the list is empty or not, uses "list.emtpy()" instead of "list.size() != 0".
  3. use an extra counter variable to counting the size of a list.

Sunday, November 19, 2006

VMWare Server with ALSA DMix

In Linux, the sound-card drivers normally do not support concurrent access. This means when you playing MP3, your instant-chat program (e.g. gaim) will be mute. To solve this problem, there are some projects -- ALSA DMix, ESD, ARTSD, JACK.... However, most of them are not compatible each other and the applications needs to use the API provided by the specific project.

In my Ubuntu desktop, I use ALSA DMix with ESD approach. Most applications should support ALSA or ESD. However, VMWare support neither of them. VMWare only use native /dev/dsp device for sounding. After some searching on the web, we can use the LD_PRELOAD libossa.so trick.

After half day of try-and-error, the following is the summary of how to make VMWare work with ALSA:
  • make sure you installed the package "olsa-oss".
  • add suid bit to /usr/lib/libaoss.so by command chmod +s /usr/lib/libaoss.so
  • rename the /usr/lib/vmware/bin/vmware-vmx to vmware-vmx-real
  • create a shell script /usr/lib/vmware/bin/vmware-vmx with the following contents
#!/bin/sh
LD_PRELOAD=libaoss.so exec /usr/lib/vmware/bin/vmware-vmx-real $@
  • make sure the shell script is executable (i.e. chmod a+x /usr/lib/vmware/bin/vmware-vmx-real)
  • If your guest OS's disk image file is "single growable virtual disk" type with size large than 2G, you should use the vmware-vdiskmanager to split it into several files. Otherwise, you will encounter the problem of "File too large".
Related Link:
A Post about VMWare works with ALSA
ALSA DMix

Friday, November 10, 2006

Switch To Ubuntu

I have been used Linux as my primary desktop OS since 2001. At that time, I used Mandrake because it was easy to install. Then I switched to Debain because of its good package management and package update. Today, I decided to switch to Ubuntu.

Ubuntu is based on Debian's package management and adds user-friendly installation. No wonder Ubuntu is the most popular Linux distribution (http://distrowatch.com).

Today, I tried to install Ubuntu and don't encounter any difficulty. It can auto detect and configure all my hardware (sound card, video card, network card....). So, everything works properly!

One year ago, I have tried to install Ubuntu and I found it was not mature. So, I remained to use Debian. Now, Ubuntu 6.10 is much better. I love it!

Saturday, January 07, 2006

Does MTU matter?

Recently, I have changed my ISP to HKBN. I chose the plan BB10 which provide 10Mb upload and download speed. This is much better than ADSL. For such high bandwidth, I want to use my NSLU2 Linux box to setup a web server at my home.

However, there is some problems. I found that not every machine can access my web server. Ellen using Pacific Supernet cannot access the web server. Besides, a friend of mine using Netvigator faces the same problem. However, the W3C's HTML validate can access my web server to validate my HTML files. Moreover, my company can also access the server.

This is really strange. Today, I try to tackle the problem. I tried to set the server in DMZ at my router but fail. Then, I look for other setting in the router's configuration. I find the item "MTU". MTU stands for "maximum transmission unit". Currently setting is 1500 which is the maximum allowed value. I try to change the value smaller to 1400. It works! However, I want to ask, "Does MTU matter?".