Saturday, May 26, 2018

Why use Apache Server Side Includes (SSI) for Web scripting

  • Simple
  • Fast
  • Flexible
  • Secure (if configured properly)
  • Low server load
Apache SSI (also called XSSI, extended server side includes) has several advantages over other server-side technologies:
Easy to learn
A small learning curve makes XSSI accessible to people with limited programming experience. XSSI is programmer-efficient because it requires very  little debugging.
Mature
Well-tested code and a stable API make future surprises unlikely.
Lightweight
XSSI can deliver popular features such as printer-friendly versions, article partitioning, and hierarchical menus without client-side scripting or a database back end. Maintenance becomes easier--and cheaper.
Efficient
Contrary to early-day warnings that XSSI would bog down a web server, XSSI is probably the most resource-efficient of all dynamic technologies. For example, according to the Apache Hello World Benchmarks (see XSSI Resources), mod_include, the base module implementing XSSI in Apache, can serve more Hello World pages per second than other dynamic content-generation technologies.
Secure
In particular, if you do not include the output of arbitrary web server executable programs. Also, content maintenance is at the file system level. Desktop html editors make that an advantage because Web-based CMS write  to the file system. That's the vector for CMS attacks. See below for a security discussion.
Ubiquitous
Present in virtually every Apache installations, because its implementation is a base module.
Complementary
Combined with web site templates, XSSI can decrease maintenance time and increase sitewide consistency. 
It is easy to integrate with client-side technologies, including cascaded style sheets, JavaScript, and other dynamic objects such as Flash and Java applets.
On the server side, it's integrated with Apache CGI (Apache's original way of programming Web pages). Thus it can be combined with any other programming language that supports stdin/stdout. CGI is language neutral. 
Desktop GUI html editors can include it by switching to html mode. Can even use an online editor like blogger.com and copy-paste the html.
Forward-looking
It can integrate with any text-based document, including XML and RSS.
Powerful
CGI has access to all programming languages, commands and scripts on the system including server side Javascript. It can get data, code, etc. from other servers. It can make database calls. There's practically no limit to what a programmer can do using CGI integrated with SSI.

Apache's eXtended Server Side Includes Onlamp.com, by Kostas Pentikousis 07/07/2005

 

But, is it secure? Various authors have challenged Apache SSI security. For example:

Protecting Web Servers from Security Holes in Server-Side Includes by Jared Karro, Jie Wang, Division of Computer Science, University of North Carolina at Greensboro, Greensboro, NC 27402, USA, Jared Karro@uncg.edu, wang@uncg.edu
All of the examples this paper sites are internal attacks. Controlling who can edit the Web site and what user Apache runs as completely negate the claimed problems.

Generally, when people talk about the security of a Web scripting language, they are referring to external attacks. No one will claim that a Web language is totally immune, but SSI has, historically, had the fewest issues of any Web programming language.

Other claimed vulnerabilities:
  • Server-Side Includes (SSI) Injection
    • The authors provide no explanation of how the injection is to be accomplished. Setting the file system permissions so the Web server can't write to it and turning off Exec permission, which are standard procedures for securing an Apache site, should eliminate any possibility of this working.
    • Perhaps they are referring to using the query string as a variable in an SSI command. Programmers must be cautioned to never do this without checking the content of the query string.
So, what's wrong with it?
  • Limited function in of itself compared to other Web languages, e.g. PHP. Using CGI, it can do anything the others can, but programmers may find breaking the work into two environments inconvenient.
  • Requires understanding of stdin/stdout to use CGI.
  • Programmers must pay attention to the data coming in to ensure it doesn't contain executable code. Best practice is to never execute any part of the parameters or form input. Some CGI libraries, e.g. in CPAN and MIT's cgic take care of this housekeeping.
  • The biggest problem is lack of exposure. Most Web programmers don't know it exists.

Tuesday, May 22, 2018

Turning Apache SSI usage on its head.

Most people who talk about templating with Apache Server-side Includes scripting (SSI) have HTML pages pull in pieces of common code such as styles, headers, footers and so on, then hard code the content in the page. This technique certainly reduces the amount of code in each page. And, one can make some changes in a single place. In programming parlance, it modularizes the code. This approach has drawbacks, though.
  • Depending on what is pulled in, changing the structure of all the pages in the site may mean editing many files.
  • The content can't be presented in different ways for different purposes. It can't be reused.
So, what if we turn this concept on its head? What if the content calls the “page”, or more broadly the “template” rather than each page having content. What would that look like?

SSI can set variables. The variables can contain anything that is a string. The variables can be substituted for text just about anywhere, including in the URI in an SSI command.

What does that mean? It means that content can be put in a file that calls a “page” to display itself. The steps are:
  1. Set one or more variables with content.
  2. Call a template file, either a fixed one, or, and here's the beauty of it, one whose path is in a variable that was set before the content file was called.
  3. The template file puts the content variables in the appropriate places.
Why go to this trouble? Because the template file that’s called can be different depending on the desired output. One time it can be a complete HTML page. Another time it can be an HTML fragment such as a paragraph or a list element. Another time it can be an RSS feed item. Another time it can be Javascript variables. The same content. Only the template changes.

