Friday, October 21, 2011

Linux vs. Windows... redux redux redux

A colleague sent me a link today to an article on a zdnet blog discussing a particular failing of Linux (and implying, without really supporting the argument, that Windows somehow accomplishes this better). The author seems to be trying to make the following points:
  1. Keeping up with all of the latest-and-greatest developments in Linux takes a lot of time, arguably more time than he can spend on it.
  2. "Bleeding edge" is highly dependent on exact versions of packages under developement, and getting those versions wrong breaks everything.
  3. Linux distributions are moving targets and commands (or command lines) that work on one version may not work on successive versions.
  4. Updating the operating system can break custom-compiled software that you install on the system.  He claims it makes the system unbootable.  I am skeptical about this.
  5. His ISP claims they never update their CentOS machines, because it breaks them.
First, let me say that perhaps Mr. Gewirtz is earnest about what he did and what the effects are, but describing things that he supposedly did like "recompiling the package manager" make no sense, so it's difficult to be certain what parts of his post are fact and what parts are exaggeration.  I've tried to give him the benefit of the doubt.

His first four points are absolutely true.  But they're not really "points" because they are obvious, and the solutions are equally obvious.  If you don't have time to keep up with all the latest developments in Linux, then don't!  I've arguably used Linux almost as long as anyone (since around 1992, my first kernel version was in the 0.96pl series, and I installed my first Linux on a 386SX from floppies -- it was the MCC distribution, which predates Slackware!) and I certainly don't have time to keep up with all the Linux trivia.  So I don't.  It doesn't stop me from running a few Linux boxes and knowing what I need to know to run them.  99% of the arcane details that might be interesting about Linux are not actually necessary to use it.

Likewise, there have always been "bleeding edge" versions of everything on Linux, and if you want to run them, there's generally some pain involved.  So if you don't want to put in the effort, don't run the bleeding edge!  Wait a bit for it to get stabilized and tested and sorted out, and you'll be in a much better position to have it "just work" like you're hoping it will.

The complaint that commands stop working between distribution versions is sort of silly to me.  It's true, but it's true of everything.  Solaris 10 doesn't support a lot of the commands that worked on SunOS 3, for obvious reasons (although admittedly, Sun does a remarkable job of making it work well, with the /usr/ucb tree of SunOS-type commands to compliment the /usr/bin SVR4 versions).  Even Windows doesn't solve this -- how many complaints have you ever heard about how Microsoft changed the UI in Windows?

Updating the OS definitely has the potential to break custom software.  This is equally true of Windows, IMHO, although admittedly I think Linux is a faster-moving vehicle so it's more likely that this happens more often.  Also, coming from the open-source paradigm, it's easy for Linux aficionados to feel that simply recompiling the software with the upgraded OS is easy since most things have available source.  I have a mail/web server that I originally built in 1998 that has been running RedHat 6 since it came online.  I custom compiled the mail server, and the web server, and the SSL libraries and the PHP modules and the Perl modules, etc., etc., ad nauseum.  I literally cannot upgrade this server because everything will break if I do.  I've lived with that for 10 years.  I've hardened it as much as I can, firewalled it, don't let many people log into it, and it's been okay for that long.  The operating system has outlasted 2 PCs and 2 hard disks.

One day, I will have to build a new server to replace that one, and when I do I will do it differently.  When I built this server, there was not really any such thing as Linux security updates.  If you wanted the latest SSL holes patched, you compiled your own SSL.  Today I'd never do this.  Every major distribution has a mechanism for distributing security (and other) updates, and if you update within the distribution's own software, it's not going to break.  If I had to rebuilt my server today, I'd put Debian on it.  I'd apt-get install apache and something for mail (I am a long time qmail user but I recognize that there are alternatives that didn't exist in 1998 when I chose qmail).  And I'd painlessly take updates from the vendor, easy peasy.

Finally, regarding updates for CentOS breaking the system, it's definitely unfair to paint all Linux distributions with the same brush because of something that happened on one.  I have been updating Debian and Ubuntu for years and years and while I've had some problems (trust me, trying to figure out why your apt-get dist-upgrade failed and what sort of messed up state it left you in is no picnic) it's gotten much better every time I've tried it and I've had no problems for several years.  I don't run CentOS or Fedora or Red Hat so I can't speak to them, but claiming you can't update Linux because CentOS sucks is like saying word processors are crap because you don't like Google Documents.

