CybrHost is Going Green by Staying Home

CybrHost is going green by staying home. In celebration of the 40th anniversary of Earth Day 2010 all CybrHost employees will be working from home on Wednesday, April 21st in an effort to minimize their energy footprint for the day.

“We are working to become a certified green corporation. We are reducing our carbon footprint, planting trees to improve the environment, and exploring carbon offset credits to reach carbon neutrality”, said Matt Whitted, Hosting Director.

“We’re recycling, we’re pursuing ‘green’ supply alternatives, and we’ve instituted a corporate process that considers the green status of our office and data center from the highest levels.”

CybrHost is also celebrating Earth Day by planting a tree for each new customer during April and May. Trees will be planted locally in northeast Ohio, where they will help reduce pollution, offset carbon emissions, improve water quality, and provide natural habitat for wildlife.

“We feel a personal responsibility for our local area, and have made personal commitments to it. We maintain 40 acres of urban woodlands at our home farm, and continue to make personal investments in our nation’s ecology”, said Linda Zack, Vice President and part owner. “Now CybrHost is joining the effort. We have a ways to go, of course, but we’ll continue to pursue carbon neutrality through carbon reduction in our business and through local tree plantings.”

CybrHost plans to keep customers and the community updated on their progress at their Going Green website, http://www.cybrhost.com/green.

ClamAV Segmentation Faults

We started receiving a high volume of calls regarding Spamassassin, Amavisd, and ClamAV being broken in many mail systems today and in many cases “ClamAV Segmentation Faults”. Additional research yielded that the cause of this issue was a new signature added to the ClamAV daily definitions that exceeds the length a signature can be in all versions of ClamAV prior to and including version 0.94. You can read the announcement ClamAV made regarding this issue on their website.

Verbatim the announcement was as follows:

