Archive for the ‘Randomness’ Category

AtMail Open Authentication Fix

Posted 33 days ago by Alex in Randomness, Software

I’ve been running AtMail Open for my personal email for a while now. I recently upgraded to the latest version 1.05 for the security updates and ran into a bit of a problem after completing the installation. I likely had to fix this when I first installed AtMail way back in the day.

When I would try to login, it would return an error saying I specified invalid credentials. Looking at my maillog I saw the connection failing with the username “user@hostname.tld”. My mailserver is configured to use local accounts which means that authentication is done without having to specify the hostname in the address. Checking my other mail clients confirmed that I only have to specify my username to authenticate. AtMail uses the combination of username and hostname when it attempts to authenticate.

I dug around the install for a bit and found a little hidden setting in [AtMailHome]/libs/Atmail/Config.php. To configure AtMail to only send the username to the mailserver for authentication, change this line:

'mailserver_auth' => '1',

to this

'mailserver_auth' => '0',

.

A lovely undocumented setting.

“Message: dualvar is only available with the XS version of Scalar::Util” Error in CentOS 5

Posted 110 days ago by Alex in Randomness, Software

After upgrading the CentOS 5 system that is running my company’s internal ticketing system (OTRS), the automated cron jobs for processing tickets started throwing the following error:

Message: dualvar is only available with the XS version of Scalar::Util at /usr/lib/perl5/vendor_perl/5.8.8/IO/Socket/SSL.pm line 19

This error was caused by an upgrade to the Compress::Zlib package. The newer version of the package isn’t compiled with XS support. I found some information about this error from this OTRS mailing list post from 2010 regarding RHEL. Looks like it takes about a year for RHEL packages to make it downstream to CentOS.

To fix the error, I ran the following from the command line:

perl -MCPAN -e "CPAN::Shell->force(qw(install Scalar::Util));"

After letting the cronjobs rerun, the error was gone and tickets successfully processed again.

Sending HTML Email from the Linux Command Line

Posted 131 days ago by Alex in Code, Randomness, Technology

Just a little tip that I found useful for a project I was working on today. I had to send the results of a MySQL query via email. Since the results are printed in a table, the formatting in the email had to use a monospace font. The easiest way to use a monospace font in an email is to enable HTML and wrap everything in a <pre> tag.

#!/bin/bash
mailto=email@awesome.tld
subject="The awesome subject line of your email message"
(
  echo "Subject: $subject"
  echo "MIME-Version: 1.0"
  echo "Content-Type: text/html"
  echo "Content-Disposition: inline"
  echo "<html><body><pre>"
  mysql db -uawesome -pawesomer --table < some-sql-to-run.sql
  echo "</pre></body></html>"
) | /usr/sbin/sendmail $mailto

The output looks like this:

To: email@email.tld
From: system@awesome.tld
Subject: The awesome subject line of your email message
+----------+----------+----------+
| Column 1 | Column 2 | Column 3 |
+----------+----------+----------+
| Apples   |        2 |    14.00 |
| Oranges  |        2 |   0.5000 |
+----------+----------+----------+

Reconfiguring Network Interfaces in CentOS/RHEL Systems Cloned with vCenter

Posted 189 days ago by Alex in Hardware, Randomness, Technology

While cloning CentOS VMs in our environment, I ran into a problem where eth0 wouldn’t start up. When trying to start the networking service, the following error popped up:

Bringing up interface eth0: Device eth0 does not seem to be preset, delaying initialization.      [FAILED]

The reason this error occurs is because networking adapters in cloned VMs are assigned unique MAC addresses, so they don’t conflict with the parent VM. During OS installation, the installer detects the network adapter and udev configures the mapping between the device eth0 and the MAC address. When the MAC address changes udev thinks the device is missing.

To fix this, we need to update udev’s mapping rules to point the eth0 definition to the device with the correct MAC address. Open the file /etc/udev/rules.d/70-persistent-net.rules. You should see something similar to what is below:

# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

# PCI device 0x8086:0x100f (e1000) (custom name provided by external tool)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:9c:00:16", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x8086:0x100f (e1000) (custom name provided by external tool)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:9c:00:18", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

As you can see there are two PCI ethernet adapters present. The original one from the parent VM (MAC: 9c:00:16) and the new one from the current VM (MAC: 9c:00:18). To fix the issue you need to change the eth0 device definition to have the correct MAC address (9c:00:18) and remove the eth1 device. Your resulting file will look like so:

# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

# PCI device 0x8086:0x100f (e1000) (custom name provided by external tool)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:9c:00:18", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

You’ll also want to update the /etc/sysconfig/network-scripts/ifcfg-eth0 file to reflect the correct MAC address. Then, after a quick system restart your eth0 adapter will be back up.

Fix from address (root@localhost.localdomain) in sendmail

Posted 427 days ago by Alex in Randomness, Software, Technology

I’m usually a postfix guy. That’s what I run on my servers and it’s the configuration I understand. So when someone asked me to take a look at an issue on a server running sendmail, I was a bit befuddled.

The problem was that any messages sent from the command line, were arriving with a from address of root@localhost.localdomain. This was a bit of a problem. To test and confirm I ran the following:

echo "Who will this message be addressed from?  The world may never know." | mail -s "Testing sendmail" alex

And sure enough, I get an email address from root@localhost.localdomain. I end up Googling combinations of ‘root@localhost.localdomain’, ‘localhost.localdomain’ and ‘sendmail’. The options were pretty much useless. Too much noise about changing the sendmail configuration options.

In the end, I stumbled upon the real way to fix it…. Open /etc/hosts and change add the host’s name before the localhost.localdomain entry on the first line.

127.0.0.1     host.foobar.com host localhost.localdomain localhost
::1           localhost6.localdomain6 localhost6

Turns out, sendmail looks for the first hostname in the hosts file for the loopback address and uses that in the from field when a from address isn’t specified by the mail client.

List last modified file in all subdirectories

Posted 545 days ago by Alex in Code, Randomness, Software

I don’t know when someone would use this little snippet, but I think it’s useful.

It will open every directory in /home and retrieve the last modified file in all subdirectories under that directory. Then it will print out the file’s modification time and path. This might be useful for a system administrator who wants to see when the last time a user modified a file in their home directory.

for i in `find /home -maxdepth 1 -mindepth 1 -type d`; do
  cd $i
  find `pwd` -type f -printf "%TY-%Tm-%Td %TT %p\n" | sort | tail -n 1
done

To run it, save the code as ‘directory-age-check.sh’ and run:

 sudo ./directory-age-check.sh | sort