December 30, 2005

Kerio and Bleeding-Edge Snort

As I believe I mentioned in the past, my favorite little firewall (Kerio) was recently purchased by Sunbelt. Sunbelt has already proven their worth in my opinion with this post about adding Bleeding-Edge Snort rules to protect yourself from the recent wmf issues.

WHAT?! Kerio supports bleeding-edge snort rules?! I really wish I had known this before, but man that is cool!

I’ve been following Sunbelt’s blog since the announcement and have been pretty impressed with both the openess and technical nature of the posts by the company’s president, Alex Eckelberry. Not only has Sunbelt introduced me to features of Kerio I never knew existed, they’re also going to slash the price to $14.95, at least temporarily. $14.95, yes that’s right folks…$14.95. That’s 1/3 of what it used to cost. Mr. Eckelberry - I applaud your “no brainer” pricing. You have convinced me, a long-time free user of the firewall, to pony up and pay for it.

Wordpress Comment Blacklist bit me in the a$$

In an attempt to reduce a certain url from being spammed in my comments, I put that url into my wordpress comment blacklist. I know there’s a warning about being careful what you put there, but I figured the url was safe…well it turns out I was wrong. I didn’t look into it too much, but it seemed the url matched any comments that were put in. That means I lost comments from some of my recent posts like automating subversion, upgrading mysql on Gentoo, and running tentakel in Windows…some posts I really would have liked to see some feedback about.