What's more, one template can be used for many pages, potentially an entire site. So, if the site structure or style changes, only one file has to be modified.

In some sense, this turns SSI into an object-oriented system, bringing it into the modern era of system architecture. The variables are object attributes and the template file is the method. What's more, the method can be anything. Unlike most OO languages, it doesn't have to be hard coded. (Although it could be by using #if conditional processing to choose among a fixed set of methods.)

Regardless, the possible uses of this technique are limited only by one’s imagination. The output can be anything that is deliverable in response to a Web request, even JSON. And, it can be driven by parameters in the URL that called it. (Apache SSI has access to the query string.) RESTful services anyone?

Tuesday, November 21, 2017

Satellite TV for an RV with no contracts and no gimmicks

We got satellite TV simple and cheap, no contracts, no fine print, no "have to do this to get that", no lease/rent payments on equipment. Up front cost: $270 ($310 if you want DVR). That gets your own receiver and a free dish installed at your house.  Monthly cost starts at $35 ($45 with local channels).

What's the trick? Pretend that you have an RV with satellite already installed and that you want to move it into your house when you're home. (This is no longer necessary. The Flex Pack is now available to home customers directly from DISH.)

Step by step:
  1. Go to DishForMyRV, Shop Now.
  2. Buy a DISH receiver. At the time of this writing, you want the Wally (NOPE, Wally is obsolete already). It has many desirable features, such as:
    1. Bluetooth headset support
    2. Wifi so you can stream from Netflix, etc.
    3. DVR support
  3.  When the receiver arrives, go back to DishForMyRV to the TV Channels section. Decide on the channel package you want. Make note, especially, of the Flex Pack. You may be able to get just the channels you want without having to pay for the bigger packages. Also note that there are no credit checks or contracts and no fees to start or stop the service.
  4. Call the number that's on the receiver to activate the service and set up an account with the channel pack(s) you decided on. The person you call will set up an account for you at DISH as part of the process. Do not call DISH network directly at this point!
  5. For DVR (you must have done step 4 first so that you have a DISH account),
    1. Attach a self-powered USB hard drive to your Wally receiver. Apparently DISH receivers don't supply power on their USB ports, so a flash drive won't work unless you put it into a self-powered USB card reader.
    2. Call DISH at 800-333-3474 to activate DVR on the receiver. They'll charge your account a one-time fee of $40.
  6. Now, call DISH. Tell them you have satellite TV in your RV already, but you want to use it in your house when you're not on the road. They'll send out an installer who, for a flat $147 fee, will install a free satellite dish and wire it into your receiver wherever you want to put it.
That's it. $120 for the receiver, $147 for the dish installation and $40 for DVR. Total cost $307. Start and stop the service any time you want. Change channel packs any time you want. No monthly equipment lease fees. No commitments. Satellite TV the way it should be: clean, simple and flexible. We pay only $45 a month for the "starter" and local channels.

As far as I know, DirecTV doesn't offer this kind of service.

DISH does package channels in some weird ways, though. For example, National Geographic Channel is only available in the Flex pack, not any of the higher channel count packs. Nat Geo Wild, which we would like to have, is only available in the 200 and 250 packages.

I hope many readers use this information to break out of the fine print prisons of conventional multi-year TV contracts.

Thursday, November 17, 2016

Herding Cats

Thoughts on managing independent, smart people.

Q: How do you herd cats?
A: With a mouse.

Q: How do you confuse a cat?
A: With more than one mouse.


Sunday, March 13, 2016

Large mouth bass in Maine

The original version of this essay was over the top. I apologize to those who read it. Hopefully this revised version is a little more accurate and well reasoned. jah 4/25/2016

Bass fisherman had no right to illegally introduce large mouth bass into Maine waters. In some places, these voracious fish have caused a collapse of other fisheries. If it were up to me, the Maine Department of Inland Fisheries and Wildlife (DIFW) would be doing research to find a way to destroy them. They're an invasive species and should be treated as such. At the very least, the law should require that the fish be killed after being caught.

On the other hand, one avid bash fisherman pointed out to me that in some places the water quality has deteriorated to the point that salmon and trout won't survive and reproduce, so large mouth bass aren't responsible for the collapse.

I would have no problem if the DIFW had done research and decided, for the right reasons, to introduce large mouth bass legally into former salmonid waters. But, private citizens introducing an invasive species of any kind anywhere is illegal and wrong.

Now public officials are embracing out of state bass fishermen. (Note recent efforts in Waterville that made the paper.) Who doesn't love a rich guy who throws his money around? Well, I'd rather they take their fast boats, money, publicity and attitude and go back where they came from. I only wish they could take their fish with them.

Thursday, March 3, 2016

Report on my diy silent computer system 2 years on

This system has proved to be very reliable and exceeded my expectations for performance.

(Nov. 2017 update:  The USB board in the front burned out for the second time and the company no longer makes the part. Bummer. Fortunately the Mobo wasn't damaged and the case has a separate USB3 port on the front.)

System specifications

Case: NoFan CS-60 mATX Mobo: Gigabyte GA-B75M-D3H CPU: Intel Pentium G2120 Graphics: SAPPHIRE Ultimate Radeon HD 6670 RAM: Crucial Technology 8gb (2x4) Pc3-12800 1600mhz Ddr3 Ballistix Cl9 Drives: 120 gb OCZ Vertex, 128GB Samsung SM841, Super Writemaster SATA DVD/RW PSU: SeaSonic SS-400FL2 CPU Cooler: stock Intel with Scythe Slipstream 120 Other cards: Syba ieee1394a-b PCI-X

Performance

iPlane9 and Flightgear flight simulators: smooth and responsive at max frame rates

Will run 2 Windows VMs in VirtualBox both doing updates, Firefox with a dozen or more tabs, Chromium with multiple tabs, Libreoffice with multiple documents open, and Thunderbird: switching between applications, mouse movement and typing are instantaneous; opening additional applications, e.g. gthumb to import pictures, is as fast as if nothing else were running. In other words, it'll do more things at once than I can keep track of.

Boots Ubuntu 14.04: 6 seconds, timed
Load Firefox: 2 seconds
Load Gimp: 2 seconds
Load Libreoffice essentially instantaneously...less than a second
Extract a 640MB tar/gzip archive: <2 seconds

Some things it doesn't do so well:

Encode a 4GB mp4 to 1080p 60fps (same as the recording) using OpenShot Video Editor: 23 minutes
(I have no idea whether this software uses the GPU. It uses ffmpeg for encoding.)

Temperature data

Ambient temp. 20 deg. C
Stress test the CPU at 100% - max CPU core temp 56 deg. C
Flightgear for 1 hour - max GPU temp 68 deg. C, max CPU temp 57 deg. C
(Note: The CPU is above the graphics card so it will get hotter when the GPU gets hotter)

These temperatures were much higher with two different passive CPU coolers. The case is narrow so only short coolers will fit. Running a CPU stress test, the CPU cores were over 80 and still climbing. Under normal use, they were in the 60s, but running a flight simulator pushed them, again, to a level I wasn't comfortable with. So I gave up on totally fanless and installed the Scythe 120. The results speak for themselves.


Issues

1) The first OCZ SSD died within the 2-year warranty window and was replaced.
2) The firewire card has never worked...appears to be a hardware problem. I didn't care until recently and have ordered a new card.
3) When a USB2 device is plugged into the USB3 port in the back, it often locks up the USB bus. You have to power the machine down by holding the start button for 5 seconds, then start it up again. Very annoying so I don't use the port.
4) I started out with 4GB of RAM. At times it wasn't enough, especially when running VMs. Adding another 4GB eliminated the problem. As noted above, I can't run and keep track of enough tasks to overload the machine.

Summary

Many people have used the G2120 in their builds because the combination of performance, price and low power is hard to beat. SPCR has reviewed an actively cooled card with the 6670 GPU, but this particular card is passively cooled. That has proved to be sufficient in the Nofan case with no high-temp cards below it. Combining these two processing units with SATA III and an SSD yields a fast, responsive system for day-to-day tasks. To my ears it's totally silent, but I'm 65 years old and my hearing isn't what it used to be. For those who want hard numbers, SPCR has tested the version of this fan without PWM: http://www.silentpcreview.com/article83 ... .html#SS-M

Monday, February 15, 2016

Guns, Kids and Power

So much of the public rhetoric, both for and against firearms, confuses statistical correlation with cause and effect. For example, states that have both more firearms and more firearm deaths may have other correlative factors...perhaps more alcohol consumption or more children per household or more poverty or less education. Or something else, entirely. No one of those factors can be singled out as the cause.

Let's face it, if an area has more cars, there are more car accidents. Do we take cars away from people? No, we require more driver training and put more restrictions on use by minors.

Roughly 100 children are killed in bicycle accidents every year. Does anyone call for taking bikes away from kids?

People who don't grow up around firearms often view them as an unnecessary evil. For those who are used to them, they're just another tool; one to be handled with respect just like any tool or machine that can injure or kill.

What are the most dangerous things in our households? Electricity. Fire. Cars. 411 people died from electrocutions in the US in 2001.1 Seven people died each day in U.S. home fires.2 According to the CDC3, motor vehicles were the leading cause of death of children and young adults from ages 5 - 24 in 2013. That same year, accidental death by firearms was 10th in the 5-9 age group, 9th in the 10-14 group and didn't make the top 10 for teens. Homicide by firearm was near the top of the list in every age group, but that's surely a function of gang violence, which is a whole different problem.

I really wish we would focus our energies on violence in our culture and on the socio-economic disparity that drives it. Then we might get somewhere. People who are productive and have non-violent control over their lives don't, generally, commit crimes or kill others. Feelings of helplessness and hopelessness that become despair and rage...those are what we must deal with. Disparity in power is at the core of all of the violence in the world, not just the U.S.

Does there seem to be a theme here?


1. Seven people die each day in reported U.S. home fires
2. Deaths from Electrocution 
3. Ten Leading Causes of Death and Injury