Archive for November, 2006

Testing Secure Socket Connections

Thursday, November 30th, 2006

Often, telnet is used to test a server listing on a TCP port because if telnet can connect, then you know the server is listening. With simple text protocols like POP, you can do pretty extensive testing with telnet by just typing in commands. Testing a server that supports SSL can be done with the stunnel program. You need to download the pem file with the key and certificate, but after that, it isn’t much different than using telnet.

terry@m38:~$stunnel -c -r www.jeeptech.com:995 -p pop3.pem
+OK Hello there.
user terry
+OK Password required.
pass cleartextPasswd
+OK logged in.
list
+OK POP3 clients that break here, they violate STD53.
1 3721
2 5873
3 1020
4 15425
5 1955
6 8598
7 18708
.
quit
+OK Bye-bye.
terry@m38:~$

The order of contents of the .pem file is, it should contain the unencrypted private key first, then a signed certificate. There should be empty lines after the certificate and private key. Any plaintext certificate information appended on the top of generated certificate should be discarded.

—–BEGIN RSA PRIVATE KEY—–
[encoded key]
—–END RSA PRIVATE KEY—–
[empty line]
—–BEGIN CERTIFICATE—–
[encoded certificate]
—–END CERTIFICATE—–
[empty line]

Integrating bogofilter with postfix

Thursday, November 23rd, 2006

After installing bogofilter, integrating with postfix was fairly straightforward by following the steps in /usr/share/doc/bogofilter/integrating-with-postfix with minor tweaks.

The document shows you how to set up a script that will have bogofilter filter incoming mail. As identified in the bogofilter man page, you can have the result of the filter do a variety of things like add header lines with spam/non-spam ratings, add text to subject lines, automatically update your spam/non-spam dictionary, etc. I configured the script to add text to subject lines based on if bogofilter classified the mail as spam or unsure (non-spam goes through without any subject line change).

The only clarification to the integrating-with-postfix document was to make sure that the /var/spool/filter directory is owned by user filter user with permissions 0×755.

The only change to the bogofilter config in /etc/bogofilter.cf was to uncomment the “spam_subject_tag” and the “unsure_subject_tag” so those were turned on.

The /etc/postfix/master.cf file launches the necessary scripts for bogofilter as described in the integrating-with-postfix document.

Escaping the GUI in Linux

Thursday, November 23rd, 2006

If you want to escape the GUI in Linux, press ctrl-alt-F1 to get a tty style terminal session. There are at least six tty style sessions using the other function keys up to ctrl-alt-F6. Ctrl-alt-F8 will bring back the GUI. In Red Hat, it seems like it preserves the GUI, but under Ubuntu, your current GUI session is lost. Escaping the GUI is handy if it hangs or the mouse isn’t working. From the tty session, the machine can be repaired or rebooted cleanly.

Linux Box Booting GUI vs Terminal Mode

Thursday, November 23rd, 2006

If you are configuring a Linux box as a server, it is convenient to configure it to boot into terminal mode rather than GUI mode. This is especially true if it is hooked up to a KVM because Linux seems to get confused when it is hooked up to a KVM and the mouse won’t work. On RedHat boxes the default run state needs to be changed from 5 to something like 3 in the /etc/inittab file. For example:

id:3:initdefault:

On a Ubuntu box (and I assume all Debian boxes are like this), the default runstate is 2 and the GUI is started in all runstates except 1. This is the case if you load Ubuntu as a desktop which I generally do because it is nice to have the GUI to configure the server. In order to disable the GUI in runstate 2, don’t just remove the start script, move it so that the start script does not get recreated during an update:

cd /etc/rc2.d
mv S13gdm K01gdm

Any time you want to start up the GUI, all you need to do is change the runstate to a runstate that has the GUI.

init 5

Remote GDB for Embedded Developement

Wednesday, November 22nd, 2006

Sometimes it can be tough debugging a program built with a cross compiler for an embedded system. The embedded system might not have enough memory to run gdb. It probably has enough memory to run gdbserver though and this can be extremely handy.

The first step of running a remote gdb session with gdbserver is building gdb for the target platform that runs on the host. Download your desired gdb version and configure it something like this:

./configure --target="target-cpu" --host=i686-host_pc-linux-gnu
--with-headers=/path/to/headers/for/cross/compiler

On the embedded system, run your process under gdbserver and specifiy a port to listen to:

$ gdbserver host:1234 a.out

On your development system with the source code, run the gdb that you built.

$ ./gdb a.out
gdb> target remote 10.0.1.1:1234
gdb> c

Linux Installation rpm vs apt-get

Tuesday, November 21st, 2006

In the commercial world, there seems to be a lot more Red Hat than Debian work, so a lot of people end up doing a lot more rpming than apt-getting. But, who wants to load Red Hat or Fedora at home when they could load a Debian based distro like Ubuntu. The tough part is bouncing back and forth on the installation commands. It always seems like the GUI tools don’t cut it.

The following lists are Red Hat first, Debian second.

  • Package installation:
    • rpm -i packageName or up2date –install packageName
    • apt-get install packageName
  • Determine if a package is installed:
    • rpm -qa | grep packageName
    • dpkg -l |grep packageName
  • Get the latest updates:
    • up2date –install –channel channelName
    • apt-get update; apt-get upgrade
  • List the files in a package:
    • rpm -ql packageName
    • dpkg -L packageName
  • Find out what package provided a file:
    • rpm -qf fileName
    • dpkg -S fileName
  • Remove a package:
    • rpm -e packageName
    • apt-get remove packageName

Cpp Pre Processor #define Support for Compiler

Friday, November 17th, 2006

When you are doing a port or working on a new platform, you need to know what #defines are supported for the architecture and operating system. The following command reads nothing(/dev/null) and dumps the #defines:

cpp -dM </dev/null

GDB errno gets “Cannot access memory at address 0×8″

Friday, November 17th, 2006

When running GDB under Linux, I often want to see why a system call failed, but when I try to print errno, I get “Cannot access memory at address 0×8″. This is because errno is a macro for:

# define errno (*__errno_location ())

The solution to the problem is to print what the macro expands to:
(gdb) p errno
Cannot access memory at address 0×8
(gdb) p (*__errno_location ())
$4 = 1

Introduction

Wednesday, November 15th, 2006

Tiptop Software Company’s technical notes is our way of sharing we’ve learned on the field. Often, we find ourselves searching the Internet or digging through documentation to solve a problem. We are hoping if we post up, the next web search might be easier.