And, I must say that if an ISP told me that they never applied updates to their systems, I would find a new ISP.  The only exception to this would be if, as I suspect, they don't avoid applying updates because it's dangerous or risky, but rather they don't maintain the servers so of course they don't update them.

Either way, it sounds to me like the the author wants to use Windows rather than Linux, and I'm gracious enough to say that for a lot of things Windows is very capable.  But don't make the mistake he made and confuse the quality of an operating system with your personal measure of its ease of use.

Wednesday, October 19, 2011

Virtualization options

Although there are a plethora of virtualization options, there are really only two that I've used extensively.  VMware is the original virtualization platform and probably the one that most people know about.  To be clear, I've used many versions of VMware and even purchased a commercial license to use as a developer.  But most recently, I needed to set up a Windows Server 2008 VM for testing, and the Virtual PC stuff that comes Windows 7 doesn't do 64-bit, so I tried VMware.  After fighting with it for the better part of a day, I gave up.  I got cryptic messages about having to install drivers, I got errors saying that files that were needed for the installation weren't available.  It just plain didn't work.

So I installed Virtualbox.  I have used Virtualbox for a few years now when I needed a free virtualization option, and I've recommended it to a few friends and family.  It's always worked well for me, although to be fair my needs have never been extreme.  I was quite surprised to find that it installed the Windows Server 2008 VM on the first try with no hassles whatsoever.

I read somewhere that VMware was supposed to be faster than Virtualbox, but based on the experience I've had to today, Virtualbox works a million times better than VMware, and I'll take that over a bit of speed any day.

Tuesday, October 18, 2011

Content filtering for minors

I use DansGuardian as a content filter for our local network.  Much to my children's chagrin, they are not allowed to access sites that are rated above their pay grades, nor to sites that contain content that, via a set of weighted phraselists, is deemed to be too mature for them.  Finally, they're completely disallowed to access files based on filetype (e.g. exe, zip, rar, bz2) and mime type -- basically, they are not allowed to download executable files.

After having a few of my (now adult) children have their computers toasted by malware and whatnot (10 or so years ago), and after one of them accidentally fell into pop-up porn hell, I set this system up to try to protect them from themselves.  Since then, I am happy to say that nobody has had their computer lost to the bad stuff.  (But the credit for this obviously goes to DansGuardian.)

