Archive for the 'Linux' Category

The GIMP

I really like GIMP, and use it quite frequently, even with Creative Suite 4 Design Premium (licensed legally I might add) installed on my Mac, and with other applications like Paint.NET easily available for Windows. With that said, I thought I would post a few links about it, since I have been using it for… oh I don’t know, since 2002 or 2003 I’m guessing.

Read about it:

Download it:

Posted by Karl Herrick on October 13th, 2009 in Photography, Apple, Windows, Linux | 1 Comment »

The network config

My network setup is going through a transitory phase as I swap parts and move things around. Here’s what I have to work with:

I also have some other miscellaneous parts/systems that can be used as needed. My thought was to have one MythTV backend, that will also serve as a file share, and backups. This may present some problems with the bandwidth and disk speeds on the Pentium IV box, but that remains to be seen. I am hoping the newest desktop will continue to run some form of Linux, and XP Home virtualized to provide the cordless telephone service. And then finally the two laptops, for all their mobility as well as using XBMC for additional MythTV frontends.

Posted by Karl Herrick on August 20th, 2009 in Microsoft, Windows, Linux | 2 Comments »

DD Backups over SSH

To perform backups of a local workstation’s hard disk over a network, perform the following procedures (adjusted to your particular situation of course):

  1. Download and boot from a live Linux distro
  2. Become “root” within a shell
  3. Run “fdisk -l” (”mac-fdisk -l” I know works on SystemRescueCD 0.2.0 (PPC) for PPC/Macs (what about Intel Macs?)) and note the internal hard disk partition to backup (ex: ‘/dev/hda’)

The rest assumes that (in short, you will probably have to substitute some numbers or devices and you have ssh access somewhere):

  1. You have network access
  2. You have access to an SSH server
  3. Your network is configured with private addresses and you are not assigning one that conflicts with another local IP address
  4. Your netmask is the same as the one supplied in the following commands

Give an IP address to the workstation you have just booted the live Linux disc on, set the netmask, and bring the network interface up:

ifconfig eth0 192.168.1.50 netmask 255.255.255.0 up

Set the default gateway (if you need to reach outside of the LAN that is… normally this is your router’s IP address):

route add default gw 192.168.1.1

Set a DNS server (if you are in the habit of not strictly using IP addresses):

echo "nameserver 192.168.1.1" > /etc/resolv.conf

Execute the backup command:

dd if=/dev/hda | ssh username@backupserver.fqdn "dd of=/directory_of_backups_on_ssh_server/backupfile.iso"

Obviously, most of the previous is getting the network up… try running “dhclient” if the live Linux disc has it installed, and your network has DHCP setup. ;-)

UPDATE (2010-02-09): I just thought I would mention, that Clonezilla Live is a fantastic piece of software that makes this all a little more automated. Their site says, “For [supported] file systems, only used blocks in partition are saved and restored. For unsupported file system, sector-to-sector copy is done by dd in Clonezilla.” Essentially, this translates into much smaller image sizes for the majority of files systems that people work with. See a basic how-to at http://www.howtoforge.com/back-up-restore-hard-drives-and-partitions-with-clonezilla-live.

Posted by Karl Herrick on September 12th, 2008 in Apple, Linux, Bash | 4 Comments »

Goldfish and forged spam

Recently I had the goldfish autoresponder (vacation responses / email auto reply) setup for a user for about one week. Checking their inbox about half way through this time period revealed it having over 47,000 unread messages. What was happening is that spammers were sending email with forged headers. Have you ever received a spam message that apparently has been sent from yourself?

I suppose it can be accomplished via a variety of ways, however I was able to reproduce this particular issue via generating one of these tasty spam mails via the following (all internally of course… I am not a spammer):

telnet smtp.example.com 25

and then issuing these commands:

ehlo workstation.example.com
mail from:<emailuser@example.com>
rcpt to:<emailuser@example.com>
data
From: <emailuser@example.com>
To: <emailuser@example.com>
Subject: testing a loop
Message text
.
quit

Notice the mail is being sent to the user… and from the user…

  1. The server would receive the email addressed to emailuser@example.com
  2. goldfish would parse the message and notice it needed to respond to… emailuser@example.com
  3. The mail was delivered
  4. Rinse, wash, repeat

The source of the message looked something like this:

