"; */ ?>

howto


7
Jan 09

Install Adobe Flash Player Firefox Plugin

Flash Player on Ubuntu

Since I upgraded one box to Ubuntu 8.04 (Hardy Heron), and another box to Ubuntu 8.10 (Intrepid Ibex), it was quite irritating for some time to watch youtube videos with no or flaky sound along with skipping videos.

In Firefox, when I went to “Tools -> Add-ons -> Plugins”, or just typed “about:plugins” in the address bar, I saw that I do have “Shockwave Flash 9.0 r124”, however it just dis not want to work smoothly. The same was true for “”Shockwave Flash 9.0 r100”.

So you would think that the right thing to do was to go to the Adobe website: “http://get.adobe.com/flashplayer/“, choose “get the one for Ubuntu 8.04+” option, and download the latest (v10 / v11 / v12 / v13 / v14 / whatever…) flash player, right? Well, not really. After I did that, I saw both “Shockwave Flash 9.0 r124” and “Shockwave Flash 10.0 r15”, so I disabled 9.0 one, and enabled 10.0 – should be good right? NOPE.

What appeared to be the solution for this mess of flash plugins was to do some “sudo apt-cache search flash…” searches, and figure out what needed to go from both systems.

There were two culprits that overruled the only enabled “Shockwave Flash 10.0 vr15” plugin: “swfdec-mozilla” and “mozilla-plugin-gnash”. And hence they are going to be removed with all other potential inconsistencies:

sudo apt-get remove -y --purge flashplugin-nonfree gnash gnash-common mozilla-plugin-gnash swfdec-mozilla libflashsupport nspluginwrapper
sudo rm -f /usr/lib/mozilla/plugins/*flash*
sudo rm -f ~/.mozilla/plugins/*flash*
sudo rm -f /usr/lib/firefox/plugins/*flash*
sudo rm -f /usr/lib/firefox-addons/plugins/*flash*
sudo rm -rfd /usr/lib/nspluginwrapper

After this, I had a good feeling and went to http://get.adobe.com/flashplayer/ again, chose “get the one for Ubuntu 8.04+”, saved “install_flash_player_version_linux.deb” locally, and install it with my bare hands:

sudo dpkg -i install_flash_player_10_linux.deb

Restarted Firefox, and let me tell you – Quality of my Ubuntu life has improved significantly since then!
Want to improve the quality of your life significantly? Follow the two steps above :)


6
Jan 09

Find USB flash drive device in Linux

Find USB drive in Linux / Unix

Recently I have written a quick “how to” on restoring, formatting a USB flash drive. The “how to” had a lot of hits from different places since then, mostly from GOOGLE, of course, but some from independent bloggers, like my blogging self.

One of such places was www.newlinuxuser.com. Although the guide “saved them” (welcome :)) they had a very constructive critique that one thing the guide missed was how to actually find which device to restore / format.

Hence I decided to write a new little 2 step “how to” that will teach you just that.

Step 1. System Log is your friend, listen to what it has to say…

Imagine you close your eyes, and someone puts an apple in your mouth – would you be able to identify what the heck was put into your mouth? For most people the answer would be “yes”. ( If you’d like to experiment, feel free :). The thing is once you bite on that apple, your brain goes through many lines of code (given that we are written in C), finds that match, and reports:

"The object in your mouth was identified as an Apple - we've had that before.
  I just talked to the stomach, it knows how to digest it."

You would think that your Linux/Unix system is any different? Well, not really.

Right after you insert a USB device into a slot, Linux/Unix will try to read, and identify it. While doing that, it will also assign it to a particular device as “/dev/particular-device”. This device is exactly the information we need, so we can talk to it, and mount it.

Although most people would approach it with running a dmesg, and look at the output, I prefer a more natural OS way to look at things – we’ll look directly in the eye of a System Log!

Let’s use “tail -f”, so we can see real time system log updates:

tail -f /var/log/messages

Now insert your USB drive into a slot and you should see the output similar to:

Dec  5 14:53:19 your-hostname kernel: [81585.308993] usb 4-1: new full speed USB device using uhci_hcd and address 3
Dec  5 14:53:19 your-hostname kernel: [81585.456757] usb 4-1: not running at top speed; connect to a high speed hub
Dec  5 14:53:19 your-hostname kernel: [81585.484884] usb 4-1: configuration #1 chosen from 1 choice
Dec  5 14:53:19 your-hostname kernel: [81585.498817] scsi6 : SCSI emulation for USB Mass Storage devices
Dec  5 14:53:24 your-hostname kernel: [81590.514870] scsi 6:0:0:0: Direct-Access     USB 2.0  USB Flash Drive  0.00 PQ: 0 ANSI: 2
Dec  5 14:53:24 your-hostname kernel: [81590.519874] sd 6:0:0:0: [sdb] 15794175 512-byte hardware sectors (8087 MB)
Dec  5 14:53:24 your-hostname kernel: [81590.522834] sd 6:0:0:0: [sdb] Write Protect is off
Dec  5 14:53:24 your-hostname kernel: [81590.534817] sd 6:0:0:0: [sdb] 15794175 512-byte hardware sectors (8087 MB)
Dec  5 14:53:24 your-hostname kernel: [81590.537814] sd 6:0:0:0: [sdb] Write Protect is off
 
>>>>  Dec  5 14:53:25 your-hostname kernel: [81590.537888]  sdb: sdb1  <---- GOT YOU!
 
Dec  5 14:53:25 your-hostname kernel: [81590.654848] sd 6:0:0:0: [sdb] Attached SCSI removable disk

Note that the USB drive was “connected”, or associated with sdb device

[81590.654848] sd 6:0:0:0: [sdb] 15794175 512-byte hardware sectors (8087 MB)

and more precisely, with sdb1 device

[81590.537888]  sdb: sdb1

And that means we can talk to it! The full name of the guy would be “/dev/sdb1”.

Now let’s greet our friend. Say: “Hi /dev/sdb1”! :)

Step 2. Mount USB drive’s device to the File System.

Just an extra step, in case you need to mount it. If you can’t, and would like to format it, so you can mount it afterwards, read this.

To mount the drive enter this:

sudo mount -t vfat /dev/sdb1 /media/usbdrive/

where “/dev/sdb1” is the name of the device, we found in the step above. “/media/usbdrive/” is the directory that we are going to mount it to. Make sure this directory exists (otherwise create it “sudo mkdir /media/usbdrive/”). And “-t vfat” is asking your Linux/Unix OS to mount this device as a “vfat” (FAT16, FAT32) device.

Many, if not most, USB devices are VFAT, however if you have an NTFS USB hard drive, for example, you can mount it by entering:

sudo mount -t ntfs-3g /dev/sdb1 /media/usbdrive/ -o force

“sudo” in above couple commands comes from mostly Ubuntu way to “run command as a super user”. If you have any other flavor of Linux/Unix, you may want to just run it as a “root” user.

Eat more apples, and good luck!


17
Nov 08

Configure iwl3945 Driver on Ubuntu

It is quite frustrating when you have a wireless card built in, but you cannot use it – don’t you agree? That seems to be the case for wifi cards that are served by “iwl3945” driver. One of such examples can be “Intel Corporation PRO/Wireless 3945ABG” card.

Before, ( e.g. Feisty and earlier ) “ipw3945” driver was used instead, and worked beautifully with Intel cards. However the active development of this driver has stopped a couple of years ago, which means that security risks that were identified in the last couple of years were not patched. Therefore Ubuntu community switched to a more recent and supported “iwl3945” driver.

However that created a problem with NetworkManager that is used as a default network user interface in (Gnome) Ubuntu. It appears that in order “to be compatible with NetworkManager, a wireless driver must support both hardware and software scanning. Currently, hardware scanning is faster and more reliable and so is recommended for use with NetworkManager“. But unfortunately “iwl3945” driver does not support hardware scanning very well, however it is a default behaviour that NetworkManager expects.

But usually, and that is what I love Ubuntu for, if there is a problem, there is 99.9999% a solution to this problem. So this how to will help you solve it, and enjoy your Intel Wireless card with Ubuntu, despite of inconsiderate (in this case) NetworkManager.

1. Remove the bad guy

sudo apt-get remove network-manager

2. Disable “iwl3945” hardware scan

sudo vi /etc/modrobe.d/iwl3945

enter:

	alias wlan0 iwl3945
	options iwl3945 disable_hw_scan=1   # <-- enables software scanning

and save it (:wq).

At this you might want to restart or (optinal) just re-insert the module like this:

sudo modprobe -r iwl3945
sudo modprobe iwl3945

3. Install the good guy

Here you’ll install “the good guy” – his/her name is WICD:

Add wicd’s repository to Ubuntu sources:

sudo vi /etc/apt/sources.list
	 deb http://apt.wicd.net intrepid extras

(if you have Hardy Heron, then add “deb http://apt.wicd.net hardy extras” instead)

Update repositories

   sudo apt-get update

Install wicd “the normal Ubuntu way”:

   sudo apt-get install wicd

4. Run the good guy

   wicd-client

or restart, it should run automatically.

Happy wifying!


10
Nov 08

Configure Simp Server to Encrypt IM clients in Linux

Recently many companies started to inject their security policies with securing IM communication. It makes sense, since everything you type in that chat window to your buddy flies over the network in a clear text. That does not sound to bad, you think, but what it really means, is if anybody wanted to see what you are talking to your colleague, or even to your wife, about, s/he can see it easily by reading your network packets – which is a very easy thing to do now days.

Another example could be the client whose policy is to monitor all the incoming/outgoing network request, and you want to talk over IM to your colleague about something that you do not want your client to see.

Below I’ll show you how to secure you IM communication with SimpServer: http://www.secway.fr/us/products/simpserver/ on Unix client/server boxes. I am going to use Ubuntu here as an example, but it should work for most if not for all Unix flavours.

1. Get the SimpServer.

According to the liink above “SimpServer is currently beta software and is free for any use”, hence let’s get it for free from here:

wget http://download.secway.com/public/products/simpserver/simpserver-2.1.5c-linux-x86.tgz

2. Install the SimpServer.

Before untarring it, let’s make sure the standard C++ libraries that SimpServer uses are installed:

sudo apt-get install libstdc++5

Now let’s untar it and move to “/usr/local” – that is where it will search for its binary files, so make sure you do that:

tar -xvzf simpserver-2.1.5c-linux-x86.tgz
 
sudo mv simp/ /usr/local/

Go to “/usr/local/simp/bin/”, and run the SimpServer:

cd /usr/local/simp/bin/
 
./simpserver
 
----------------------------------------------------------------------------------
SimpServer Linux 2.2.1.5c - (c) Copyright Secway 2000-2005
All rights reserved
 
Visit http://www.secway.com/products/simpserver/ for updates.
Visit http://www.secway.com/support/ for support.
 
MSN Service on 0.0.0.0:11863, mode 1
MSN Service on 0.0.0.0:1863, mode 0
AIM Service on 0.0.0.0:15191, mode 1
ICQ Service on 0.0.0.0:15190, mode 1
YAHOO Service on 0.0.0.0:15050, mode 1
Admin Service on 127.0.0.1:10023, mode 0
 
----------------------------------------------------------------------------------

If there are any problems, grab the simpserver version that is offered here: http://www.secway.fr/us/products/simpserver/download.php

3. Configure the SimpServer.

While SimpServer is running, telnet to it (port 10023). Default “username/password” are “admin/admin”:

$ telnet localhost 10023
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
SimpServer Linux 2.2.1.5c - (c) Copyright Secway 2000-2005
All rights reserved
 
Visit http://www.secway.com/products/simpserver/ for updates.
Visit http://www.secway.com/support/ for support.
 
Login: admin
Password: admin

Let’s see what it is capable of by asking for “help”:

> help
SimpServer Linux 2.2.1.5c - (c) Copyright Secway 2000-2005
All rights reserved
 
Visit http://www.secway.com/products/simpserver/ for updates.
Visit http://www.secway.com/support/ for support.
 
 ?,        help                  print this help
 list,     list_keys             [all, public, private]
 generate, generate_private_key  [-e<account>] [-s<service>] [-c<cipher>] [-b<size>] [-n<name>] [-p
<password>]
 load,     load_private_key      -i<keyid> [-e<account>] [-s<service>] [-c<cipher>] [-p
<password>]
 unload,   unload_private_key    -i<keyid> [-e<account>] [-s<service>] [-c<cipher>]
 change,   change_password       -i<keyid> [-e<account>] [-s<service>] [-c<cipher>] [-o
<old_password>] [-p<new_password>]
 delete,   delete_key            -i<keyid> [-e<account>] [-s<service>] [-c<cipher>] [-force] [-pendinf]
 accept,   accept_pending_key    -i<keyid> [-e<account>] [-s<service>] [-c<cipher>]
 quit,     exit                  exit

4. Create private/public certificates.

Notice that the “list” command, from the above help, shows all/public/private keys, including your public/private key, and all your IM buddies that you are talking to.

Let’s try to see what keys we have right away (without doing anything yet):

> list
Prv  Loaded KeyId             SHA-1 fingerprint                                   Date        Type         Srv  Name
--------------------------------------------------------------------------------------------------------------------

As you can see, we have no keys – because for now we have neither “secure/encrypted” IM buddies, nor our public/private key pair.

Hence start by by running a “generate” command that would create your the key pair (link to certificates article) that will be used:

> generate
generating the new key pair, please wait... done!
new key: 278dc025d92cdbc4  b14e 7b16 6415 e88f 2a67 2fe6 2e31 579b 580e 1a89   2008-10-16  RSA-2048  [admin] KeyPair

Now let’s “list” the keys again:

> list
Prv  Loaded KeyId             SHA-1 fingerprint                                   Date        Type         Srv  Name
--------------------------------------------------------------------------------------------------------------------
Yes  Yes    278dc025d92cdbc4  b14e 7b16 6415 e88f 2a67 2fe6 2e31 579b 580e 1a89   2008-10-16     RSA-2048    *  [admin] KeyPair

Perfect – you have your own “KeyPair”, that will be used to authenticate and encrypt communication from your IM buddies.

5. Connect IM clients to the SimpServer.

Next, let’s connect to our SimpPro / SimpLight / etc.. IM buddies. Here is an example on how to configure “Pidgin” to use a SimpServer:

For example you’d like your work AIM account to “follow the company standards” and use encryption via simp server. Here is what you should do

Go to "Accounts" -> (Choose your AIM account) "Edit Account" -> "Advanced"
 
Choose "SOCKS4" in "Proxy Options"
 
type "127.0.0.1" in Host
type "15191" in Port

Pidgin SOCKS4 settings

Why “127.0.0.1”? Because you have started the SimpServer on your local box. By the way, you can start the server on one box, and use it from many other PCs by entering IP address of that box to the “host” field for the proxy settings of the account in your IM client.

Why “15191”? Let’s look at the server output once again:

MSN Service on 0.0.0.0:11863, mode 1
MSN Service on 0.0.0.0:1863, mode 0
AIM Service on 0.0.0.0:15191, mode 1
ICQ Service on 0.0.0.0:15190, mode 1
YAHOO Service on 0.0.0.0:15050, mode 1
Admin Service on 127.0.0.1:10023, mode 0

We see that “AIM Service” listens on the port “15191”.

6. Start using the SimpServer with your IM client(s).

Now when you send an IM to anybody who runs SimpPro / SimpLight / or just a Simp Server, they would get a pop up asking them to accept your message. After they do accept it, your public key ( one of the keys that was generated by the “generate” command ) will be added to their Simp database. Same thing will happen when they ping you or respond to your IM encrypted message – their public key will be added to the simpserver:

Here is an example of what happens initially, when there is a new “Simp-Oriented” buddy pings you:

(2008-10-16 15:16:09) BuddyName: *** (*) SimpServer Linux 2.2.1.5c - Encrypted and Authenticated (*) ***
(2008-10-16 15:16:09) BuddyName: Hey, that is cool - so now our messages are encrypted...!

And now you can go back to your “telnet” session and “list” the keys again:

> list
Prv  Loaded KeyId             SHA-1 fingerprint                                   Date        Type         Srv  Name
--------------------------------------------------------------------------------------------------------------------
Yes  Yes    278dc025d92cdbc4  b14e 7b16 6415 e88f 2a67 2fe6 2e31 579b 580e 1a89   2008-10-16     RSA-2048    *  [admin] KeyPair
 No  N/A    0f2292a9d40c2f90  ab1d 6f78 6bff a03e 892a 34df 2b3a 26e7 16ff cbb9   2008-10-16     RSA-2048  AIM   <buddy1Name>
 No  N/A    62f02d7e858e0139  c315 616f 8518 d9c8 9827 e4c4 d8b4 2448 06f7 4278   2008-10-16     RSA-2048  AIM   <buddy2Name>

Notice that now you have your own “KeyPair”, a public key for “Buddy1Name”, and a public key for “Buddy2Name”.

Happy Secure IMing, and don’t abuse your secrecy :)


24
Oct 08

Getting Return Code from ANT in SHELL

This short tutorial shows how to get an exit code from Ant and act upon it. This can be useful when building a massive application that requires several Ant scripts/targets and a collection of shell scripts.

The rule of thumb when building the system is “when it should fail -> it should fail”. Sounds weird, but it is really true.

If the whole build of the application takes 15-20 minutes, and one of the libraries failed to build (for example), the whole build should fail. Otherwise, if the build master inspects the logs, and sees something went wrong (in case it is logged), s/he would have to spend another 20 minutes to rebuild it. Or what is even worse, the application could end up in an inconsistent state, without anybody raising a flag, and that would be very dangerous, especially if the current release goes beyond integration builds, for example to quality assurance or even worse – to production.

So, above are the reasons, below is an ultra simple example with a solution:

Let’s say we have an Ant script (build.xml) that checks for duplicate jars in a directory. The target name that does that is “check-duplicate-jars”:

build.xml:

    <target name="check-duplicate-jars" depends="some-other-task">
        <!-- does its magic here -->
    </target>

Let’s say we also have a simple shell script that calls “ant “. If this shell script is in the same directory as the “build.xml”, we can call it like this “./callant.sh check-duplicate-jars”, and it should check if there are any duplicate jars. Let’s run the shell script:

[user@host]$ ./callant.sh check-duplicate-jars
ANT: Running check-duplicate-jars task...
Buildfile: build.xml
 
check-duplicate-jars:
     [echo] Checking for duplicate jars......
     [exec] ***********    NO DUPLICATE JARS FOUND IN LIB!    ***********
 
BUILD SUCCESSFUL
Total time: 3 seconds
ANT: Return code is: "0"
GREAT SUCCESS: Niiice - I liiike!

This is an expected behavior. However what would be nice is to have this shell script “fail hard”, in case the Ant script (build.xml) fails.

Let’s try to misspell the target name “check-duplicate-jar” (should be plural: “check-duplicate-jars”) and run it:

[user@host]$ ./call-ant.sh check-duplicate-jar
ANT: Running check-duplicate-jar task...
Buildfile: build.xml
 
BUILD FAILED
Target `check-duplicate-jar' does not exist in this project.
 
Total time: 1 second
ANT: Return code is: "1"
BUILD ERROR: I am failing hard...

Wonderful – it failed! That is an expected behavior. And here is a sneak peek to the magic box – the “callant.sh” shell script:

#!/bin/bash
 
tname=$1
 
echo "ANT: Running $tname task..."
ant $tname
 
antReturnCode=$?
 
echo "ANT: Return code is: \""$antReturnCode"\""
 
if [ $antReturnCode -ne 0 ];then
 
    echo "BUILD ERROR: I am failing hard..."
    exit 1;
else
 
    echo "GREAT SUCCESS: Niiice - I liiike!"
    exit 0;
fi

Hence the whole magic is here:

antReturnCode=$?

In general, “$?” will return an exist code of any executable run within the shell script.
Well, now you ready for the massive build process. Get to work, and may the build force be with you! :)