My apologies to anybody that tried to post in the past two weeks and didn’t see anything show up. What a bummer. :-(

December 28, 2005

Running Tentakel on Windows

Nothing like a little late-night Python to keep one up until the wee hours of the morning…

I came across a great article tonight about executing commands on multiple *nix servers. It will come in extremely handy for me when moon-lighting as a *nix admin. I’d used fanterm before, but it wasn’t that good looking and being the freak of nature that I am, I spend most of my time in Windows. Although the program mentioned in the above article, Tentakel appeared to be designed for use on Linux systems, it is written in Python and should be able to run on Windows.

Well I can confirm that it does, but it needs a few changes in order to do so. What follows is a brief overview of the changes needed and then some more detailed descriptions about what was done. To get Tentakel working on Windows, follow these steps (current as of Tentakel 2.2):

  1. Comment out import pwd in lekatnet\config.py
  2. Modify the user parameters on lines 62 and 349 to be the user you’re going to connect as, ie:
    ‘user’: “bob”,
    user1 = “bob”
  3. Set a HOME environment variable:
    set HOME=”C:\Documents and Settings\bob\My Documents”
  4. Finally add import os at the end of the imports list in lekatnet\plugins\ssh.py and
  5. Either comment out or delete the status, output = commands.getstatusoutput(s) (line 43) in the same ssh.py and add the following where it was:
    pipe = os.popen(s + '2>&1')
    output = pipe.read()
    status = pipe.close()

    and then change the return statement to not perform the shift:
    return (status, output)

Follow those instructions, create your tentakel.conf and you should be good to go. By the way, I used the wonderful plink for my ssh client:
set ssh_path="C:\Download\Net\plink.exe" Now for the gory details.

After unpacking the source, I just attempted to run the program to see what would happen.

C:\tentakel-2.2\py>python tentakel
Traceback (most recent call last):
File “tentakel”, line 43, in ?
import lekatnet.config as config
File “C:\tentakel-2.2\py\lekatnet\config.py”, line 53, in
?
import pwd
ImportError: No module named pwd

Hrm, looks like it’s using a module that my Python install doesn’t have. Looking a little bit deeper, this module is actually used to retrieve passwd information from /etc/passwd. In this case, it’s retrieving the current users effective user id. Well…no need for that, really. Just comment out the import pwd and change the two areas on config.py where the pwd.getpwuid is referenced to be a static string of my username.

Try to run it again:

C:\tentakel-2.2\py>python tentakel
Traceback (most recent call last):
File “tentakel”, line 43, in ?
import lekatnet.config as config
File “C:\tentakel-2.2\py\lekatnet\config.py”, line 68, in
?
__user_dir = os.path.join(os.environ[’HOME’], ‘.tentakel’)
File “C:\Python24\lib\os.py”, line 422, in __getitem__
return self.data[key.upper()]
KeyError: ‘HOME’

Ah…Windows doesn’t generally set a HOME environment variable. No problem there, just do it myself. set HOME=”C:\Documents and Settings\bob\My Documents”

Tentakel ran ok after that with the provided -h flag to get a usage display. Next I made a config file and tried to run it:

C:\tentakel-2.2\py>python tentakel -c tentakel.conf -g linuxservers uptime
### t.u.x.y(stat: 0, dur(s): 2.0):
‘{’ is not recognized as an internal or external command,
operable program or batch file.
### t.u.x.z(stat: 0, dur(s): 2.42):
‘{’ is not recognized as an internal or external command,
operable program or batch file.

That certainly doesn’t look good. My first guess was that it was executing the command in those braces, which is compatible on *nix, but not Windows. The only problem was…I didn’t know where this was getting executed. An hour of debugging and familiarizing myself with both python and the tentakel program, and some googling led me to line 43 in lekatnet\plugins\ssh.py: status, output = commands.getstatusoutput(s). It appears that the getstatusoutput function uses unix-specific command syntax. That google groups link gives a couple suggestions and I ended up using the last one. I added import os at the end of the imports list at the beginning of ssh.py and replaced the line above with the following:

pipe = os.popen(s + '2>&1')
output = pipe.read()
status = pipe.close()

and then finally modify the return statement to not perform the shift:

return (status, output)

Save all the files and Tentakel works beautifully in Windows. From a second look, it’s not quite as nice as fanterm in that it is not truly interactive…but I think it’ll do just fine. My only gripe now is that output is based on the duration of the command…something to keep in mind when glancing quickly at the output.

December 24, 2005

Merry Christmas

Just wanted to say a quick Merry Christmas. I hope everybody is with loved ones and enjoying the holiday.

Now I better get to bed before it’s too late!

He was chubby and plump - a right jolly old elf,
And I laughed when I saw him, in spite of myself.
A wink of his eye, and a twist of his head,
Soon gave me to know I had nothing to dread.

“Happy Christmas to all,
and to all a good night!”

Blondes

Came across a good blonde joke earlier today.

It was so good, it motivated me to do the following:
Blonde Joke

Unfortunately, I couldn’t start at the root for a few reasons and my technorati API query limit was also hit. But still pretty cool to see. Apparently the Germans really liked the joke. Really interesting to see that element spider out. I’ll have to run it again from a slightly lower point and see what happens.

Thanks to Technorati for their Technorati API that even allowed me to do this in the first place. I initially was going to use Google, but they apparently don’t have an api for their Blogsearch yet. Too bad, Google!

December 20, 2005

Automating Subversion

As I mentioned in the past, I’ve been working on subverting my homedir. I’ve also been putting a great deal of effort into subverting my downloads directory. I have archives that date back to 1999 (ICQ99b, anybody…) spread across multiple CD’s and archive directories collected over time. What can I say…I like history. This made subversion a good fit for this task. I wanted to centralize all my download archives and manage to keep track of their history (should I ever need an old version) and synchronize this across hosts as well. Subversion works particularly well from the history aspect as now I don’t have to have 20 versions of one program all stashed in one directory. I just have one and I checkout the appropriate revision if I need to.

However, getting my archived downloads has been somewhat of an administrative headache. I took a look at some old Kerio downloads, for example, when they were making almost 2 releases a month…and I have most of them. Renaming, copying, committing, and repeat was not sounding desirable after I had already done it several times. So what do I do, of course, but whip up a quick one-liner to do it for me. *Note - I had to enable delayed expansion for this to work. I also had to download the svn binaries (as I was doing this on Windows) and make sure I had an appropriate SSH in my path - I used TortoisePlink and just renamed it…

set SVN="D:\Program Files\TortoiseSVN\bin\svn\svn.exe"
SET OLD=kerio-pf-2.1.5-en-win.exe
B:\Storage Bin\SVN Downloads\Net>for /F "tokens=1,2,3* delims=-" %i IN ('dir /od /b R:
\Download-2004.04.27\Net\kerio-pf-4*') do %SVN% rename !OLD! %i-%j-%k-
%l && copy /Y R:\Download-2004.04.27\Net\%i-%j-%k-%l && SET OLD=%i-%j-
%k-%l && %SVN% ci -m "Update to Kerio %k"

I ran that and in about 3 minutes had 12 Kerio new versions in my repository. What that script does is loop through each Kerio 4 download in the source directory, rename the old kerio to the new kerio name (I rename so I can keep track of versions at a glance, but still keep the update history), copy the new kerio over, update the OLD variable, and then commit the changes and do it all over again!

This is going to make some of the other apps much easier to get added to the repository as well. Man, I love version control.

How appropriate this seems at the moment:
I am nerdier than 87% of all people. Are you nerdier? Click here to find out!

December 15, 2005

Resetting Windows Security Settings to Not defined

As a person that frequently configures my Local Security Settings and experiments with Group Policy on my Windows network, this is something that has always baffled me, but I never really had a problem with it.

Many of the settings in the Windows Security Options settings are “Not defined” by default. For example, note how neither Enabled or Disabled is selected in this policy.
[img]

So what happens when you do enable or disable that option, but want to set it back to “Not defined” at a later point? There’s no “Not defined” option and I can’t quite recall right now if there is a way to do this when you’re working with Group Policy Objects…there very well may be.

One option I just discovered though, is simply by hitting the ‘d‘ key. Yes, that’s right. Open the security policy, hit d and the options will be disabled and set back to “Not defined” when you apply or click OK.

December 10, 2005

MySQL 4.1 Upgrade on Gentoo

Like a few others, I had a problem upgrading MySQL to 4.1 on Gentoo. I was faithfully following the upgrade guide and got to the revdep-rebuild part of step 3. Revdep-rebuild said it was going to take the following actions:

emerge –oneshot –nodeps -pv =dev-php/mod_php-4.4.0-r9 =dev-php/php-4.4.0 =net-libs/libwww-5.4.0-r3

However, I got the following error during the first part of revdep-rebuild when it was trying to compile mod_php:

can not run test program while cross compiling

Well that’s definitely odd as I wasn’t attempting to cross-compile. I googled around quickly and found several people with a similar problem (with quite a few in German…) and a couple solutions. I tried re-emerging gentoolkit, but that didn’t help. I then came across Bob Rasey who was having the same problem. Looking through my config.log, it did appear that something was trying to link against libmysqlclient.so.12, which I didn’t have…but I didn’t like his solution of adding a symlink as that seemed somewhat hackish. Gentoo is already sensitive enough, and I didn’t want to take any chances.

Going back through the config.log, I noticed that the test compile mentioned in this thread was failing with the following error:

libmysqlclient.so.12, needed by /usr/lib/libxmlparse.so, not found

A quick equery belongs /usr/lib/libxmlparse.so revealed that the file actually belongs to libwww. Ah-ha! This is beginning to make more sense now.

mod_php links to libxmlparse, which requires libmysqlclient.so.12. But that’s not there anymore since I upgraded MySQL. libxmlparse is part of libwww, though, which is also slated to be rebuilt, but not until after mod_php. And that is where the problem lies. Re-emerging libwww by itself to get libxmlparse.so to link to the proper libraries and then continuing with the revdep-rebuild solved the problem.

December 7, 2005

4

It’s 4 out. That’s right 4.

I have a new way of measuring degrees - it’s the number of minutes you can walk outside without freezing your butt off!

I think Jason says it best

December 5, 2005

Excel Tips

I’ve been working in Excel quite a bit lately. Here are some useful tips:

  • When using multiple data rows in Pivot Tables, it automatically subtotals each row, which can be somewhat annoying. To disable this feature, use the following:

    Select the ‘product’ label in the PivotTable and from the PivotTable menu, try:

    PivotTable>Field Settings…>Subtotals>None (select)

    Source

  • When inserting Excel charts in Word, sometimes you want them to be rotated to landscape view. This can also be achieved simply by doing the following:

    In Word, click where you want the spreadsheet. On the menu bar, select ‘Insert’>’Break’, and under ‘Section break types’ check ‘Next Page’. Insert your spreadsheet, set this page (ie. this section) up as landscape (File>Page Setup…).

    After the spreadsheet, insert another section break, reset the next section to portrait.

    Source

  • There are some other useful tips about Pivot Tables that I can’t recall now, but here’s one of them:

    When inserting a “Calculated Item or Field” into a pivot table, the formulas use the “sum” of each item you select…this can’t be changed, apparently.

    Not the original ref, but a good source nonetheless

    You don’t even know how long I fought trying to figure out why my formulas weren’t working at all…

  • Often times, the need comes up to count the number of unique values in a list. This can be pretty easily done, although it’s not immediately obvious:

    Use this forumla: =SUM(1/COUNTIF(Range1,Range1)). Now this is very important: Press Ctrl-Shift-Enter rather than only Enter; this will tell Excel to make it an array formula. You can use names or ranges in the countif function.

    Source

    Microsoft had a much more complicated solution that didn’t work for me.

  • This issue comes up quite a bit for me as I frequently combine various workbooks and use autofilter quite a bit. Sometimes, though, it doesn’t display the count in the status bar…it just displays “Filter Mode”. Microsoft to the rescue on this one:

    1. On the Tools menu, click Options.
    2. In the Options dialog box, click the Calculation tab.
    3. On the Calculation tab, click Manual under Calculation.
    4. Filter the list to see the filter results in the status bar.

    Source

I think that’s all for now. Maybe more later!