Hui WANG's Blog

One will, One way

No Sound Input in Ubuntu 9.10

As I’m using a beta version of ubuntu 9.10, plenty of updates are installed before its final release.  In the beginning,  skype 2.1 is working with pulseaudio like a charm. The sound quality is much improved than any of the former skype-ubuntu combination  Maybe it’s because of the frequent updates. There is no longer sound input after a normal reboot.

Luckily, after a few configurations by alsamixer, I’ve founded the lost sound.

At first, make sure sound card is correctly installed. You can check it by going system->preference->sound->hardware.

Then open a terminal and hit alsamixer. You can use Tab to switch between playback, capture and all.

Make sure capture is enabled. Then adjust PCM volume and set the Digital as digital not mixer nor analog.

capture

playback

sudo and environment variables

As a normal user, we have to use privilege-gaining tools such as sudo to run programs as the root user when required. With the super user rights in hand, are we still working in the same environments set by the normal user ?

The reason why I ask this question is that I’m losing the environment variables set in ~/.bashrc when running a bash script with sudo. For instance, the variable JAVA_HOME is set and exported in ~/.bashrc.

export JAVA_HOME=/usr/lib/jvm/java-6-sun

A bash script called example.sh will use this variable to find java home directory.

#!/bin/bash

echo $JAVA_HOME

When example.sh is invoked by the current user by typing

./example.sh

the output is exactly the expected one:

/usr/lib/jvm/java-6-sun

However, when trying with

sudo ./example.sh

We get nothing. The variable is lost or in a other word, not inherited.

In fact, I have found two solutions to preserve the evnironments varialbes exported in the parent shell.

Solution 1: add an option for sudo

sudo -E ./example.sh

Solution 2: invoke an interactive sub shell

#!/bin/bash -i

echo $JAVA_HOME

Hints and further questions:

According to the above two solutions, the lost of variables may be caused by sudo or bash or both. To explain these two solutions, I think, we should firstly figure out the behavior of sudo especially the effect of  env_reset in /etc/sudoers and then how the variables settings are handed form parent shells to sub shells.

Hopefully you can get your problem resolved and if you know why, please teach me.

OpenIMSCore Troubleshooting

The following list is composed to refer the errors or warnings which I have came across while my adventures with OpenIMSCore and some related topics. Most of the solutions are found in the OpenIMSCore mailing list. The current list is not complete and I will get it up to date regurlaly.  The sharing of your discoveries is warmly appreciated.

setkey: command not found
the inpse-tools are missiong
sudo apt-get install ipsec-tools

ping open-ims.test unkown hostname
the /etc/resolv.conf is automatically reset during restart, so we can lock and unlock it using the following two comands.
sudo chattr +i /etc/resolv.conf
sudo chattr -i /etc/resolv.conf

WARNING:peer_connect(): Error opening connection to to 127.0.0.1 port 3868 >Connection refused
cd /opt/OpenIMSCore/FHoss/deploy
sudo ./startup.sh

tcp badcheck sum

http://www.wireshark.org/lists/wireshark-users/200704/msg00107.html

P-Visited-Network-ID header missing
the request are probably sent to icscf instead of pcscf so make sure that the port pcscf is correctly configured by default it’s 4060

401 Unauthorized, challenging the UE

check the authentication method in the scscf.cfg file in your openimscore root directory and make sure Akav1-MD5 is being used.

403 target refresh outside dialog not allowed

it’s a stupid mistake, I’ve forgot about the call-id header when doing UPDATE

406 Initial Request Method not allowed at the I-CSCF
for the following subsequent request, the destination IP address is required instead of the url.

to be continued…

I no longer work on OpenIMSCore. Instead, the Ericsson IMS which is delpoyed in java may be a better choice. You can refer to Ericsson SDS.

how to setup an openssh home server in ubuntu

In this simple tutorial, I am showing you how to make the openssh server accessible via distance rather than just install several binary packages.

Anyway, we should firstly get the packages installed. Fire up a terminal and hit the following command:

sudo apt-get install ssh openssh-server openssh-client

Secondly, make sure the server is working correctly

sudo /etc/init.d/ssh restart

Thirdly, check whether the port 22 which openssh server is listening on is open. A package called Nmap is needed here. Run the following command:

sudo apt-get install nmap

If your computer is behind a router, please find the its public ip first, you can find it by connecting to your router’s web interface, typically by typing 192.168.1.1 in your preferred browser. If not get it directly by hitting ifconfig in your termernal.

Right now, with the public ip, run the following command:

sudo nmap -sS -O your_public_ip

Last, if port 22 is open, everything is done. Connect to your server with this command:

ssh your_user_name@your_public_id

If not, you must have at least another ONE open port from the result of nmap, and then configure your router to forward requests on this open port to the port 22. Typically in your router configuration table, you could find an column called NAT. The picture below is showing my configuration.
ssh_nat

Ok, get connected by using this command:

ssh your_user_name@your_public_ip -p the_open_port

Please feel free to let me know if it doesn’t work for you.

What webmasters have to know about file permissions

If you are a web master and get your website hosted in a Linux environment, but you are not very familiar with the Linux things, please keep reading. I hope this post could give you a further insight of file permissions in the Triple W filed. Or at least, bring you some ideas to get your hands dirty.

Let’s get started by looking at an example which could bring us into topics directly. An index.php file is created in WhuIsPublicFiles, just read it to get more informations http://www.hui-wang.info/WhuisPublicFiles/index.php .

I am not trying to get you confused, in contrast, it is the key point to understand file permissions. So what does 700 mean ? Yes, you are 200% right by saying that only the owner of the file is able to read it and all the others can do nothing with it. However, who is the owner ? The answer is simple, it’s me. Then who are you ? YOU are my dears readers, so you are not those “others”. The principle comes like as followings.

I get my site hosted by a web server, an apache server, in my case. It is 24/24h-7/7d there to listen to your requests. As I can’t do it for you like apache, I assign all my rights to the apache server. Apache server is running as me(Attention please, it is not always like this, apache can also run as someone else). You pass it an order by typing some kind of url in your browser, and with my rights, apache server returns you what you want. In fact, it is always a program that gets things done, and every program is running as some user. For example when we edit a text file, it is the editor that is editing it and surely with our rights assigned.

To conclude, whether your visitors could read your file depends on not only the three octal digits but also whom your web server is running as. If the server is running as the owner, your visitors are the owners and if your server is running as others, your visitors becomes the others.

P.S: All  posts in this site is for purpose of exchanging opinions. You are very welcome to give us yours if you have different ones.

Install SIPp in Ubuntu

The common problem we are meeting in installing sipp 3.1 in ubuntu is a declaration problem.

Probably this error will prevent you from completing the compile.

‘INT_MAX’ was not declared in this scope

Please add #include <limits.h> in the file header where it is missed.

If you like an all-in-one solution to install sipp, a deb package is available by default, but it’s not the newest version.

Type the following command to install sip with both openssl and pcap supported.

sudo apt-get install sip-tester

rndc: connect failed: 127.0.0.1#953: connection refused

I have installed bind9 in ubuntu 9.04. This error arises when I try to restart bind9 after some configurations.

To find out what is preventing bind9 from getting started,  your can use this command

named -g -p 53

18-Aug-2009 22:43:35.631 starting BIND 9.5.1-P2 -g -p 53
18-Aug-2009 22:43:35.632 found 1 CPU, using 1 worker thread
18-Aug-2009 22:43:35.632 using up to 4096 sockets
18-Aug-2009 22:43:35.642 loading configuration from ‘/etc/bind/named.conf’
18-Aug-2009 22:43:35.642 /etc/bind/named.conf.options:17: expected IP address near ‘{‘

18-Aug-2009 22:43:35.643 loading configuration: unexpected token
18-Aug-2009 22:43:35.643 exiting (due to fatal error)

Everything becomes fine after I change the expected IP to one contained /etc/resolv.conf.

Good luck.