I use Shorewall as my firewall solution, and configure it to (transparently) redirect all outgoing traffic on port 80 to Dansguardian (on port 8080):
REDIRECT lan 8080  tcp www  # redirect LAN-www to local 8080
Dansguardian relays the requests to a proxy (originally I used Squid, but I have also configured Apache's proxy module), and you should probably block access from the LAN to the proxy ports, lest someone configure their computer to bypass your content filter.  I have not done this because at times I do exactly this and configure a computer to directly access the proxy.  So far, nobody has figured this out (I do check occasionally) so I haven't worried about it.

For computers that should bypass the content filter, like my Wife's, I define a variable in /etc/shorewall/params listing the MAC addresses of those computers:
RIKKI_IPAD=~ed-0d-59-b7-c7-5d
RIKKI_IPHONE=~24-ab-81-fd-71-c4
Then, I define a variable that includes all of the systems that should bypass the filter:
MACS_NOT_FILTERED=$RIKKI_IPAD,$RIKKI_IPHONE,...
Then, finally, in /etc/shorewall/rules I specify that these should bypass the filter:
ACCEPT+  lan:$MACS_NOT_FILTERED net tcp www 
The ACCEPT+ target is like ACCEPT, but it also prevents further rules from matching, so by placing this rule above the REDIRECT rule, we ensure that  $MACS_NOT_FILTERED will never reach the REDIRECT rule.

One final issue I've had is that DansGuardian allows me to "whitelist" sites using /etc/dansguardian/lists/exception{site,url}list files, but some of my [linux] systems try to get updates from one of any number of mirror sites, and I don't necessarily know all the mirror sites and even if I could be bothered to find out, I wouldn't want to manually maintain a list of exceptions.  So, instead I used /etc/dansguardian/lists/exceptionregexpurllist to allow access to any mirror (in this case, the CentOS 6.0 servers):
 ^.*centos/6.0/(os|extras|updates)/x86_64/.*$
Unfortunately there isn't a very good way to have the kids hit a blocked page, and allow them to have access for a limited time.  DansGuardian has some functionality to allow you to get "warned" but then continue onto the site, but it doesn't have a way to issue "tokens" that would expire after a period of time.  To try to help solve this issue, I've started playing with a form that adds exceptions to the DansGuardian configuration (the form only being shown to the adults by having them in their own filtergroup).  But this is a very immature solution so far.

That said, I think DansGuardian is an excellent tool for networks with children, and I highly recommend it.

Saturday, October 15, 2011

Web Cams, woot

I have set up a webcam page, mostly for fun, although my wife likes it because she can see if I'm working or watching TV or whatever.  I thought it might be fun to go over the technology involved, or at least the pieces that I've chosen for myself over the years.

Motion is a motion-detection and recording camera application for Linux.  This makes a great basis for a webcam.  You can have it generate recordings of activity on your camera that can be reviewed later with a simple PHP script.  MJPG-Streamer is another great tool for Linux.  It's a bit "raw" in that it's not packaged into system packages (that I know of) but it's actually a pretty slick lightweight program for having a live streaming camera.

On Windows, there's no shortage of webcam applications, but a simple free one that gets the job done is Yawcam (Yet Another Web CAM).  This is Java, but works reasonably well even on lower-powered systems (but definitely not as lightweight as mjpg-streamer).

I've tried all sorts of chat widgets for my webcam page, but none (for me) has ended up being better than CGI::IRC, which is a Perl-based IRC server in a web page.  I use this to allow people to join my private IRC server where I idle just in case anyone ever shows up.  They never do, but that's not the point. ;)

On my page, there are three cameras, each hosted on a separate computer.  A linux box (10.10.100.2) running motion records on the "main" camera with the widest angle.  Then, I have two laptops with integrated webcams that provide live streams from "side angles".  One of the laptops (10.10.100.19) runs mjpg-streamer, the other (10.10.100.201) runs Yawcam on Windows.

I've set it up so that the IP address (cam.akropolys.com) resolves to my firewall, both on internal DNS (as 10.10.100.1) and on external DNS.  I use Shorewall's DNAT rules to redirect external clients to the live camera streams:
DNAT net lan:10.10.100.2        tcp 8081     # webcam streaming
DNAT net lan:10.10.100.19:8082  tcp 8082     # webcam streaming
DNAT net lan:10.10.100.201:8081 tcp 8083     # webcam steraming
To allow internal clients to access the live streams, I use the rinetd utility to redirect request to the live video streams:
0.0.0.0         8081    10.10.100.2     8081 # cam
0.0.0.0         8082    10.10.100.19    8082 # cam
0.0.0.0         8083    10.10.100.201   8081 # cam 3
Of course, I use my reverse-proxy trick to redirect requests to the actual website.  This works for both internal and external clients:
RewriteCond %{HTTP_HOST} ^cam\.akropolys\.com$ [NC]
RewriteRule /(.*) http://10.10.100.2/~troy/$1 [P]
I also installed an ErrorHandler for error 503.  This error is thrown if Apache can't proxy requests to the camera page.  The error handler script checks the value of the $SERVER_NAME environment variable and if it's the camera server, it returns the camera down page.  This doesn't help if the webpage requests (on port 80) can be fulfilled but the live camera streams are down.  At some point I'm thinking I can use Javascript on the page itself to display an error image, but I haven't tried this yet.


Finally, I restrict access to the recordings to internal clients by checking the PHP $_SERVER['HTTP_X_FORWARDED_FOR'] variable and ensuring that the requesting client is on the 10.10.100.0/24 network.  This gives me a way to sort of secure parts of the page from prying eyes if I need to.

Search This Blog