2002 11 07

                    LINUX NEWS
          November 7, 2002 -- Issue #106


1) Sean’s Notes

2) Linux News

Red Hat Announces New Certification
GNOME Foundation Board Elections
A Bug or Two... Or Six
Missing Chapter From Mitnick's Book

3) Linux Resources

Everything You Ever Wanted to Know About LDAPv3
                       (But Were Afraid to Ask)
Enterprise Snort Installation
Securely Speaking
Fighting Spam
Python Resources

4) App o’ the Week

~~~~~~~~~~~~~~~~~~~~~~ ADVERTISEMENT ~~~~~~~~~~~~~~~~~~~~~~~

Gain study time and enhance your learning! Hear hundreds of certification exam questions on audio CDs or cassettes. Learn while you commute to and from work, exercise, or walk the dog. Ideal for those times when you can’t read. 90-day money back guarantee if you’re not happy.


For information on how to advertise in this newsletter
please contact mailto:adsales@CramSession.com or visit

1) Sean's Notes

Like many people with a Linux box on a cable modem, I've got a
web server.  Nothing fancy, but one of the things it does is let
my brother and I post pictures of our kids for our family to
see.  So, we scan in the pictures, create a directory, and
upload the files.

However, what you end up with is a pathetic looking directory
listing that Apache gives you.  What I'd rather have is a page
of thumbnails, each linked to the full sized picture.  In shell,
this is pretty easy:

<div class="highlight"><pre><code class="bash"><span class="nb">echo</span> <span class="s2">&quot;My pictures &amp;lt;br&gt;&quot;</span> &gt; index.html
<span class="k">for </span>i in <span class="sb">`</span>ls <span class="se">\*</span>.jpg <span class="p">|</span> grep -v ^tn_<span class="sb">`</span><span class="p">;</span> <span class="k">do</span>
<span class="k">  </span>convert -interlace NONE -geometry 133x133 <span class="nv">$i</span> tn_<span class="nv">$i</span>
  <span class="nb">echo</span> <span class="s2">&quot;&amp;lt;a href=$i&gt;&amp;lt;img src=tn_$i&gt;&amp;lt;/a&gt;&amp;lt;p&gt;&quot;</span> &gt;&gt; index.html
<span class="k">done</span>

Basically, that iterates through each .jpg that doesn't begin
with tn\_, and uses the ImageMagick "convert" command to make a
133x133 thumbnail of it called tn_imagename.jpg.  The rest is
some simple HTML.  It's not too much from there to make this
iterate over some directories.

Ick.  Each time I re-run this script, it has to recreate the
thumbnail from the original file, even if the original file
hasn't changed.  Then, even if none of the files have changed,
the index file has to be recreated.  What a waste.  This was
fine for a while, but my brother is some sort of scanning freak,
and updating his page became a 10 minute job.

What we need is some sort of dependency system.  Developers have
had this for ages, it's called "make".  Make's job is to take a
config file that describes the relationship between files, and
to execute the proper commands to bring everything up to date.

For example, a programmer might have 100 source files.  Each
file is compiled into an object file, and all the object files
are linked together into an executable.  If one source file is
updated, then only one object file has to be recreated and the
linking step redone to get the final executable.  It saves a lot
of time.

Makefiles are pretty simple.  If we had two .c files that we
wanted to build into an executable called "program", we could do:

program: file1.o file2.o
	gcc file1.o file2.o -o program

%.o: %.c
	gcc -c $&lt; -o $@

Call it "Makefile", and all you have to type is "make" at the
command line.  This makefile has two stages.  Each stage
consists of:

target: dependencies
	instructions for creating target
	more instructions
	note that there are no blank lines, and it is tab indented

The first target is for the "program" executable itself.  It
says that "program" needs "file1.o" and "file2.o".  If either
are newer than program, then program has to be rebuilt.  You
rebuild it by invoking gcc.

The second stage is what is called an implicit rule.  Since the
commands to build file1.o are the same as building file2.o, I
use an implicit rule to say "to build a .o file from a .c file,
do this".  $&lt; is expanded to the name of the original (or
dependency) file, and $@ is the name of the target.