root@server:/var/local/vmail/example.com/emailuser# cat new/1220557062.P6882Q0M652544.server\,S\=1082
Return-Path: <emailuser@example.com>
Delivered-To: emailuser@example.com
Received: from localhost (localhost [127.0.0.1]) by server.example.com (Postfix) with ESMTP id 923E9185F7 for <emailuser@example.com>; Thu, 4 Sep 2008 15:37:42 -0400 (EDT)
X-Virus-Scanned: Debian amavisd-new at server.example.com
Received: from server.example.com ([127.0.0.1]) by localhost (server.example.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id q3tScOaitRoS for <emailuser@example.com>; Thu, 4 Sep 2008 15:37:42 -0400 (EDT)
Received: from workstation.example.com (workstation.example.com [xx.xxx.xxx.xx]) by server.example.com (Postfix) with ESMTP id B89E1185EB for <emailuser@example.com>; Thu, 4 Sep 2008 15:37:25 -0400 (EDT)
From: <emailuser@example.com>
To: <emailuser@example.com>
Subject: testing a loop

Message-Id: <20080904193728.B89E1185EB@server.example.com>
Date: Thu, 4 Sep 2008 15:37:25 -0400 (EDT)

Message text

and to prevent goldfish from causing havoc on the particular inbox (or mitigating what was already done… and preventing future issues), I added the following PHP:

//strip the line break from $address for checks
$addressCheck = substr($address,0,strlen($address)-1);
if ($addressCheck==$email)
{
        $log->addLine("Email address from autoresponder table is the same as the intended recipient! Not sending the mail!");
        break;
}

just before letting the mail being sent…

mail($address, $subject, $message, $headers);

I love goldfish. It’s like a do it yourself autoresponder! Keep in mind, this code works on Version 002, patch level 1, but could very well not work on any future releases (there have been indications that a newer version is in the works). Maybe I will post a few more tweaks in upcoming posts if the latest stable stays around for much longer.

Posted by Karl Herrick on September 9th, 2008 in PHP, Linux, Cron | 2 Comments »

pyLiMaSound

When life gives you lemons, make lemonade. This small application is my first real need to use the python language, and that makes me excited. Furthermore Ubuntu and Debian, in the desktop varieties, appear to come standard with PyGTK (your mileage may vary).

My main issue was that I needed to remotely adjust my OS X workstation’s sound, and I figured a control would be easier than opening a shell and running a script. Basically this will give you a small gtk.VScale widget (a vertical slider widget used to select a value from a range) in a resizable window. When everything is all setup I also run it using AllTray so that it can be docked into the system tray.

pylimasound-001.jpg
pylimasound-002.jpg

When a value is selected using the widget it passes the value off to rsh, which in turn sends the command to a remote workstation (the command I have prefilled into the script works on OS X’s main volume):

rsh -l remote_username mac_workstation.fqdn "osascript -e 'set Volume 4.6'"

The following, in the intended deployment requires password-less key based ssh connections between the workstation intended to remotely adjust the sound (any platform that supports PyGTK) and the Macintosh workstation:

#!/usr/bin/env python
#pyLiMaSound.py

import os
import gtk
import pygtk
pygtk.require("2.0")

user="remote_username"
host="mac_workstation.fqdn"

def scale_set_default_values(scale):
    scale.set_update_policy(gtk.UPDATE_DELAYED)
    scale.set_digits(1)
    scale.set_value_pos(gtk.POS_BOTTOM)
    scale.set_draw_value(True)

class pyLiMaSound:
    def delete_event(self, widget, event, data=None):
        print "delete event occurred"
        return False

    def destroy(self, widget, data=None):
        print "destroy signal occurred"
        gtk.main_quit()

    def rsh_vol_cmd(self, data):
        payload = "rsh -l " + user + " " + host \
            + " \"osascript -e 'set Volume " + \
            str(data.value) + "'\""
        print payload
        os.system(payload);

    def __init__(self):
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.set_default_size(50, 200)
        self.window.connect("delete_event", self.delete_event)
        self.window.connect("destroy", self.destroy)
        self.window.set_border_width(10)

        adj1 = gtk.Adjustment(0.0, 0.0, 10.1, 0.1, 0.1, 0.1)
        adj1.connect("value_changed", self.rsh_vol_cmd)

        self.vscale = gtk.VScale(adj1)

        scale_set_default_values(self.vscale)

        self.window.add(self.vscale)
        self.vscale.show()
        self.window.show()

    def main(self):
        gtk.main()

if __name__ == "__main__":
    control = pyLiMaSound()
    control.main()

Posted by Karl Herrick on August 20th, 2008 in Python, Apple, Linux, Bash | 1 Comment »