All ClamAV releases older than 0.95 are affected by a bug in freshclam which prevents incremental updates from working with signatures longer than 980 bytes.
You can find more details on this issue on our bugzilla (see bug #1395)

This bug affects our ability to distribute complex signatures (e.g. logical signatures) with incremental updates.

So far we haven’t released any signatures which exceed this limit.
Before we do we want as many users as possible to upgrade to the latest version of ClamAV.

Starting from 15 April 2010 our CVD will contain a special signature which disables all clamd installations older than 0.95 – that is to say older than 1 year.

This move is needed to push more people to upgrade to 0.95 .
We would like to keep on supporting all old versions of our engine, but unfortunately this is no longer possible without causing a disservice to people running a recent release of ClamAV.
The traffic generated by a full CVD download, as opposed to an incremental update, cannot be sustained by our mirrors.

We plan to start releasing signatures which exceed the 980 bytes limit on May 2010.

We recommend that you always run the latest version of ClamAV to get optimal protection, reliability and performance.

Thanks for your cooperation!

If your ClamAV segmentation faults when it attempts to start and it didn’t yesterday you’re likely experiencing the bug described here. When you attempt to start the daemon you should see an error that looks like this displayed on the console or in your logs:

LibClamAV Error: cli_hex2str(): Malformed hexstring: This ClamAV version has reached End of Life! Please upgrade to version 0.95 or later. For more information see www.clamav.net/eol-clamav-094 and www.clamav.net/download (length: 169)
LibClamAV Error: Problem parsing signature at line 742
LibClamAV Error: Problem parsing database at line 742
LibClamAV Error: Can’t load /tmp/clamav-cb68c98144521c30/daily.ndb: Malformed database
/etc/init.d/clamav-daemon: line 57: 2803 Segmentation fault start-stop-daemon –oknodo -S -x $DAEMON

You will also likely see some log entries like this if you’re running spamassassin or amavis:

Apr 16 09:53:29 mailserver amavis[2293]: (02293-01-7) Clam Antivirus-clamd: Can’t send to socket /var/run/clamav/clamd.ctl: Transport endpoint is not connected, retrying (1)
Apr 16 09:53:30 mailserver amavis[2320]: (02320-01-7) Clam Antivirus-clamd: Can’t connect to UNIX socket /var/run/clamav/clamd.ctl: No such file or directory, retrying (2)

First of all “DON’T PANIC“, there are two simple fixes for this problem to get your mail IMMEDIATELY flowing again.

To implement either of these you first need to disable the freshclam and make sure ClamAV isn’t running. Once you’ve done that you can remove the offending signature from the ClamAV daily.cvd or remove the daily.cvd file. The first option of course is the better one as you will still get all the other updates until today. The file should be located in one of these locations depending on your distribution and mail-server setup:

/share/clamav
/usr/share/clamav
/usr/local/share/clamav
/usr/clamav
/usr/local/clamav
/usr/lib/clamav
/usr/local/lib/clamav
/var/lib/clamav

After you have either edited the offending entries out of the file or deleted the file entirely you can restart ClamAV and your mail should start flowing again. Do not start freshclam again as you will likely re-download the file or additional long records that will break mail again. If your mail has been down for several hours you may want to your mailer daemon to attempt
redelivery of queued up mail:
For postfix:

postqueue -f

For Sendmail:

sendmail -OTimeout.hoststatus=0m -q -v

For Exim:

exim -q -v

For QMail:

kill -14 (pid of qmail)

or if you have supervised qmail:

svc -a /service/qmail

This however, is a short term solution with two distinct disadvantages, the first is: You no longer are receiving virus updates. The second is your virus definitions are not current if you deleted the daily.ctd meaning you will be missing
some new viruses that have been identified.

The solution is to recompile ClamAV and re-integrate it into your mail-scanner setup and this can be a complex and daunting operation for many admins especially in aged systems or extremely customized mail setups (frequently qmail has setups like these.) There is no simple easily addressed way of doing this we can tell you, every setup is somewhat unique. If you find that this is a task beyond your ability or need additional assistance with getting your mail back in a production ready clean state give us a call we’ve already helped a massive number of people get their mail-servers updated and back online and we’ll gladly help you do the same! As always give us a call if you need further assistance with this or any other open source software, you can contact Pantek at www.pantek.com, 877-LINUX-FIX, 216-344-1614 or email us at support@pantek.com.

Emacs: The Digital Swiss Army Knife

INTRODUCTION

“The purpose of a windowing system is to put some amusing fluff around your one almighty emacs window.” — gnu.emacs.help

That quote does not begin to do justice about the power that the Emacs editor offers its user. From integration with source-code management tools right inside the editor to a large number of special editing modes for any number of different languages to a wide variety of other tools and utilities, Emacs takes the “kitchen sink” philosophy seriously. In this article we’ll plumb the depths of this versatile, powerful editor and get you on your way of becoming an Emacs guru.

A bit of history is in order first of course. Emacs begun as a project by Richard Stallman who was responsible for launching the GNU Project and Free Software Foundation. Emacs development begun in the 1970’s and is still actively contributed to today despite the many modern IDEs that exist. GNU Emacs, which is the version I’ll be referring to here, is currently at version 23.1. There was a fork of GNU Emacs in the early ’90s which led to the development of XEmacs,but for all practical purposes both XEmacs and GNU Emacs are quite similar. There are, of course, other versions of Emacs out there as well and you’ll likely to find a lot of overlap in terms of extension for each one.

“How do I get Emacs”, you might ask? Most modern Linux distributions ship with Vi(m) but might not come pre-installed with Emacs. Depending on your Linux distribution, you may be able to run run any of the following commands:

Gentoo:
su emerge emacs

Ubuntu:
sudo apt-get install emacs23

CentOS/Fedora:
su yum install emacs

ArchLinux:
su pacman -S emacs

I’ll wait while you install….

BUFFERS AND COMMANDS

Ready? Great! Now that emacs is installed you can fire it up by simply typing ’emacs’ at your terminal. Depending on your current configuration this may take a few seconds. Of course since you just installed you really haven’t customized Emacs yet. When you start up Emacs the first thing you are probably going to see is a few lines that begin with “;;”. These are comments in elisp, the scripting language Emacs is written in. (We’ll get more into elisp later). Emacs has the notion of buffers – anytime you load up a file, create a new file, or get output from any of Emacs’ utilities the results go in a buffer. The buffer you see when you first start emacs is known as the *scratch* buffer. It is provided there for you to write down anything that you don’t want to save (though you save it to a file if you want) and as a convenient place to evaluate simple elisp expressions.

Of course the *scratch* buffer isn’t going to be where you do all your work. So how do we open or create a file? Well, before we delve into that its time to discuss the command structure of Emacs. Unlike ‘other’ editors you don’t have to hit a key before you can start typing. Which means that there must be some way to interact with the hundreds of Emacs commands. I introduce to you two keys which are known as modifier keys in Emacs, “Ctrl” and “Meta”. These two keys will become your friends during your Emacs career. I’m sure you know where the “Ctrl” key is on your keyboard, but “Where is Meta?” you might ask. Well, for many systems ‘Meta’ translates into ‘Alt’. You can also achieve ‘Meta’ by typing ESC as well. All commands will be referenced by a specific key sequence such as C-x C-f or M-x. This translates intoCtrl-x Ctrl-f (or to think of it another way, hold down control then type x f) and Alt-X. Emacs takes practice, there are many different key combinations built-in plus you have the option of specifying your own. I highly recommend you keep a cheatsheet of common sequences until you are more comfortable with the editor.

Now we move onto files. I’ve already introduce the command to create or open a file, C-x C-f. If you go ahead and enter that command in Emacs you’ll notice at the bottom of your Window the following line: “Find File: (CURDIR)”, where CURDIR is the working directory of the current buffer (which, in this case, is the directory you opened up emacs from). You can now navigate to your file by navigating to its path. Emacs features autocomplete, so if you’re not sure exactly what directory a file is in but you have some idea, you can hit the <TAB> key to have Emacs complete the path for you or show you exactly what files and directories there are in the current path. When you’ve found your file, simply hit enter and Emacs will load the file in a new buffer and at this point you can start editing. Of course, chances are you’re going to want to save your file. The command sequence for this is C-x C-s. If you enter this command you’re notice at the bottom Emacs tells you that it wrote the file or that no changes were made that needed saving.

When you’re finished editing and want to quit Emacs simply enterC-x C-c. Emacs will either exit if your files are up-to-date, or prompt you whether or not you want to save any changed files. You can enter ‘y/n’ here for “Yes, save” or “No, don’t save”, ‘q’ for give up on all saves, C-g for cancel command, or the most important of all, C-h for help.

MANAGING YOUR TEXT

Navigation

You are now officially an Emacs user! Of course, this is only the tip of the iceburg as far as Emacs goes. So our next topic of discussion will be some basic navigation. Emacs offers a number of ways of navigating your document quickly and efficiently. Lets present some use-cases for you to consider:

  • You want to navigate to the previous line or next line?
    • C-p navigates to the previous line.
    • C-n navigates to the next line.
  • You want to navigate one character at a time?
    • C-b navigates back one character.
    • C-f navigates forward one character.
  • You want to navigate one word at a time?
    • M-f navigates forward one word.
    • M-b navigates back one word.
  • How about a sentence at a time?
    • M-a moves back one sentence.
    • M-e moves forward one sentence.
  • You want to move to beginning/end of the line?
    • C-a moves to the beginning of the line.
    • C-e moves to the end of the line.

There are other navigational commands as well. What if you know what line you need to go to? There’s a command for that! M-x goto-line will allow you to type in and navigate to any line in the current buffer. Now, I know what you’re saying. “But, I have to type all that just to go to a single line?” You’d be right, of course, that is a little much. I’ll address this in a future post!

What if you want to search for specific text? Emacs offers you multiple choices in this category as well. C-s allows you to search forward through the document for particular text, while C-r searches backwards through the document. Once you type in your search query after hitting C-s or C-r you can enter either command repeatedly to continue searching if there are more than one instance of your query present. You also have the option of doing a regular expression search, which can be accomplished using C-u c-s. Lets say I wanted to search this document in emacs for the following: “X one Y” where X is either forward or backward and Y is character, word, or sentence. I can enter C-u C-s and type
\(forward\|background\) one \(word\|character\|sentence\) and useC-s and C-r to navigate all the matches!

“But, can I replace text?” Its Emacs, of course you can! There are multiple ways of accomplishing this task depending on your need. Lets say I wanted to replace all instances of Vim with Emacs? Pretty straight forward since we have defined a simple string to replace. We can go ahead and type M-x replace-string, enter Vim as the “Replace String” and Emacs for the “”Replace String … With” and voila! All instances of Vim are now Emacs. You may also want to perform more complicated replacements using regular expressions. Lets say we have a document that references Word, Nano, Joe, and Vim and we want to replace all those text editors with a single one – Emacs. Well then, we can fire up M-xreplace-regexp and enter\(MS Word\|Nano\|Joe\|Vim\)
for the first prompt, which will be the regular expression pattern we want to match against. Enter Emacs for the second prompt, which is what we will replace each reg-ex match with and in the words of Emeril Lagasse, “BAM!”, we’ve replaced all the matches. Emacs also provides two additional commands which can be entered via M-x, query-replace and query-replace-regexp which functions nearly the same way as the above commands with the exception that it prompts you on each match how you want to proceed.

Deleting Text

Emacs also offers commands that makes it easy to delete text as well. You can use C-d to delete a single character or use M-d to delete an entire word. These perform deletions forward (meaning you have to be before the word/character you want to delete). Obviously you can use [DEL] to delete a forward delete a character and use [BACKSPACE] to perform a backwards deletion. However, you can use M-[DEL] to perform a backwards delete word. If you need to delete an entire line, C-k will delete anything on the current line that comes after the cursor. Using a C-a C-kcombination will easily erase the current line by navigating to the beginning and performing the delete.

Copy and Paste

Copying and pasting is a little bit more involving. The main point to keep in mind when you want to copy and paste is that Emacs uses the notion of “Marks” which is an indication where a region begins. If you want to copy/cut text you would first have to mark the beginning of the region then navigate to the end of the region and perform the actual cut/copy operation. You can mark the beginning of a region by using C-[SPACE]. Once you’ve navigated ot the end of the region you want to modify, you can use C-W to ‘cut’ or ‘delete’ the marked region. This will remove it from your buffer and make it available for ‘yanking’ or pasting back into the document else where. You can accomplish this by using C-y. Of course, if you want to simply copy text rather than cutting it from the document follow the same above procedure but use M-W instead to copy the text.

CONCLUSION
I wish I could say that was everything but we’re only getting started. You’re on your way to becoming an Emacs guru, so I welcome you to the growing list of Emacs user. Before you know it you’ll be dreaming in elisp and outtyping Vim users. Stay tuned for future articles which will start covering more advanced features of Emacs. If you need further assistance, Pantek Inc. is always available at info@pantek.com, or 21-344-1614, and 877-LINUX-FIX.