If you don't specify which target to make, the first target is
built.  Thus, "make", or "make program" are the same.  Likewise,
to rebuild file2.o, you could run "make file2.o".

Back on to the pictures.  Makefiles sound like a great fit.
Nothing says that my makefile has to use a compiler!  I'll use
some basic shell scripting to build the HTML, and good old
ImageMagick to make the thumbnails like I did in my original

At the beginning of my Makefile, I defined some variables (note
the use of := to define a variable, and the "shell" command to
insert the results of a shell command).

<div class="highlight"><pre><code class="bash">INDEXFILE :<span class="o">=</span> index.html
<span class="c"># Precompute the names of the thumbnails</span>
<span class="c"># sed is used to prefix each filename with tn_</span>
THUMBS :<span class="o">=</span> <span class="k">$(</span>shell ls <span class="se">\*</span>.jpg <span class="p">|</span> grep -v <span class="s2">&quot;^tn_&quot;</span> <span class="p">|</span> sed <span class="s1">&#39;s/^/tn_/&#39;</span><span class="k">)</span>

Next, I state that index.html depends on all the thumbnails.
To build the index file, I iterate through all the thumbnails,
and make a table with five columns.

<div class="highlight"><pre><code class="bash"><span class="k">$(</span>INDEXFILE<span class="k">)</span>: <span class="k">$(</span>THUMBS<span class="k">)</span>
        @echo <span class="s2">&quot;Building index&quot;</span>
        @n<span class="o">=</span>0
        @echo <span class="s2">&quot;&amp;lt;table&gt;&quot;</span> &gt; <span class="k">$(</span>INDEXFILE<span class="k">)</span>
        @for i in <span class="k">$(</span>THUMBS<span class="k">)</span><span class="p">;</span> <span class="k">do</span> <span class="se">\</span>
                <span class="k">if</span> <span class="o">[</span> <span class="s2">&quot;$$n&quot;</span> <span class="o">==</span> <span class="s2">&quot;&quot;</span> <span class="o">]</span> <span class="p">;</span> <span class="k">then</span>  <span class="se">\</span>
                    <span class="nb">echo</span> <span class="s2">&quot;&amp;lt;tr valign=top&gt;&quot;</span> &gt;&gt; <span class="k">$(</span>INDEXFILE<span class="k">)</span><span class="p">;</span>  <span class="se">\</span>
                <span class="k">fi</span><span class="p">;</span>  <span class="se">\</span>
                <span class="nv">PIC</span><span class="o">=</span><span class="sb">`</span><span class="nb">echo</span> <span class="nv">$$</span>i <span class="p">|</span> sed <span class="s1">&#39;s/^tn_//&#39;</span><span class="sb">`</span><span class="p">;</span> <span class="se">\</span>
<span class="nb">echo</span> <span class="s2">&quot;&amp;lt;td&gt;&amp;lt;a href=$$PIC&gt;&amp;lt;img src=$$i&gt;&amp;lt;/a&gt;&amp;lt;/td&gt;&quot;</span>  &gt;&gt; <span class="k">$(</span>INDEXFILE<span class="k">)</span> <span class="p">;</span> <span class="se">\</span>
                <span class="k">if</span> <span class="o">[</span> <span class="s2">&quot;$$n&quot;</span> <span class="o">==</span> <span class="s2">&quot;4&quot;</span> <span class="o">]</span><span class="p">;</span> <span class="k">then</span> <span class="se">\</span>
                        <span class="nb">echo</span> <span class="s2">&quot;&amp;lt;/tr&gt;&quot;</span> &gt;&gt; <span class="k">$(</span>INDEXFILE<span class="k">)</span><span class="p">;</span> <span class="se">\</span>
                <span class="k">fi</span><span class="p">;</span> <span class="se">\</span>
                <span class="nv">n</span><span class="o">=</span><span class="nv">$$</span><span class="o">((</span>n+1<span class="o">))</span><span class="p">;</span>  <span class="se">\</span>
                <span class="nv">n</span><span class="o">=</span><span class="nv">$$</span><span class="o">((</span>n % 5<span class="o">))</span><span class="p">;</span>  <span class="se">\</span>
        <span class="k">done</span>
        @echo <span class="s2">&quot;&amp;lt;/tr&gt;&amp;lt;/table&gt;&quot;</span> &gt;&gt; <span class="k">$(</span>INDEXFILE<span class="k">)</span><span class="p">;</span>

A few things to note.  It's all shell scripting within the
action part, but since it's being executed under make, some
changes have to be made.  For one, if you want to reference a
shell variable, you need two dollar signs instead of one.
Otherwise, make tries to evaluate the variable itself (that's
why THUMBS only has one $ and i and n have two).  Secondly,
there are a lot of \ characters in there.  They mean "continue
this line".  In a normal shell script, you don't need them, but
if you want to do loops within a makefile, you do.  Finally,
most commands are prefixed with an @.  This simply means "don't
output the actual command".  Remove them, and you'll see what I
mean, as a lot of extra stuff will be spit out.

So, I've told make how to build index.html out of all the
thumbnails.  But how do I build the thumbnails?  With the
implicit rules, it's pretty easy.:

tn_%.jpg: %.jpg
        convert -interlace NONE -geometry 133x133 "$&lt;" "$@"

So, if I add a new picture to the directory, I rerun "make" and
only one thumbnail is generated, along with the new index file:

$ touch 1.jpg
$ make
convert -interlace NONE -geometry 133x133 "1.jpg" "tn_1.jpg"
Building index

And, if I try to run it again:

$ make
make: 'index.html' is up to date.

Now I'm off to scan the latest batch of pictures!

Long live the Penguin,


2) Linux News

