Fixing box drawing in Midnight Commander

Launching MC in rxvt showed all the box drawing characters replaced with strange looking accented characters… What?

Turns out none of the Windows fonts support box drawing characters (from what I’ve read, it seems that they don’t have the characters in the expected positions in the character table)…

The easiest solution is to tell MC to use non box drawing characters to draw boxes with the -a switch. The other solution is to get the Lucida ConsoleP Font. (307), and set rxvt to use it (as suggested by this guide).

How do you set the fonts? You could set them with command line switches, or use a .XResources file in your Cygwin home directory (base file from here)):

rxvt.font:             Lucida Console-14
rxvt.boldFont:         Lucida Console-14
rxvt.scrollBar:        True
rxvt.visualBell:       True
rxvt.loginShell:       True
rxvt.background:       Black
rxvt.foreground:       White
rxvt.saveLines:        3000
rxvt.cursorColor:      Green
rxvt.scrollBar_right:  True

If you want to use the box drawing font (you have to install it on the system first):

rxvt.font:             Lucida ConsoleP-14
rxvt.boldFont:         Lucida ConsoleP-14
rxvt.scrollBar:        True
rxvt.visualBell:       True
rxvt.loginShell:       True
rxvt.background:       Black
rxvt.foreground:       White
rxvt.saveLines:        3000
rxvt.cursorColor:      Green
rxvt.scrollBar_right:  True

If you use the standard DOS terminal for Cygwin, you may want to change the code page setting in the batch file to:

set CYGWIN=codepage:oem

Source Engine Servers and Network Protocols – Security

As an administrator of several Source based game servers, I’ve dealt with various known security vulnerabilities that Valve hasn’t bothered to fix. Some of the most common include client side console commands, that if run once, or spammed (which the server will allow), will cause a degradation (massive lag) or denial of service (you guessed it, the server will crash). These really aren’t all that bad, since they are well known, server plugins are available to block the commands.

The most troubling incident I’ve dealt with involved an attacker who exploited a security vulnerability in Valve’s server query protocol, which caused a serious degradation of service condition. I couldn’t simply block all the query packets, since legitimate clients needed to be able to query servers. To further complicate matters, the attacker was also spoofing IP headers, which ruled out the possibility of a simple firewall rule.

This particular vulnerability was not really bad design per say (although it was poorly designed), but more a really poor implementation. Here are the details:
Continue reading

MinGW

After needing a copy of MinGW to compile some C code, I was somewhat annoyed to find that their all in one installer is now considered “deprecated”. That meant I had to download and extract 15 packages manually (two of them were even compressed as .lzma).

Why anyone would compress a package designed for Windows in .lzma format? The only way to extract it is with a command line sdk tool. Even on Linux, distributing archives in .lzma format is a little strange.

Anyhow, to save everyone the trouble, here’s a package (includes C, C++ and all necessary tools) in .7z format (which can be extracted by 7-Zip, the best file archiver for Windows) -> MinGW Compiler Package (238).

More on eAccelerator

Now that I’m correctly loading the extension (zend_extension_ts), eAccelerator is running smoothly.

I found something interesting in the event log yesterday:

PHP Warning:  [eAccelerator] This build of "eAccelerator" was compiled for PHP version 5.2.9. Rebuild it for your PHP version (5.2.9-2) or download precompiled binaries.

Now that error message makes perfect sense. The reason I didn’t see it the first time around is that PHP logged two messages separately at the same time. If I was reading a flat file log, I would’ve noticed it immediately.

eAccelerator

After getting somewhat annoyed with the slowness of my blog, and having nothing better to do, I decided to setup eAccelerator. I’m pretty sure I tried setting it up a long time ago, but for some reason, didn’t finish.

Following the path of logic, I went to the eAccelerator website in search of the appropriate files. Their Windows section directed me to SiteBuddy, which had a nice collection of binaries for various PHP versions. After determining my PHP version (5.2.9-2), I tried the closest match (5.2.9), and was greeted by the following error in the Windows event log:

Unable to start eAccelerator module in Unknown on line 0.

My initial reaction to the error: what the ****… (UPDATE: See this post for more details) After a quick Google search, I found that PHP modules must be built for the EXACT PHP version you plan to use them on.

Since I have just about every Microsoft C++ compiler, I figured compiling a new eAccellerator module for my version of PHP would be simple. I downloaded the archived PHP files I needed (now I understand why they keep archives), switched to the release configuration, and pressed build.
Continue reading

Best of open source (2009)

As 2009 starts to wrap up, here’s my list of the best open source software that I’ve used:

The best of open source
Software Comments
WordPress The best blogging platform.
Python One of the most modern and powerful programming languages. Incredible standard library.
Mumble The best conference style VOIP. Incredible sound quality, the lowest latency and lowest bandwidth usage that I’ve ever seen in a VOIP system (open source or not). Version 1.2 seems to have fixed some of the major server administration issues.
Sage (Open Source Mathematics) An open source alternative to “Magma, Maple, Mathematica and Matlab”. Good documentation.
Ubuntu My personal favorite Linux distribution. Version 9.10 adds cloud technology to both the desktop and server (yes, you can use it to make your own cloud).
SourceMod The most modular and powerful server administration tool for Source based game servers.
VirtualBox Open source (the RDP server, USB support, and USB over RDP are not) virtualization comparable to VMWare Workstation. Seamless windows for Linux and Windows guests. The closed source parts are available for free under the VirtualBox PUEL.
Firefox The best web browser.

Browsing the web without ads

Amusingly, I didn’t use an ad blocker until a few months ago. Now, I enjoy viewing sites without half a million ads cluttering up my screen.

Ad blockers like ABP (Ad Block Plus) scan web pages for ads, and remove them. As simple as they are, ad blockers are incredible.

I installed ABP when I was trying to print an article from a coding website. There were so many ads on their main and print views of the article that printing it would have barely been worth the effort. I remembered that a friend of mine had talked about ABP, so I looked it up and installed it. After enabling it and returning to the website, the ads were gone, and I could actually print the article.

ABP also lets you block new ads that it doesn’t already detect with a few simple clicks. Some websites use JavaScript to display ads, and if ABP can’t block them, NoScript can.

Web masters should realize that intrusive ads will just cause more and more people to start using ad blockers, and start being reasonable.

Bitwise operations

While you don’t see them every day, bitwise operations are important. Everything at the hardware level is represented in binary (base 2, 1 and 0). Bitwise operations allow programmers to operate directly on the bits used by variables. This is very useful with enums, since you can have one variable be multiple values.

To understand how one enum variable can be multiple values, you need to understand the bitwise AND and OR operations.

An OR operation compares two sets of bits. If either bit is 1, the result is 1, else, result is 0. In the below example, set 1 is the value of enum option 1, and set 2 is the value of enum option 2.
Continue reading