Command Line Arguments in Python

When I need a new tool, I often code it in Python. Often, command-line options are useful. Sometimes it is possible to have a fixed set of parameters, but this is not very flexible. Fortunately, Python has standard libraries to handle parsing command lines. Three libraries provide varying capabilities. Some of the systems I run on have older versions like Jython 2.1 or Python 2.6. This limits which libraries I can use without backporting libraries

This document provides examples of four command-line processing options. The examples are for a program that processes files and has an optional argument to report the execution time.

Continue reading “Command Line Arguments in Python”

MX on a Dynamic IP Address

I often see posts asking about running a mail server on a Dynamic IP address. Twenty years ago I started running my server on a dynamic IP address. However, times have changed, and it is more difficult to do so. Stil, there are mail server roles that work reasonably well on a dynamic IP address.  

Continue reading “MX on a Dynamic IP Address”

Choosing Log Levels

There are many tools available that will allow a programmer to create log entries. I originally worked with log4j, but have recently been working with logback. I am also working with Jython and am looking at Python’s logging framework. Used well they can make log analysis simple and provide a rich tool for resolving issues. Used poorly they can generate a mass of relatively useless information.

While these loggers have a good hierarchy of levels, the documentation tends to be lacking in guidance on when to use which level. The following document contains the recommendations I have gathered over the years.

Continue reading “Choosing Log Levels”

Tuning Linux CPU Performance

A recent kernel change broke my CPU performance tuning. I have an AMD processor that presents 4 cores to the kernel. The process in this article should work for Intel processors although the governors and CPU settings tree may be different. Different kernels may also have different settings. The current kernel allows setting the governor per CPU, but for an earlier kernel, the setting was global.

My system is mostly idle, and I want it to be as quiet as possible. However, from time to time it is busy and I want processing to be as fast as possible. I use a small block of bash code to select a governor and ignore niced programs (such as BOINC) in controlling processor speed.

Continue reading “Tuning Linux CPU Performance”

Adding SHA-2 to tinyca

Google has announced a sunset for SHA-1 certificate signatures in Chrome. SHA-2 (aka SHA-256, SHA-384, and SHA-512) is the remaining option for certificate signatures. I decided to upgrade my certificates to SHA-2 (256 bits). However, when I tried to use tinyca2 to generate a SHA-2 certificate, I found it was not supported.

As tinyca2 is a Perl package, I looked at the code to see how difficult it would be to update. The code is easy to read and well modularized. Adding the SHA-2 involves changes to the GUI, REQ, CERT, and OpenSSL components. I updated six files, although support can be added with fewer changes.

Patches are attached at the end of this post. An additional patch to apply the selected digest when creating sub-CAs (thanks to Cédric Dufour) has been included.

Continue reading “Adding SHA-2 to tinyca”

Disabling SSLv3 to block Poodle

The new Poodle vulnerability lead me to disable SSLv3 on my Ubuntu server. I have TLS/SSL enabled on three services: apache2, exim4, and dovecot2. Each service required a different method to disable SSLv3. While SSLv3 is mostly history, the techniques I used can be applied to other TLS versions.

Ubuntu uses configuration files split into small pieces. The method should apply to other distributions, although the configuration files may be arranged differently.

Continue reading “Disabling SSLv3 to block Poodle”

Disable TraceClassUnloading in Java 6

I recently discovered logs filling up with log messages for classes being unloaded during garbage collection. After a little research, I found that the TraceClassUnloading switch gets turned on by the Xloggc switch. After a little testing, I found that this can be resolved by adding the argument -XX:-TraceClassUnloading after the -Xloggc argument.

Continue reading “Disable TraceClassUnloading in Java 6”

Hostnames for eximstats Rejections

I use eximstats to report my daily email traffic. I have a fairly high rate of rejections and wanted hostnames listed in the rejection reports. To resolve this I developed a patch to capture the hostname related to the IP address, and add this data to the rejection reports.

The enhanced list saves me the effort of looking up IP addresses that were repeatedly addressed. Occasionally, these are from legitimate servers that have been misconfigured. DNS problems are often the cause.

Continue reading “Hostnames for eximstats Rejections”

Faking IMAP for Exchange Email

For years I have had problems getting IMAP access to exchange servers. Many organizations don’t enable IMAP on their Exchange servers, and others don’t do it right. I recently came across a solution that works with the Microsoft WebMail interface to provide an IMAP and/or POP3 access to the mail servers. This allows the use of IMAP mail clients like Thunderbird or Microsoft Live Mail.

This article describes the solution as I have implemented it. It uses the open-source DavMail Gateway written in Java. It accesses a WebMail server and provides access via standard protocols like IMAP, SMTP, and CalDav. This program can be configured for personal use on a desktop, or group use on a server. When configuring a server, it is recommended that you provide SSL keys so that secure protocols can be used.

Continue reading “Faking IMAP for Exchange Email”