Red Hat Announces New Certification

The Red Hat Certified Technician certification was just
announced by Red Hat. The RHCT is a half day, practical exam,
and is ideal for people moving over from other Unixes into Linux,
or those that want a stepping stone to the prestigious RHCE.


GNOME Foundation Board Elections

It's that time again... the GNOME Foundation has just closed
nominations for its board of directors. As of closing day, only
11 people had been nominated (the board is 11 strong), including
Richard Stallman. The list is announced with 23 people in the


A Bug or Two... Or Six

Yikes. Six serious security related bugs in Mozilla. It isn't
going to stop me from using this fantastic product, but you can
bet I'll be upgrading as soon as there is a fix.


Missing Chapter From Mitnick's Book

Kevin Mitnick, who made the news with his feats of social
engineering and subsequent legal troubles, wrote a book about
the ordeal. One chapter that was in the preview version of the
book never ended up in the final copy, presumably because of the
content.  Here's the chapter (sorry for it being in .doc format).


3) Linux Resources

Everything You Ever Wanted to Know About LDAPv3
(But Were Afraid to Ask)

This slide show gets into the real details of LDAP, and the
improvements made in version 3. LDAP lets you build a central
directory for authentication or other information. It is highly
scalable, not to mention lightweight (guess what the 'L' stands


Enterprise Snort Installation

I've long been a fan of the Open Source Snort IDS, even though
enterprise management has been lacking. This document pulls
together many different software tools, and detailed
instructions, to build the system.


Securely Speaking

Here's a relatively new site devoted to fostering security
related discussions. It's also run by Cramsession user
RobnHood, who is a regular on the Linux and Security boards.


Fighting Spam

I've passed along many links dealing with technical ways to
combat spam, but another effective approach involves changing
some of your behavior. The advice in this article is easy to
follow, and should do a bit to lower the number of junk emails
you get.


Python Resources

Python is a scripting language, much like Perl, except much
cleaner and a better focus on objects. If you're looking to get
into some Python programming, here are a bunch of links to get
you started.


4) App o' the Week

"Totem is simple movie player for the Gnome desktop based on
xine. It features a simple playlist, a full-screen mode, seek
and volume controls, as well as a pretty complete keyboard


(C) 2002 BrainBuzz.com, Inc. All Rights Reserved.

          This message is from CramSession

You are currently subscribed to the following list
   Hottest Linux News and Resources
   as: sean@ertw.com

To un-subscribe from this newsletter by e-mail,
   send a blank email message to:

To subscribe to this newsletter and many others visit
our site at: