$ cat post/september-10,-2001---a-day-in-the-life-of-a-linux-sysadmin.md

September 10, 2001 - A Day in the Life of a Linux Sysadmin


Today marks another day on the ops floor, and as I look at my desk piled high with server logs, configuration files, and half-finished shell scripts, it seems like any other typical Tuesday. But then again, that’s precisely why today feels different.

You see, this blog post is about one of those days where reality just slaps you in the face—albeit a bit more violently than usual. It was a day when a simple script I thought was foolproof broke, causing our email server to grind to a halt. And let me tell you, when Sendmail starts complaining about something, it’s not happy campers.

The Script That Caused Trouble

A couple of weeks ago, we were trying to streamline our mail delivery process by optimizing the way our Postfix relays work with Sendmail. I had written a small Python script that was supposed to parse incoming emails and inject them into the queue without any additional latency. In theory, it was a simple task: read the email headers, extract the destination address, and pass it along to Sendmail.

Here’s what the relevant part of the script looked like:

import os
import sys

def send_email_to_sendmail(email_body):
    with open('/var/tmp/incoming-email', 'w') as temp_file:
        temp_file.write(email_body)
    
    os.system('sendmail -bs -t < /var/tmp/incoming-email')

if __name__ == "__main__":
    email_body = sys.stdin.read()
    send_email_to_sendmail(email_body)

The Breakdown

On September 10, everything seemed to be working fine until we noticed that emails were taking an unusually long time to deliver. Checking the logs revealed a message I hadn’t seen before:

sendmail: fatal: unexpected file `/' in argument

It took me a while to figure out what was wrong. The script was somehow trying to process a file named /—yes, the root directory! It turns out that there was an edge case where the email body included a newline at the end, which caused Python to pass it as an empty string to sys.stdin.read(). This resulted in os.system('sendmail -bs -t < /var/tmp/incoming-email') trying to read from /, hence the error.

The Fix

Fixing this was straightforward—just add a check to ensure we’re not passing an empty string:

if __name__ == "__main__":
    email_body = sys.stdin.read().strip()
    if email_body:
        send_email_to_sendmail(email_body)

After that, the script worked flawlessly. But it was a reminder of how even the simplest scripts can have hidden bugs that you might not anticipate.

Reflections on the Day

This incident highlighted one of the challenges of working with open-source tools like Sendmail. While they are incredibly powerful and flexible, they come with a steep learning curve and a large number of edge cases to consider. I spent hours Googling error messages and reading man pages just to understand what was going wrong.

It also brought back memories of when Linux on the desktop was still an experiment for many. Back then, Sendmail and Apache were the de facto standards for email and web servers respectively. I remember days where the tech stack seemed like a moving target—new versions would come out every few months, bringing with them new features but also breaking old scripts.

Today, these tools have matured significantly, but the challenges remain. As we move towards more modern solutions, it’s crucial to keep an eye on these legacy systems and understand how they fit into our current tech landscape.


And so, as I sit here debugging, fixing, and learning from my mistakes, I can’t help but wonder what the future holds for ops and infrastructure management. One thing is certain: the work will always be there, pushing us to adapt and improve every day.